using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DevExpress.XtraEditors; using ICSSoft.Frame.Data.Entity; using ICSSoft.Frame.Data.BLL; using ICSSoft.Base.Config.AppConfig; using ICSSoft.Base.Config.DBHelper; namespace ICSSoft.Frame.APP { public partial class FormICSErrorApplyAdd : DevExpress.XtraEditors.XtraForm { FormICSShifTypeUIModel typeUIModel; int flag; string typeid; string DeptCode = ""; public FormICSErrorApplyAdd() { InitializeComponent(); InfoSelect(); //txtShiftTypeCode.Text = Convert.ToString(Convert.ToInt32(ICSShifTypeBLL.SearchMaxCode(AppConfig.AppConnectString)) + 1); flag = 0; } private void InfoSelect() { #region 加载申请部门 string deptsql = @"select cDepCode AS 部门编码,cDepName AS 部门名称 from ICSDepartment where WorkPoint='{0}' AND bDepEnd='1'"; deptsql = string.Format(deptsql, AppConfig.WorkPointCode); DataTable deptdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, deptsql).Tables[0]; txtApplyDept.Properties.ValueMember = "部门编码"; txtApplyDept.Properties.DisplayMember = "部门名称"; txtApplyDept.Properties.DataSource = deptdt; txtApplyDept.Properties.NullText = "";//空时的值 txtApplyDept.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体 txtApplyDept.Properties.ValidateOnEnterKey = true;//回车确认 txtApplyDept.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard txtApplyDept.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 //自适应宽度 txtApplyDept.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion #region 加载申请类型 string typesql = @"select EnumText AS 申请类型 from Sys_EnumValues where EnumKey='00011' AND WorkPointCode='{0}'"; typesql = string.Format(typesql, AppConfig.WorkPointCode); DataTable typedt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, typesql).Tables[0]; txtApplyType.Properties.ValueMember = "申请类型"; txtApplyType.Properties.DisplayMember = "申请类型"; txtApplyType.Properties.DataSource = typedt; txtApplyType.Properties.NullText = "";//空时的值 txtApplyType.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体 txtApplyType.Properties.ValidateOnEnterKey = true;//回车确认 txtApplyType.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard txtApplyType.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 //自适应宽度 txtApplyType.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion } private void btnOK_Click(object sender, EventArgs e) { try { if (txtApplyDept.Text.Trim() == "") { ICSBaseSimpleCode.AppshowMessageBox("申请部门不能为空!"); return; } if (txtApplyType.Text.Trim() == "") { ICSBaseSimpleCode.AppshowMessageBox("申请类型不能为空!"); return; } if (txtApplyDetial.Text.Trim() == "") { ICSBaseSimpleCode.AppshowMessageBox("申请修改内容不能为空!"); return; } #region 自动生成单据号(先获取当天最新的单据号) string DocNo = ICSErrorHandelApplyBLL.GetDocNo(AppConfig.AppConnectString); string NewDocNo = ""; if (DocNo == "") { NewDocNo = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + "001"; } else { string tempstr = DocNo.Substring(DocNo.Length - 3, 3); tempstr = (int.Parse(tempstr) + 1).ToString().PadLeft(3, '0'); NewDocNo = DocNo.Remove(DocNo.Length - 3, 3) + tempstr; } #endregion ICSErrorHandleApply info = new ICSErrorHandleApply(); info.ID = AppConfig.GetGuid(); info.DocNo = NewDocNo; info.ApplyDeptCode = txtApplyDept.EditValue.ToString(); info.ApplyType = txtApplyType.Text.Trim(); info.ApplyDetail = txtApplyDetial.Text.Trim(); info.DocStatus = "新增"; info.Muser = AppConfig.UserCode; info.MuserName = AppConfig.UserName; info.MTIME = DateTime.Now; info.ApproveMuser = ""; info.ApproveMuserName = ""; info.ApproveMTIME = null; info.WorkPoint = AppConfig.WorkPointCode; info.EATTRIBUTE1 = ""; info.EATTRIBUTE2 = 0; ICSErrorHandelApplyBLL.Add(info, AppConfig.AppConnectString); ICSBaseSimpleCode.AppshowMessageBox("新增成功"); } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Close(); this.DialogResult = DialogResult.Yes; } #region 关闭 private void btnCancle_Click(object sender, EventArgs e) { this.Close(); this.DialogResult = DialogResult.Cancel; } private void btnClose_Click(object sender, EventArgs e) { this.Close(); this.DialogResult = DialogResult.Cancel; } #endregion private void txtApplyType_EditValueChanged(object sender, EventArgs e) { try { string Type = txtApplyType.Text.Trim(); string sql = @"select EnumText AS 申请类型,Define1 AS 类型说明 from Sys_EnumValues where EnumKey='00011' AND EnumText='{0}' AND WorkPointCode='{1}'"; sql = string.Format(sql, Type, AppConfig.WorkPointCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { txtApplyhint.Text = dt.Rows[0]["类型说明"].ToString(); } } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.ToString()); } } private void txtApplyDept_EditValueChanged(object sender, EventArgs e) { } } }