/// <summary> /// 保存按钮点击,将数据保存至数据库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveBtn_Click(object sender, EventArgs e) { this.ValidateChildren(ValidationConstraints.Enabled & ValidationConstraints.TabStop & ValidationConstraints.Selectable); if (!ValidatorManager.ValidateControls(this)) { MessageBox.Show("控件内容不合法"); return; } Customer originInfo = GetOriginCustomer(); Customer currentInfo = GetCurrentCustomer(); Depute vehicle = GetDeputeInfo(); if (this.isUpdate) { try { //CustomerDao.Update(originInfo); //CustomerDao.Update(currentInfo); DeputeDao.UpdateDepute(vehicle); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } else { try { //CustomerDao.Add(originInfo); //CustomerDao.Add(currentInfo); object id = DeputeDao.AddDepute(vehicle); MessageBox.Show("当前流水号为 " + id); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } this.resetControlContent(); this.setControlReadOnly(true); this.serial.Focus(); }
/// <summary> /// 挂车交易 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void retradeBtn_Click(object sender, EventArgs e) { this.ValidateChildren(ValidationConstraints.Enabled & ValidationConstraints.TabStop & ValidationConstraints.Selectable); if (!ValidatorManager.ValidateControls(this)) { MessageBox.Show("控件内容不合法"); return; } Customer originInfo = GetOriginCustomer(); Customer currentInfo = GetCurrentCustomer(); Depute vehicle = GetDeputeInfo(); try { if (this.isUpdate) { DeputeDao.UpdateDepute(vehicle); } else { object id = DeputeDao.AddDepute(vehicle); } } catch (Exception ex) { MessageBox.Show("保存二次过户信息时出错,错误信息为:" + ex.Message); return; } if (vehicle.Istraded) { MessageBox.Show("此流水号挂车交易已经结束!"); } Vehicle _vehicle = new Vehicle(); _vehicle.OriginCustomer = GetOriginCustomer(); _vehicle.CurrentCustomer = GetCurrentCustomer(); _vehicle.License = this.license.Text; _vehicle.Vin = this.vin.Text; _vehicle.Vehicletype = new Vehicletype(); _vehicle.Vehicletype.Id = this.vehicleType.SelectedValue.ToString(); _vehicle.Brand = this.brand.Text; _vehicle.Certificate = this.certificate.Text; _vehicle.Register = this.register.Text; _vehicle.Certification = this.certification.Text; _vehicle.Department = this.department.Text; _vehicle.Company = new Company(); _vehicle.Company.Id = this.company.SelectedValue.ToString(); _vehicle.Originpic = Utilities.ConvertImage2Bytes(this.originPic.Image); _vehicle.Currentpic = Utilities.ConvertImage2Bytes(this.currentPic.Image); _vehicle.Firstpic = Utilities.ConvertImage2Bytes(this.pictureBox1.Image); _vehicle.Secondpic = Utilities.ConvertImage2Bytes(this.pictureBox2.Image); _vehicle.Thirdpic = Utilities.ConvertImage2Bytes(this.pictureBox3.Image); _vehicle.Forthpic = Utilities.ConvertImage2Bytes(this.pictureBox4.Image); _vehicle.Actual = "0"; _vehicle.Transactions = "0"; _vehicle.SaveDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); _vehicle.Saver = vehicle.Saver; try { vehicle.Reserial = VehicleDao.AddVehicle(_vehicle).ToString(); vehicle.Istraded = true; DeputeDao.UpdateDepute(vehicle); Clipboard.SetDataObject(vehicle.Reserial); MessageBox.Show("过户流水号为:" + vehicle.Reserial + "。此号码已经复制在粘贴板中,可在信息录入界面按Ctrl+V粘贴使用。"); } catch (Exception ex) { MessageBox.Show("二次过户时出错,错误信息为:" + ex.Message); return; } this.resetControlContent(); this.setControlReadOnly(true); this.serial.Focus(); }