void form_ShowUpdate(CarDispatch model) { selectModel = model; }
/// <summary> /// 确认保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnOK_Click(object sender, EventArgs e) { if (cLookEmployee.EditValue == null) { MessageBox.Show("请输入申请人!"); return; } if (dateOperateTime.EditValue == null) { MessageBox.Show("请输入申请日期!"); return; } if (datePlaceBackDate.EditValue == null) { MessageBox.Show("请输入预计回车日期!"); return; } if (memoDispatchReason.EditValue == null) { MessageBox.Show("请输入申请理由!"); return; } if (checkEdit3.Checked) { if (string.IsNullOrEmpty(textEdit1.Text.Trim()) || string.IsNullOrEmpty(textEdit2.Text.Trim()) || string.IsNullOrEmpty(textEdit3.Text.Trim()) || string.IsNullOrEmpty(textEdit4.Text.Trim())) { MessageBox.Show("请完善社会人员信息!"); return; } } CarDispatchApply model = new CarDispatchApply { EmployeeID = ValueConvert.ToInt32(cLookEmployee.EditValue), CarID = ValueConvert.ToNullableInt32(cLCarNo.EditValue), ApplyDate = ValueConvert.ToDateTime(dateApply.EditValue), PlaceBackDate = ValueConvert.ToDateTime(datePlaceBackDate.EditValue), Status = 1, DispatchReason = memoDispatchReason.Text, OperatorID = Program.CurrentEmployee.EmployeeID, OperateTime = ValueConvert.ToDateTime(dateOperateTime.EditValue) }; if (radioGroup1.SelectedIndex == 0) { model.ApplyMode = "CP"; model.CarID = ValueConvert.ToInt32(cLCarNo.EditValue); } else { model.ApplyMode = "CX"; model.CarModel = comCarModel.Text; } if (checkEdit1.Checked) { model.IsDriver = 0; } else if (checkEdit2.Checked) { model.IsDriver = 1; } else if (checkEdit3.Checked) { model.IsDriver = 2; } bool result = false; if (FormState == DS.MSClient.FormState.Modify) { model.ApplyID = curData.ApplyID; model.DispatchID = curData.DispatchID; result = new CarDispatchApplyDao().Update(model); } else { CarDispatch modelDis = new CarDispatch { DispatchID = new CommonDAO().GetIntUniqueNumber("t_car_dispatch"), EmployeeID = ValueConvert.ToInt32(cLookEmployee.EditValue), DispatchReason = memoDispatchReason.Text, CarID = ValueConvert.ToNullableInt32(cLCarNo.EditValue), ApplyDate = ValueConvert.ToDateTime(dateApply.EditValue), PlaceBackDate = ValueConvert.ToDateTime(datePlaceBackDate.EditValue), Status = 0, OperatorID = Program.CurrentEmployee.EmployeeID, OperateTime = ValueConvert.ToDateTime(dateOperateTime.EditValue) }; if (new CarDispatchDao().Add(modelDis)) { model.ApplyID = new CommonDAO().GetIntUniqueNumber("t_car_dispatch_apply"); model.DispatchID = modelDis.DispatchID; result = new CarDispatchApplyDao().Add(model); } } if (result) { new CarDispatchDao().UpdateApplyDate(model); CarApplySocialpeople model1 = new CarApplySocialpeople(); model1.Name = textEdit1.Text; model1.IdentityNo = textEdit2.Text; model1.DriverLicense = textEdit3.Text; model1.FileNumber = textEdit4.Text; new CarApplySocialpeopleDao().Add(model1); MessageBox.Show("保存成功"); this.DialogResult = DialogResult.OK; } }