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; namespace WMS.FrmBaseData { public partial class FrmCapaCityDetcs : FormBase { /// /// 运力资料MODEL /// CapacityModel capaModel = new CapacityModel(); /// /// 运力资料类型MODEL /// CapacityTypeModel capaTypeModel = new CapacityTypeModel(); /// /// 运力资料类型数据源 /// List SourceList = new List(); /// /// 业务类型 /// int workflag;//0 增加 1 修改 2 删除 ; public FrmCapaCityDetcs(CapacityModel model,int flag) { capaModel = model; workflag = flag; InitializeComponent(); } private void FrmCapaCityDetcs_Load(object sender, EventArgs e) { lue_Unit.LoadData(); LEPCapacityType.LoadData(); LEPCreateType.LoadData(); try { string strCapacityTypeModel = Newtonsoft.Json.JsonConvert.SerializeObject(new CapacityTypeModel()); string strListCapacityTypeModel = WebLockConfig.Instance.WebCapacityType.execCapacityTypeGetList(strCapacityTypeModel); SourceList = Newtonsoft.Json.JsonConvert.DeserializeObject>(strListCapacityTypeModel); } catch (Exception) { SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } bind(); } private void bind() { BSCapacity.DataSource = capaModel; try { BSCapacityType.DataSource = SourceList.Find(r => r.TYPE_ID == capaModel.CAR_TYPE); DicDepartment.TextBoxValue = capaModel.CAR_DEPARTMENT; } catch { BSCapacityType.DataSource = new CapacityTypeModel(); } } private void btnCommit_Click(object sender, EventArgs e) { capaModel = BSCapacity.DataSource as CapacityModel; capaModel.CAR_DEPARTMENT = DicDepartment.TextBoxValue; if (DicDepartment.SelectTable.Rows.Count > 0 && DicDepartment.SelectTable.Rows[0][0] != null) { capaModel.CAR_DEPARTMENT = DicDepartment.TextBoxFlag; } if (string.IsNullOrEmpty(capaModel.CAR_TYPE)) { SystemCommon.ShowInfoMessageBox("运力类型未选择!"); LEPCapacityType.Focus(); return; } if(string.IsNullOrEmpty(capaModel.CAR_ID)) { SystemCommon.ShowInfoMessageBox("车牌号未填写!"); txtCarID.Focus(); return; } if (string.IsNullOrEmpty(capaModel.CAR_DEPARTMENT)) { SystemCommon.ShowInfoMessageBox("所属部门未选择!"); DicDepartment.Focus(); return; } if (capaModel.CAR_INSUREDEDDDATE < capaModel.CAR_INSUREDSRADATE) { SystemCommon.ShowInfoMessageBox("货保生效日期应在截止日期之前!"); } if (string.IsNullOrEmpty(capaModel.ID)) { capaModel.ID = Guid.NewGuid().ToString(); } string strcapaModel = Newtonsoft.Json.JsonConvert.SerializeObject(capaModel); string errtxt = string.Empty; if (workflag == 0) { errtxt = WebLockConfig.Instance.WebCapacity.execCapacityAdd(strcapaModel); } else if (workflag == 1) { errtxt = WebLockConfig.Instance.WebCapacity.execCapacityUp(strcapaModel); } if (!string.IsNullOrEmpty(errtxt)) { SystemCommon.ShowErrorMessageBox(errtxt); } else { SystemCommon.ShowInfoMessageBox("操作成功!"); } if (workflag == 0) { BSCapacity.DataSource = new CapacityModel(); } else { this.Close(); } } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void LEPCapacityType_TextChanged(object sender, EventArgs e) { } private void LEPCapacityType_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) { } private void LEPCapacityType_EditValueChanged(object sender, EventArgs e) { try { BSCapacityType.DataSource = SourceList.Find(r => r.TYPE_ID == LEPCapacityType.EditValue.ToString()); } catch { BSCapacityType.DataSource = new CapacityTypeModel(); this.Refresh(); } } } }