public UnitOfWork(IDbConnection connection) { _connection = connection; AccountDao = new AccountDao(connection); BusCoordinateDao = new BusCoordinateDao(connection); BusDao = new BusDao(connection); BusDriverDao = new BusDriverDao(connection); CityDao = new CityDao(connection); CountryDao = new CountryDao(connection); DistanceDao = new DistanceDao(connection); DistrictDao = new DistrictDao(connection); DriverDao = new DriverDao(connection); DriverContactDao = new DriverContactDao(connection); LocationDao = new LocationDao(connection); LookupsDao = new LookupsDao(connection); LookupValuesDao = new LookupValuesDao(connection); RepairSpecialistDao = new RepairSpecialistDao(connection); RoleDao = new RoleDao(connection); RouteDao = new RouteDao(connection); RouteLocationDao = new RouteLocationDao(connection); TripDao = new TripDao(connection); TripBusDao = new TripBusDao(connection); TripBusDriverDao = new TripBusDriverDao(connection); UserDao = new UserDao(connection); VehicleDao = new VehicleDao(connection); ScheduleDao = new ScheduleDao(connection); ScheduleLocationDao = new ScheduleLocationDao(connection); StoredProcedureDao = new StoredProcedureDao(connection); }
/// <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> /// <returns></returns> public Vehicle GetVehicleInfo() { vehicle.Serial = this.serial.Text; vehicle.Invoice = this.invoice.Text; 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.Actual = this.actual.Text; vehicle.Transactions = this.transactions.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.PrintDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); vehicle.Printer = LoginForm.user; return(vehicle); }
private void searchBtn_Click(object sender, EventArgs e) { //DataTable dt = new DataTable(); //if (Utilities.IsNullOrEmpty(this.serialSearch.Text) && Utilities.IsNullOrEmpty(this.customerId.Text) && Utilities.IsNullOrEmpty(this.license.Text) && Utilities.IsNullOrEmpty(this.customerName.Text)) //{ // SearchForm_Load(sender, e); //} //System.Collections.IList list = VehicleDao.SearchResult(this.serialSearch.Text, this.customerName.Text, this.customerId.Text, this.license.Text); //if (list != null) //{ // dt.Columns.Add("Serial"); // dt.Columns.Add("OriginId"); // dt.Columns.Add("OriginName"); // dt.Columns.Add("CurrentId"); // dt.Columns.Add("CurrentName"); // dt.Columns.Add("VehicleType"); // dt.Columns.Add("License"); // dt.Columns.Add("Brand"); // for (int i = 0; i < list.Count; i++) // { // object[] tmp = (object[])list[i]; // object[] o = new object[] { tmp[0], tmp[2], tmp[3], tmp[5], tmp[6], tmp[7], tmp[8], tmp[9] }; // dt.Rows.Add(o); // } //} this.dataGridView.DataSource = VehicleDao.SearchResult(this.serialSearch.Text, this.customerName.Text, this.customerId.Text, this.license.Text).Tables[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); }
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(); } }
private void saveBtn_Click(object sender, EventArgs e) { if (this.license.Text.Length != 5) { MessageUtil.ShowError("号牌号码输入不正确!"); return; } Archives archive = new Archives(); archive.License = this.license.Text; archive.Process = this.process.Text; archive.Reason = this.reason.Text; archive.Saver = LoginForm.user.UsersId; archive.SaveDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); try { ArchivesDao.AddArchives(archive); } catch (Exception ex) { MessageUtil.ShowError("保存档案时出错,错误信息为:" + ex.Message); } this.dataGridView.DataSource = ArchivesDao.Load(); this.clear(); }
private static Vehicle CreateAndSaveVehicle(VehicleDao vehicleDao, int i) { var vehicle = new Vehicle(); vehicle.Name = "Vehicle-" + i; vehicle.License = "VEH-000" + i; vehicleDao.Save(vehicle); return vehicle; }
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); }
/// <summary> /// 窗口初始化 /// </summary> public VehicleReportForm() { InitializeComponent(); this.dataGridView.AutoGenerateColumns = false; this.startDate.Value = DateTime.Today; this.endDate.Value = DateTime.Today; this.brand.DataSource = VehicleDao.GetBrands(); }
/// <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> /// <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(); }
/// <summary> /// 窗口初始化事件,初始化时启动摄像头 /// </summary> public PrintInfoForm() { InitializeComponent(); InitComboBox(); this.setControlReadOnly(true); 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 caculate_Click(object sender, EventArgs e) { this.dataGridView.DataSource = VehicleDao.CaculateTradeDailyReport(this.startDate.Value.Date.AddMilliseconds(-1), this.endDate.Value.Date.AddDays(1).AddMilliseconds(-1), this.dailyCondition.Text).Tables[0]; this.totalCars.Text = this.dataGridView.Rows.Count.ToString() + " (辆)"; int totalMoney = 0; for (int a = 0; a < dataGridView.Rows.Count; a++) { totalMoney += int.Parse(dataGridView.Rows[a].Cells["ActualColumn"].Value.ToString()); } this.totalMoney.Text = totalMoney.ToString() + " (元)"; }
public void WireUpNHibernate() { _sessionFactory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008 .ConnectionString( "Server=(local)\\SQLEXPRESS;initial catalog=NHibbySpike;Integrated Security=SSPI")) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Vehicle>()) .BuildSessionFactory(); _dao = new VehicleDao(); _dao.SessionFactory = _sessionFactory; }
private static VehicleDao ConstructVehicleDao() { var vehicleDao = new VehicleDao(); ISessionFactory sessionFactory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008 .ConnectionString( "Server=(local)\\SQLEXPRESS;initial catalog=NHibbySpike;Integrated Security=SSPI")) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Vehicle>()) .BuildSessionFactory(); vehicleDao.SessionFactory = sessionFactory; return vehicleDao; }
/// <summary> /// 提交点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FunctionBtn_Click(object sender, EventArgs e) { Vehicle vehicle = GetVehicleInfo(); try { VehicleDao.UpdateVehicle(vehicle); } catch (Exception ex) { MessageBox.Show(ex.Message); } this.resetControlContent(); this.setControlReadOnly(true); this.serial.Focus(); this.serial.Select(this.serial.Text.Length, 0); }
public void start(SCApplication app) { scApp = app; railDAO = scApp.RailDao; adrDAO = scApp.AddressDao; portDAO = scApp.PortDao; portIconDAO = scApp.PortIconDao; pointDAO = scApp.PointDao; groupRailDAO = scApp.GroupRailDao; sectionDAO = scApp.SectionDao; segmentDAO = scApp.SegmentDao; vehicleDAO = scApp.VehicleDao; blockZoneMasterDao = scApp.BlockZoneMasterDao; blockZoneDetaiDao = scApp.BolckZoneDetaiDao; blockZoneQueueDao = scApp.BlockZoneQueueDao; commObjCacheManager = scApp.getCommObjCacheManager(); }
/// <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 Alter getPrintInfo() { if (!this.isUpdate) { alter.Saver = LoginForm.user.UsersId; alter.SaveDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); } alter.Serial = this.serial.Text; alter.Category = this.category.Text; alter.License = this.license.Text; alter.OwnerName = this.ownerName.Text; alter.Purpose = this.purpose.Text; alter.Owner = this.owner.Text; alter.NewAddress = this.newAddress.Text; alter.PostAddress = this.postAddress.Text; alter.Postcode = this.postcode.Text; alter.Email = this.email.Text; alter.Phone = this.phone.Text; alter.Mobile = this.mobile.Text; alter.Province = this.province.Text; alter.Department = this.department.Text; alter.Engine = this.engine.Checked; alter.Body = this.body.Checked; alter.Color = this.color.Checked; alter.Whole = this.whole.Checked; alter.EngineCode = this.engineCode.Checked; alter.Vin = this.vin.Checked; alter.IdCode = this.idCode.Checked; alter.Information = this.information.Text; alter.AgentName = this.agentName.Text; alter.AgentPhone = this.agentPhone.Text; alter.AgentPostcode = this.agentPostcode.Text; alter.AgentAddress = this.agentAddress.Text; alter.AgentEmail = this.agentEmail.Text; alter.HandlerName = this.handlerName.Text; alter.HandlerPhone = this.handlerPhone.Text; alter.PrintDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); alter.Printer = LoginForm.user.UsersId; return(alter); }
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); } }
private Apply getPrintInfo() { if (!this.isUpdate) { apply.Saver = LoginForm.user.UsersId; apply.SaveDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); } apply.Serial = this.serial.Text; apply.Category = this.category.Text; apply.License = this.license.Text; apply.PlateRenew = this.plateRenew.Text; apply.PlateChange = this.plateChange.Text; apply.DriverRenew = this.driverRenew.Text; apply.DriverChange = this.driverChange.Text; apply.LicenseApply = this.licenseApply.Text; apply.LicenseRenew = this.licenseRenew.Text; apply.LicenseChange = this.licenseChange.Text; apply.SignApply = this.signApply.Text; apply.SignRenew = this.signRenew.Text; apply.SignChange = this.signChange.Text; apply.OwnerName = this.ownerName.Text; apply.OwnerAddress = this.ownerAddress.Text; apply.OwnerPostcode = this.ownerPostcode.Text; apply.OwnerPhone = this.ownerPhone.Text; apply.OwnerEmail = this.ownerEmail.Text; apply.OwnerMobile = this.ownerMobile.Text; apply.AgentName = this.agentName.Text; apply.AgentPhone = this.agentPhone.Text; apply.AgentPostcode = this.agentPostcode.Text; apply.AgentAddress = this.agentAddress.Text; apply.AgentEmail = this.agentEmail.Text; apply.HandlerName = this.handlerName.Text; apply.HandlerPhone = this.handlerPhone.Text; apply.PrintDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); apply.Printer = LoginForm.user.UsersId; return(apply); }
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; }
private Register getPrintInfo() { if (!this.isUpdate) { register.Saver = LoginForm.user.UsersId; register.SaveDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); } register.Serial = this.serial.Text; register.Category = this.category.Text; register.License = this.license.Text; register.Apply = this.apply.Text; register.Revoke = this.revoke.Text; register.Brand = this.brand.Text; register.Vin = this.vin.Text; register.Obtain = this.obtain.Text; register.Purpose = this.purpose.Text; register.OwnerName = this.ownerName.Text; register.OwnerAddress = this.ownerAddress.Text; register.OwnerPostcode = this.ownerPostcode.Text; register.OwnerPhone = this.ownerPhone.Text; register.OwnerEmail = this.ownerEmail.Text; register.OwnerMobile = this.ownerMobile.Text; register.Province = this.province.Text; register.Department = this.department.Text; register.AgentName = this.agentName.Text; register.AgentPhone = this.agentPhone.Text; register.AgentPostcode = this.agentPostcode.Text; register.AgentAddress = this.agentAddress.Text; register.AgentEmail = this.agentEmail.Text; register.HandlerName = this.handlerName.Text; register.HandlerPhone = this.handlerPhone.Text; register.PrintDate = DateTime.ParseExact(VehicleDao.GetCurrentTimestamp(), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); register.Printer = LoginForm.user.UsersId; return(register); }
/// <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(); } } }
private void SearchForm_Load(object sender, EventArgs e) { //System.Collections.IList list = VehicleDao.GetFirst20Row(); //DataTable dt = new DataTable(); //if (list != null) //{ // dt.Columns.Add("Serial"); // dt.Columns.Add("OriginId"); // dt.Columns.Add("OriginName"); // dt.Columns.Add("CurrentId"); // dt.Columns.Add("CurrentName"); // dt.Columns.Add("VehicleType"); // dt.Columns.Add("License"); // dt.Columns.Add("Brand"); // for (int i = 0; i < list.Count; i++) // { // object[] tmp = (object[])list[i]; // object[] o = new object[] { tmp[0], tmp[2], tmp[3], tmp[5], tmp[6], tmp[7], tmp[8], tmp[9] }; // dt.Rows.Add(o); // } //} this.dataGridView.DataSource = VehicleDao.GetFirst20Row().Tables[0]; }
/// <summary> /// 点击复制按钮时,取得最新流水号,并置控件为可编辑状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void copyBtn_Click(object sender, EventArgs e) { this.serial.Text = VehicleDao.GetLatestSerial(); this.setControlReadOnly(false); this.originPic.Image = global::VTMS.Properties.Resources.NoneImage; this.currentPic.Image = global::VTMS.Properties.Resources.NoneImage; 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; vehicle = new Vehicle(); vehicle.Vehicletype = new Vehicletype(); vehicle.Company = new Company(); this.invoice.Focus(); this.isUpdate = false; }
public VehicleBo() : base() { _dao = new VehicleDao(); }
/// <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(); } }
public WindownApplication() { ViewerID = getString("Viewer_ID", ""); webClientManager = WebClientManager.getInstance(); ObjCacheManager = new ObjCacheManager(this); elasticSearchManager = new ElasticSearchManager(); RailDao = new RAILDao(); AddressDao = new ADDRESSDao(); PortIconDao = new PortIconDao(); PointDao = new POINTDao(); GroupRailDao = new GROUPRAILSDao(); SegmentDao = new SegmentDao(); SectionDao = new SectionDao(); PortDao = new PortDao(); VehicleDao = new VehicleDao(); UserDao = new UserDao(); UserGroupDao = new UserGroupDao(); UserFuncDao = new UserFuncDao(); FunctionCodeDao = new FunctionCodeDao(); CMD_OHTCDao = new CMD_OHTCDao(); CMD_MCSDao = new CMD_MCSDao(); VCMD_MCSDao = new VCMD_MCSDao(); PortStationDao = new PortStationDao(); AlarmDao = new AlarmDao(); MapBLL = new MapBLL(this); UserBLL = new UserBLL(this); OperationHistoryBLL = new OperationHistoryBLL(this); CmdBLL = new CmdBLL(this); AlarmBLL = new AlarmBLL(this); PortStationBLL = new PortStationBLL(this); SegmentBLL = new SegmentBLL(this); ObjCacheManager.start(); ID = ObjCacheManager.MapId; LineBLL = new LineBLL(this); VehicleBLL = new VehicleBLL(this); SysExcuteQualityBLL = new SysExcuteQualityBLL(this); dBTableWatcher = new EventAction.DBTableWatcher(this); dBTableWatcher.initStart(); // setEFConnectionString(ObjCacheManager.EFConnectionString); SysExcuteQualityQueryService = new SysExcuteQualityQueryService(this); //initBackgroundWork(); // SysExcuteQualityQueryService = new SysExcuteQualityQueryService(); switch (WindownApplication.OHxCFormMode) { case OHxCFormMode.CurrentPlayer: natsManager = new NatsManager(ID, "nats-cluster", ViewerID); redisCacheManager = new RedisCacheManager(ID); SubscriberNatsEvent(); SubscriberDBTableWatcherEvent(); //SysExcuteQualityQueryService.start(); break; case OHxCFormMode.HistoricalPlayer: HistoricalReplyService = new HistoricalReplyService(this); //HistoricalReplyService.loadVhHistoricalInfo(); break; } //VehicleBLL.ReguestViewerUpdate(); }
/// <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(); }
public VehicleBLL(WindownApplication _app) { app = _app; cache = new Cache(app.ObjCacheManager); vehicleDAO = app.VehicleDao; }