/// <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); } }
/// <summary> /// 点击清除按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void clearBtn_Click(object sender, EventArgs e) { this.setControlReadOnly(true); this.ValidateChildren(ValidationConstraints.None); this.resetControlContent(); this.serial.Text = VehicleDao.GetCurrentDate(); this.serial.Focus(); this.serial.Select(this.serial.Text.Length, 0); }
/// <summary> /// 窗口初始化事件,初始化时启动摄像头 /// </summary> public PrintInfoForm() { InitializeComponent(); InitComboBox(); this.setControlReadOnly(true); this.serial.Text = VehicleDao.GetCurrentDate(); this.serial.Select(this.serial.Text.Length, 0); }
/// <summary> /// 检查用户名密码,取得用户信息 /// </summary> /// <returns></returns> private bool CheckPrivilege() { try { //取得用户信息 if (user == null) { user = UsersDao.GetById(this.userId.Text); } } catch (Exception e) { return(false); } //验证密码 string pwd = Utilities.Md5Encrypt(this.password.Text); if (LoginForm.user != null) { if (!user.UsersIsactive) { MessageBox.Show("用户已锁定,请联系管理员重新激活!"); return(false); } if (user.Password.Equals(Utilities.Md5Encrypt(this.password.Text))) { LoginForm.user.LoginDate = VehicleDao.GetCurrentDate(); LoginForm.user.LoginServer = server.Text; return(true); } else { MessageBox.Show("密码错误,请重试!"); return(false); } } else { MessageBox.Show("用户名不存在!"); this.userName.Text = ""; } return(false); }
private void resetControlContent() { this.originId.Text = string.Empty; this.originName.Text = string.Empty; this.originPhone.Text = string.Empty; this.originAddress.Text = string.Empty; this.originPic.Image = global::VTMS.Properties.Resources.NoneImage; this.currentId.Text = string.Empty; this.currentName.Text = string.Empty; this.currentPhone.Text = string.Empty; this.currentAddress.Text = string.Empty; this.currentPic.Image = global::VTMS.Properties.Resources.NoneImage; this.serial.Text = VehicleDao.GetCurrentDate(); this.invoice.Text = string.Empty; this.license.Text = string.Empty; this.vin.Text = string.Empty; this.vehicleType.SelectedValue = "01"; this.brand.Text = string.Empty; this.certificate.Text = string.Empty; this.register.Text = string.Empty; this.certification.Text = string.Empty; this.actual.Text = string.Empty; this.transactions.Text = string.Empty; this.department.Text = "车管所"; this.company.SelectedValue = "00"; this.pictureBox1.Image = null; this.pictureBox2.Image = null; this.pictureBox3.Image = null; this.pictureBox4.Image = null; this.Isrecorded.Checked = false; this.Ischarged.Checked = false; this.Isprstringed.Checked = false; this.Isrefund.Checked = false; this.Isgrant.Checked = false; this.vehicle = null; }
/// <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); }
/// <summary> /// 打印交易票 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void printBtn_Click(object sender, EventArgs e) { if (!this.ValidateChildren(ValidationConstraints.Enabled & ValidationConstraints.TabStop & ValidationConstraints.Selectable)) { MessageBox.Show("控件内容不合法"); 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 + "\\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 = VehicleDao.GetCurrentDate(); // 买 方 单 位 /个人 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(); } }