Пример #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();
            }
        }
Пример #2
0
 public static void DeleteRetrade(Retrade entity)
 {
     ISession session = SessionFactory.OpenSession();
     {
         session.Delete(entity);
         session.Flush();
     }
 }
Пример #3
0
 public static object AddRetrade(Retrade entity)
 {
     entity.Serial = GetLatestSerial();
     ISession session = SessionFactory.OpenSession();
     {
         var id = session.Save(entity);
         session.Flush();
         return(id);
     }
 }
Пример #4
0
 /// <summary>
 /// 设置车辆信息
 /// </summary>
 /// <param name="vehicle"></param>
 public void SetRetradeInfo(Retrade vehicle)
 {
     this.reserial.Text = vehicle.Reserial;
     this.originId.Text = vehicle.OriginCustomer.UserId;
     if (vehicle.Originpic != null)
     {
         this.originPic.Image = Utilities.ConvertBytes2Image(vehicle.Originpic);
     }
     this.currentId.Text = vehicle.CurrentCustomer.UserId;
     if (vehicle.Currentpic != null)
     {
         this.currentPic.Image = Utilities.ConvertBytes2Image(vehicle.Currentpic);
     }
     this.license.Text = vehicle.License;
     this.vin.Text     = vehicle.Vin;
     this.vehicleType.SelectedValue = vehicle.Vehicletype.Id;
     this.brand.Text         = vehicle.Brand;
     this.certificate.Text   = vehicle.Certificate;
     this.register.Text      = vehicle.Register;
     this.certification.Text = vehicle.Certification;
     this.department.Text    = vehicle.Department;
     if (vehicle.Company.Id != null)
     {
         this.company.SelectedValue = vehicle.Company.Id;
     }
     if (vehicle.Firstpic != null)
     {
         this.pictureBox1.Image = Utilities.ConvertBytes2Image(vehicle.Firstpic);
     }
     if (vehicle.Secondpic != null)
     {
         this.pictureBox2.Image = Utilities.ConvertBytes2Image(vehicle.Secondpic);
     }
     if (vehicle.Thirdpic != null)
     {
         this.pictureBox3.Image = Utilities.ConvertBytes2Image(vehicle.Thirdpic);
     }
     if (vehicle.Forthpic != null)
     {
         this.pictureBox4.Image = Utilities.ConvertBytes2Image(vehicle.Forthpic);
     }
     if (vehicle.Istraded)
     {
         this.retradeBtn.Enabled = false;
         this.saveBtn.Enabled    = false;
     }
 }
Пример #5
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();
        }
Пример #6
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();
                }
            }
        }
Пример #7
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();
                }
            }
        }
Пример #8
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();
            }
        }
Пример #9
0
 /// <summary>
 /// 设置车辆信息
 /// </summary>
 /// <param name="vehicle"></param>
 public void SetRetradeInfo(Retrade vehicle)
 {
     this.reserial.Text = vehicle.Reserial;
     this.originId.Text = vehicle.OriginCustomer.Id;
     if(vehicle.Originpic != null)
         this.originPic.Image = Utilities.ConvertBytes2Image(vehicle.Originpic);
     this.currentId.Text = vehicle.CurrentCustomer.Id;
     if (vehicle.Currentpic != null)
         this.currentPic.Image = Utilities.ConvertBytes2Image(vehicle.Currentpic);
     this.reserial.Text = vehicle.Invoice;
     this.license.Text = vehicle.License;
     this.vin.Text = vehicle.Vin;
     this.vehicleType.SelectedValue = vehicle.Vehicletype.Id;
     this.brand.Text = vehicle.Brand;
     this.certificate.Text = vehicle.Certificate;
     this.register.Text = vehicle.Register;
     this.certification.Text = vehicle.Certification;
     this.department.Text = vehicle.Department;
     if(vehicle.Company.Id != null)
         this.company.SelectedValue = vehicle.Company.Id;
     if (vehicle.Firstpic != null)
         this.pictureBox1.Image = Utilities.ConvertBytes2Image(vehicle.Firstpic);
     if (vehicle.Secondpic != null)
         this.pictureBox2.Image = Utilities.ConvertBytes2Image(vehicle.Secondpic);
     if (vehicle.Thirdpic != null)
         this.pictureBox3.Image = Utilities.ConvertBytes2Image(vehicle.Thirdpic);
     if (vehicle.Forthpic != null)
         this.pictureBox4.Image = Utilities.ConvertBytes2Image(vehicle.Forthpic);
     if (vehicle.Istraded)
     {
         this.retradeBtn.Enabled = false;
         this.saveBtn.Enabled = false;
     }
 }
Пример #10
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();
        }