Esempio n. 1
0
        private void Receive(string serial)
        {
            this.serial.Text = serial;
            vehicle          = RetradeDao.GetBySerial(serial);
            if (vehicle != null)
            {
                this.setControlReadOnly(false);

                this.isUpdate = true;

                try
                {
                    SetRetradeInfo(vehicle);
                }
                catch
                {
                    MessageUtil.ShowWarning("发生错误!");
                }

                this.SetOriginCustomer(vehicle.OriginCustomer);

                this.SetCurrentCustomer(vehicle.CurrentCustomer);
            }
            else
            {
                this.serial.Focus();
            }
        }
Esempio n. 2
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();
            Retrade  vehicle     = GetRetradeInfo();

            if (this.isUpdate)
            {
                try
                {
                    //CustomerDao.Update(originInfo);
                    //CustomerDao.Update(currentInfo);
                    RetradeDao.UpdateRetrade(vehicle);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else
            {
                try
                {
                    //CustomerDao.Add(originInfo);
                    //CustomerDao.Add(currentInfo);
                    object id = RetradeDao.AddRetrade(vehicle);
                    MessageBox.Show("当前流水号为 " + id);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }

            this.resetControlContent();
            this.setControlReadOnly(true);
            this.serial.Focus();
        }
Esempio n. 3
0
        /// <summary>
        /// 流水号失去焦点后,如果用户输入了流水号,则根据输入的流水号进行查找,否则生成流水号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void serial_Leave(object sender, EventArgs e)
        {
            if (this.serial.ReadOnly || (this.serial.Text.Length != 11 && this.serial.Text.Length != 0))
            {
                return;
            }

            InitComboBox();

            if (Utilities.IsNullOrEmpty(this.serial.Text))
            {
                vehicle = new Retrade();

                this.serial.Text = RetradeDao.GetLatestSerial();

                this.setControlReadOnly(false);

                this.isUpdate = false;
            }
            else
            {
                vehicle = RetradeDao.GetBySerial(this.serial.Text);
                if (vehicle != null)
                {
                    this.setControlReadOnly(false);

                    this.isUpdate = true;

                    SetRetradeInfo(vehicle);

                    this.SetOriginCustomer(vehicle.OriginCustomer);

                    this.SetCurrentCustomer(vehicle.CurrentCustomer);
                }
                else
                {
                    this.serial.Focus();
                }
            }
        }
Esempio n. 4
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();
        }