using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using WMS.Frm.Base; using WMS.Model.Base; using WMS.Common; using WMS.Base.WebService; using WMS.Frm; namespace WMS.FrmBaseData { public partial class FrmCapacityType : FormBase { /// /// 运力类型MODEL /// CapacityTypeModel capaTypeModel = new CapacityTypeModel(); /// /// 运力类型数据源 /// List SourceList = new List(); /// /// 业务类型 /// int workflag;//0 增加 1 修改 2 删除 ; /// /// 初始化 /// public FrmCapacityType() { InitializeComponent(); } /// /// 窗体加载 /// /// /// private void FrmCapacityType_Load(object sender, EventArgs e) { //lue_Unit //单位下拉框 //lue_Unit.Properties.NullText = ""; //lue_Unit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("VC_DICTIONARY_NAME", "单位")); //lue_Unit.Properties.ValueMember = "VC_CHAR_VALUE"; //lue_Unit.Properties.DisplayMember = "VC_DICTIONARY_NAME"; //string strResult = string.Empty; //try //{ // strResult = WebLockConfig.Instance.Common.GetCustomCtrlData("t_sys_dictionary_tab", "VC_CHAR_VALUE", "VC_DICTIONARY_NAME", " VC_DICTIONARY_TYPE = 'vc_uom' and c_flag = '1'", ""); //} //catch (Exception) //{ // SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); //} //lue_Unit.Properties.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(strResult); lue_Unit.LoadData(); LEPCreateType.LoadData(); bindGrid(); panelControl1.Enabled = false; FrmSelectModle = new CapacityTypeModel(); GCCapacityType_Click(null, null); } /// /// 通用查询 /// /// public override void LoadListData(DataTable table) { SourceList = ConvertHelper.ConvertToList(table); GCCapacityType.DataSource = SourceList; GVCapacityType.RefreshData(); } /// /// 绑定grid /// private void bindGrid() { string strCapacityTypeModel = Newtonsoft.Json.JsonConvert.SerializeObject(new CapacityTypeModel()); string Source = WebLockConfig.Instance.WebCapacityType.execCapacityTypeGetList(strCapacityTypeModel); try { SourceList = Newtonsoft.Json.JsonConvert.DeserializeObject>(Source); } catch (Exception) { SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } GCCapacityType.DataSource = SourceList; if (SourceList.Count > 0) { GVCapacityType.FocusedRowHandle = 0; } GVCapacityType.RefreshData(); GVCapacityType.ExpandAllGroups(); } #region 以下是继承的按钮事件 /// /// 新增按钮 /// public void Add() { frmButtonItem["Save"].Enabled = true; panelControl1.Enabled = true; workflag = 0; BSCapacityType.DataSource = new CapacityTypeModel(); } /// /// 保存按钮 /// public void Save() { FrmOperator(workflag); } /// /// 删除按钮 /// public void Del() { workflag = 2; if (GVCapacityType.FocusedRowHandle < 0) { SystemCommon.ShowInfoMessageBox("请选择要删除的运力类型!"); return; } if (SystemCommon.ShowMessageBoxResult("确定删除运力类型:" + GVCapacityType.GetFocusedRowCellValue("TYPE_ID").ToString()) == System.Windows.Forms.DialogResult.Yes) { Save(); } } /// /// 修改按钮 /// public void Edit() { frmButtonItem["Save"].Enabled = true; workflag = 1; panelControl1.Enabled = true; } /// /// 刷新按钮 /// public void Refresh() { bindGrid(); frmButtonItem["Save"].Enabled = false; panelControl1.Enabled = false; } /// /// 确定按钮 /// public void ConfrimDataButton() { } /// /// 查询按钮 /// public void Search() { FrmSelect frm = new FrmSelect(this.FrmSelectModle); if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.LoadListData(frm.SelectData); } } /// /// 导出按钮 /// public void Export() { SaveFileDialog fileDialog = new SaveFileDialog(); fileDialog.Title = "导出Excel"; fileDialog.Filter = "Excel文件(*.xls)|*.xls"; DialogResult dialogResult = fileDialog.ShowDialog(this); if (dialogResult == DialogResult.OK) { //DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions(); try { GCCapacityType.ExportToXls(fileDialog.FileName); DevExpress.XtraEditors.XtraMessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception e) { SystemCommon.ShowInfoMessageBox("导出失败:" + e.Message); } } } /// /// 打印按钮 /// public void PrintDataButton() { } /// /// 备注 /// protected new void NoteDataButton(FormBase fBase) { } /// /// 导入 /// public void Import() { } /// /// 反审核 /// public void ReturnAuditDataButton() { } #endregion #region 操作(增、改、删) /// /// 操作(增、改、删) /// /// 0 新增 1修改 2删除 3停用 4启用/param> private void FrmOperator(int flag) { BSCapacityType.EndEdit(); string errtxt = string.Empty; try { capaTypeModel = BSCapacityType.DataSource as CapacityTypeModel; if (string.IsNullOrEmpty(capaTypeModel.TYPE_ID)) { SystemCommon.ShowInfoMessageBox("类型编号不能为空!"); return; } if (string.IsNullOrEmpty(capaTypeModel.TYPE_NAME)) { SystemCommon.ShowInfoMessageBox("类型名称不能为空!"); return; } if (flag == 0) { string strCapacityTypeAddModel = Newtonsoft.Json.JsonConvert.SerializeObject(capaTypeModel); errtxt = WebLockConfig.Instance.WebCapacityType.execCapacityTypeAdd(strCapacityTypeAddModel); } else if (flag == 1) { string strCapacityTypeUpModel = Newtonsoft.Json.JsonConvert.SerializeObject(capaTypeModel); errtxt = WebLockConfig.Instance.WebCapacityType.execCapacityTypeUp(strCapacityTypeUpModel); } else if (flag == 2) { errtxt = WebLockConfig.Instance.WebCapacityType.execCapacityTypeDel(capaTypeModel.TYPE_ID); } if (!string.IsNullOrEmpty(errtxt)) { SystemCommon.ShowErrorMessageBox(errtxt); } else { SystemCommon.ShowInfoMessageBox("操作成功!"); bindGrid(); frmButtonItem["Save"].Enabled = false; panelControl1.Enabled = false; } } catch (Exception e) { SystemCommon.ShowInfoMessageBox("您的操作有误!" + Environment.NewLine + e.Message); } } #endregion /// /// 单击一行选定 /// /// /// private void GCCapacityType_Click(object sender, EventArgs e) { if (GVCapacityType.FocusedRowHandle < 0) { return; } capaTypeModel = GVCapacityType.GetRow(GVCapacityType.FocusedRowHandle) as CapacityTypeModel; BSCapacityType.DataSource = capaTypeModel; } private void txtLong_TextChanged(object sender, EventArgs e) { CapacityTypeModel type = BSCapacityType.DataSource as CapacityTypeModel; type.TYPE_VOLUME = isnull(txtLong.Text) * isnull(txtWight.Text) * isnull(txtHigh.Text); } private void txtWight_TextChanged(object sender, EventArgs e) { CapacityTypeModel type = BSCapacityType.DataSource as CapacityTypeModel; type.TYPE_VOLUME = isnull(txtLong.Text) * isnull(txtWight.Text) * isnull(txtHigh.Text); } private void txtHigh_TextChanged(object sender, EventArgs e) { CapacityTypeModel type = BSCapacityType.DataSource as CapacityTypeModel; type.TYPE_VOLUME = isnull(txtLong.Text) * isnull(txtWight.Text) * isnull(txtHigh.Text); } private decimal isnull(string text) { try { return string.IsNullOrEmpty(text) ? 0 : Convert.ToDecimal(text); } catch { return 0; } } private void GVCapacityType_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { if (e.Value == null || e.Value == DBNull.Value) { return; } if (e.Column.FieldName == "STATUS") { switch (e.Value.ToString().Trim()) { case "0": e.DisplayText = "停用"; break; case "1": e.DisplayText = "启用"; break; } } } private void txtTypeID_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtTypeID.Text)) { CapacityTypeModel type = new CapacityTypeModel() { TYPE_ID = txtTypeID.Text }; string strCapacityTypeModel = Newtonsoft.Json.JsonConvert.SerializeObject(type); string Source = WebLockConfig.Instance.WebCapacityType.execCapacityTypeGetList(strCapacityTypeModel); List list = Newtonsoft.Json.JsonConvert.DeserializeObject>(Source); if (list.Count > 0) { SystemCommon.ShowInfoMessageBox("该运力类型编号已存在!"); txtTypeID.Text = ""; txtTypeID.Select(); } } } } }