示例#1
0
        /// <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();

            if (this.isUpdate)
            {
                try
                {
                    vehicle        = VehicleDao.GetBySerial(vehicle.Serial);
                    originInfo.Id  = vehicle.OriginCustomer.Id;
                    currentInfo.Id = vehicle.CurrentCustomer.Id;
                    CustomerDao.Update(originInfo);
                    CustomerDao.Update(currentInfo);

                    vehicle = GetVehicleInfo();
                    vehicle.OriginCustomer  = originInfo;
                    vehicle.CurrentCustomer = currentInfo;
                    VehicleDao.UpdateVehicle(vehicle);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else
            {
                try
                {
                    CustomerDao.Add(originInfo);
                    CustomerDao.Add(currentInfo);

                    vehicle = GetVehicleInfo();
                    vehicle.OriginCustomer  = originInfo;
                    vehicle.CurrentCustomer = currentInfo;
                    object id = VehicleDao.AddVehicle(vehicle);
                    MessageBox.Show("当前流水号为 " + id);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }

            this.resetControlContent();
            this.setControlReadOnly(true);
            this.serial.Focus();
        }
示例#2
0
        /// <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();
            Retrade  vehicle     = GetRetradeInfo();

            try
            {
                if (this.isUpdate)
                {
                    RetradeDao.UpdateRetrade(vehicle);
                }
                else
                {
                    object id = RetradeDao.AddRetrade(vehicle);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存二次过户信息时出错,错误信息为:" + ex.Message);
                return;
            }

            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;
                RetradeDao.UpdateRetrade(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();
        }