Ejemplo n.º 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private bool saveInfo()
        {
            vehicle = VehicleDao.GetBySerial(this.serial.Text);
            this.ValidateChildren(ValidationConstraints.Enabled & ValidationConstraints.TabStop & ValidationConstraints.Selectable);
            if (!ValidatorManager.ValidateControls(this))
            {
                MessageBox.Show("控件内容不合法");
                return(false);
            }
            Customer originInfo  = GetOriginCustomer();
            Customer currentInfo = GetCurrentCustomer();

            vehicle = GetVehicleInfo();
            try
            {
                originInfo.Id  = vehicle.OriginCustomer.Id;
                currentInfo.Id = vehicle.CurrentCustomer.Id;
                CustomerDao.Update(originInfo);
                CustomerDao.Update(currentInfo);

                vehicle.OriginCustomer  = originInfo;
                vehicle.CurrentCustomer = currentInfo;
                VehicleDao.UpdateVehicle(vehicle);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        private void Receive(string serial)
        {
            this.serial.Text = serial;
            vehicle          = VehicleDao.GetBySerial(serial);
            if (vehicle != null)
            {
                this.setControlReadOnly(false);

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

                this.SetOriginCustomer(vehicle.OriginCustomer);

                this.SetCurrentCustomer(vehicle.CurrentCustomer);
            }
            else
            {
                this.serial.Focus();
            }
        }
Ejemplo 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)
            {
                return;
            }
            vehicle = VehicleDao.GetBySerial(this.serial.Text);;
            if (vehicle != null)
            {
                this.setControlReadOnly(false);

                InitComboBox();

                SetVehicleInfo(vehicle);

                this.SetOriginCustomer(CustomerDao.GetById(vehicle.OriginCustomer.UserId));

                this.SetCurrentCustomer(CustomerDao.GetById(vehicle.CurrentCustomer.UserId));
            }
            else
            {
                MessageBox.Show("无此数据:流水号" + this.serial.Text);
                this.serial.Focus();
                this.serial.Text = VehicleDao.GetCurrentDate();
                this.serial.Select(this.serial.Text.Length, 0);
            }
        }
Ejemplo n.º 4
0
 protected override Vehicle GetVehicleInfo()
 {
     vehicle           = VehicleDao.GetBySerial(vehicle.Serial);
     vehicle.Isgrant   = true;
     vehicle.GrantDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture);
     vehicle.Granter   = LoginForm.user;
     return(vehicle);
 }
Ejemplo n.º 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();

            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();
        }
Ejemplo n.º 6
0
 protected override Vehicle GetVehicleInfo()
 {
     vehicle = VehicleDao.GetBySerial(vehicle.Serial);
     if (base.FunctionBtn.Text == "缴费")
     {
         vehicle.Ischarged  = true;
         vehicle.Isrefund   = false;
         vehicle.ChargeDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture);
         vehicle.Charger    = LoginForm.user;
         return(vehicle);
     }
     else
     {
         vehicle.Isrefund   = true;
         vehicle.Ischarged  = false;
         vehicle.RefundDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture);
         vehicle.Refunder   = LoginForm.user;
         return(vehicle);
     }
 }
Ejemplo n.º 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;
            }

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

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

                this.setControlReadOnly(false);

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

                    this.isUpdate = true;

                    SetVehicleInfo(vehicle);

                    this.SetOriginCustomer(vehicle.OriginCustomer);

                    this.SetCurrentCustomer(vehicle.CurrentCustomer);
                }
                else
                {
                    this.serial.Focus();
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 打印交易票
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void printBtn_Click(object sender, EventArgs e)
        {
            try
            {
                vehicle           = VehicleDao.GetBySerial(this.serial.Text);
                vehicle.Isprinted = true;
                vehicle.Isgrant   = false;
                VehicleDao.UpdateVehicle(vehicle);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            Object oMissing = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Excel.Application m_objExcel = null;

            Microsoft.Office.Interop.Excel._Workbook m_objBook = null;

            Microsoft.Office.Interop.Excel.Sheets m_objSheets = null;

            Microsoft.Office.Interop.Excel._Worksheet m_objSheet = null;

            Microsoft.Office.Interop.Excel.Range m_objRange = null;

            try
            {
                m_objExcel = new Microsoft.Office.Interop.Excel.Application();

                DirectoryInfo Dir = new DirectoryInfo(".");

                m_objBook = m_objExcel.Workbooks.Open(Dir.FullName + "/Templete/Input.xls", oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);

                m_objSheets = (Microsoft.Office.Interop.Excel.Sheets)m_objBook.Worksheets;

                m_objSheet = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.get_Item(1));

                // 开票日期
                m_objRange = m_objSheet.get_Range("B1", oMissing);

                m_objRange.Value = DateTime.ParseExact(VehicleDao.GetCurrentDate(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy/MM/dd");

                // 开票人
                m_objRange = m_objSheet.get_Range("K19", oMissing);

                m_objRange.Value = LoginForm.user.UsersName;

                // 买 方 单 位 /个人
                m_objRange = m_objSheet.get_Range("C5", oMissing);

                m_objRange.Value = this.currentName.Text;

                // 单位代码/身份证号码

                m_objRange = m_objSheet.get_Range("K5", oMissing);

                m_objRange.Value = this.currentId.Text;

                // 买方单位/个人住址
                m_objRange = m_objSheet.get_Range("C6", oMissing);

                m_objRange.Value = this.currentAddress.Text;

                // 电话
                m_objRange = m_objSheet.get_Range("L6", oMissing);

                m_objRange.Value = this.currentPhone.Text;

                // 卖 方 单 位/ 个人

                m_objRange = m_objSheet.get_Range("C7", oMissing);

                m_objRange.Value = this.originName.Text;

                // 单位代码/身份证号码
                m_objRange = m_objSheet.get_Range("K7", oMissing);

                m_objRange.Value = this.originId.Text;

                // 卖方单位/个人住址
                m_objRange = m_objSheet.get_Range("C8", oMissing);

                m_objRange.Value = this.originAddress.Text;

                // 电话
                m_objRange = m_objSheet.get_Range("L8", oMissing);

                m_objRange.Value = this.originPhone.Text;

                // 车   牌   照   号
                m_objRange = m_objSheet.get_Range("C9", oMissing);

                m_objRange.Value = "辽B." + this.license.Text;

                // 登记证号
                m_objRange = m_objSheet.get_Range("E9", oMissing);

                m_objRange.Value = this.certificate.Text;

                // 车 辆 类 型
                m_objRange = m_objSheet.get_Range("L9", oMissing);

                m_objRange.Value = this.vehicleType.Text;

                // 车架号/车辆识别代码
                m_objRange = m_objSheet.get_Range("C10", oMissing);

                m_objRange.Value = this.vin.Text;

                // 厂牌型号
                m_objRange = m_objSheet.get_Range("E10", oMissing);

                m_objRange.Value = this.brand.Text;

                // 转入地车辆管理所名称
                m_objRange = m_objSheet.get_Range("L10", oMissing);

                m_objRange.Value = this.department.Text;

                // 车价 合 计(大写)
                m_objRange = m_objSheet.get_Range("C11", oMissing);

                m_objRange.Value = this.transactions.Text;

                // 车价 合 计(小写)
                m_objRange = m_objSheet.get_Range("L11", oMissing);

                m_objRange.Value = this.transactions.Text;

                m_objExcel.DisplayAlerts = false;
                m_objSheet.PrintOut();
            }

            catch (Exception ex)
            {
                MessageBox.Show("打印失败,请检查打印机设置。错误信息:" + ex.Message);
            }

            finally
            {
                if (m_objBook != null)
                {
                    m_objBook.Close(oMissing, oMissing, oMissing);

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBook);
                }
                if (m_objExcel != null)
                {
                    m_objExcel.Workbooks.Close();
                    m_objExcel.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objExcel);
                }

                m_objBook = null;

                m_objExcel = null;

                GC.Collect();
            }

            this.resetControlContent();
            this.setControlReadOnly(true);
            this.serial.Focus();
            this.serial.Select(this.serial.Text.Length, 0);
        }