/// <summary> /// Get information from UI /// </summary> /// <returns></returns> private tblDeclaration GetDeclarationInfo(ref tblDeclaration declarationInfo) { declarationInfo.NumberHandover = !string.IsNullOrEmpty(txtNumberHandover.Text) ? Convert.ToInt32(txtNumberHandover.Text.Trim()) : 0; declarationInfo.DateHandover = dtpHandover.Value; declarationInfo.PersonHandoverID = _userInfo.UserID; //declarationInfo.DateReturn = dtpReturn.Value; declarationInfo.TypeOption = (short)_declerationOptionType; declarationInfo.CustomsCode = txtCustomsCode.Text.Trim(); if (_declerationOptionType == Common.DeclerationOptionType.TNTX) { declarationInfo.NumberTemp = !string.IsNullOrEmpty(txtNumberTemp.Text) ? txtNumberTemp.Text.Trim() : ""; declarationInfo.Seal = txtSeal.Text.Trim(); } if (_declerationOptionType == Common.DeclerationOptionType.TNTX || _declerationOptionType == Common.DeclerationOptionType.XKCK) { declarationInfo.GateExport = txtExportGateCode.Text.Trim(); } if (_declerationOptionType == Common.DeclerationOptionType.NKCK) { declarationInfo.GateImport = txtImportGateCode.Text.Trim(); } return declarationInfo; }
public frmDeclarationLoanDetail(long declarationID, tblDeclaration declaration) { InitializeComponent(); _declarationID = declarationID; _declaration = declaration; }
public FrmDeclarationFilesGetLoan(UserInfo userInfo, frmDeclarationFilesManagement frmParent, long declarationID, tblDeclaration declration) { InitializeComponent(); _userInfo = userInfo; _frmParent = frmParent; _declarationID = declarationID; _declration = declration; }
/// <summary> /// update declaration /// </summary> /// <param name="declaration"></param> /// <param name="modifiedByID"></param> /// <returns></returns> public static int Update(tblDeclaration declaration) { var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); declaration.ModifiedDate = DateTime.Now; // Get orgin object var objOrginDeclaration = db.tblDeclarations.Where(g => g.DeclarationID.Equals(declaration.DeclarationID)).FirstOrDefault(); db.Attach(objOrginDeclaration); db.ApplyPropertyChanges("tblDeclarations", declaration); return db.SaveChanges(); }
public frmVehicle(int mode, Form mainFrom, ref List<ViewAllVehicleHasGood> vehicleInfosTemp, int count, tblDeclaration parrentDeclaration, UserInfo userInfo, Common.DeclerationType type) { InitializeComponent(); grdVehicle.AutoGenerateColumns = false; _mode = mode; _mainForm = mainFrom; _vehicleInfosTemp = vehicleInfosTemp; _count = count; _parrentDeclaration = parrentDeclaration; _userInfo = userInfo; _type = type; }
//private void InitialPermission() //{ // //throw new NotImplementedException(); // if (_userInfo.Type == UserType.Admin) // { // } // else if (_userInfo.Type == UserType.Confirm) // { // btnDelete.Enabled = false; // } // else if (_userInfo.Type == UserType.Input) // { // btnConfirmExport.Visible = false; // btnConfirmImport.Visible = false; // btnSearch.Visible = false; // btnDelete.Enabled = false; // } //} public frmVehicle(int mode, Form mainForm, ref List<ViewAllVehicleHasGood> vehicleInfosTemp, tblDeclaration declarationInfo, UserInfo userInfo) { InitializeComponent(); grdVehicle.AutoGenerateColumns = false; _mode = mode; _mainForm = mainForm; _vehicleInfosTemp = vehicleInfosTemp; _parrentDeclaration = declarationInfo; _userInfo = userInfo; //InitialPermission(); }
public frmVehicle(int mode, frmExport parrent, ref List<VehicleInfo> vehicleInfosTemp, int count, tblDeclaration parrentDeclaration, UserInfo userInfo) { InitializeComponent(); grdVehicle.AutoGenerateColumns = false; _mode = mode; _parrent = parrent; _vehicleInfosTemp = vehicleInfosTemp; _count = count; _parrentDeclaration = parrentDeclaration; _userInfo = userInfo; //InitialPermission(); }
public frmPageNumber(frmDeclarationManagement frmParent,UserInfo userInfo, long declarationId, bool isSecondHandover = false) { this.Text = "Ban giao ho so" + ConstantInfo.MESSAGE_TITLE + GlobalInfo.CompanyName; declaration = DeclarationFactory.GetByID(declarationId); _isSecondHandover = isSecondHandover; _userInfo = userInfo; _frmParent = frmParent; InitializeComponent(); if (_isSecondHandover) { txtPageNumber.ReadOnly = _isSecondHandover; txtPageNumber.Text = declaration.PageNumbers.Value.ToString(); } }
private void btnAddVehicle_Click(object sender, EventArgs e) { try { var declarationInfo = new tblDeclaration(); if (!string.IsNullOrEmpty(txtExportNumber.Text)) { declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text); } declarationInfo.CreatedDate = CommonFactory.GetCurrentDate(); declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.ProductAmount = txtProductAmount.Text; // Add Mode if (_mode == 0) { var vehicle = new frmVehicle(0, _mainForm, ref _vehicleInfosTemp, declarationInfo, _userInfo); vehicle.Show(this); } else { declarationInfo = DeclarationFactory.GetByID(_declerationID); if (!string.IsNullOrEmpty(txtExportNumber.Text)) { declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text); } declarationInfo.CreatedDate = CommonFactory.GetCurrentDate(); declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.ProductAmount = txtProductAmount.Text; // Update Mode var vehicle = new frmVehicle(4, _mainForm, ref _vehicleInfosTemp, declarationInfo, _userInfo); vehicle.Show(this); } } catch (Exception ex) { logger.Error(ex.ToString()); if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString()); } }
/// <summary> /// Insert to Declaration and list vehicle /// </summary> /// <param name="declarationInfo"></param> /// <param name="vehicleInfos"></param> public int AddDeclaration(tblDeclaration declarationInfo, List<tblVehicle> vehicleInfos, int userID) { var result = -1; var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); declarationInfo.tblUser = db.tblUsers.Where(g => g.UserID.Equals(userID)).FirstOrDefault(); // Set Created date and Last modified date declarationInfo.CreatedDate = DateTime.Now; declarationInfo.ModifiedDate = DateTime.Now; db.AddTotblDeclarations(declarationInfo); db.SaveChanges(); // Return if insert fail if(declarationInfo.DeclarationID <= 0) return - 1; var declarationID = declarationInfo.DeclarationID; // Add vehicle foreach (var vehicle in vehicleInfos) { vehicle.tblDeclaration = declarationInfo; db.AddTotblVehicles(vehicle); db.SaveChanges(); } return result; }
private void btnUpdateVehicle_Click(object sender, EventArgs e) { try { var declarationInfo = new tblDeclaration(); if (!string.IsNullOrEmpty(txtExportNumber.Text)) { declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text); } declarationInfo.CreatedDate = DateTime.Now; declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.ProductAmount = txtExportProductAmount.Text; declarationInfo.HasDeclaration = cbExportHasDeclaration.Checked; // New mode if (grdVehicle.SelectedRows.Count == 1 && this._mode == 0) { var vehicle = new frmVehicle(1, this, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.SelectedRows[0].Cells["Count"].Value), declarationInfo, _userInfo); vehicle.MdiParent = this.ParentForm; vehicle.Show(); } else if (grdVehicle.SelectedRows.Count == 1 && this._mode == 1) // Update Mode { var vehicle = new frmVehicle(2, this, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.SelectedRows[0].Cells["Count"].Value), declarationInfo, _userInfo); vehicle.MdiParent = this.ParentForm; vehicle.Show(); } else { MessageBox.Show("Bạn cần chọn 1 phương tiện cần cập nhật."); } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }
private void btnAddVehicle_Click(object sender, EventArgs e) { try { var declarationInfo = new tblDeclaration(); if (!string.IsNullOrEmpty(txtExportNumber.Text)) { declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text); } declarationInfo.CreatedDate = DateTime.Now; declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.ProductAmount = txtExportProductAmount.Text; declarationInfo.HasDeclaration = cbExportHasDeclaration.Checked; // Add Mode if (_mode == 0) { var vehicle = new frmVehicle(0, this, ref _vehicleInfosTemp, declarationInfo, _userInfo); vehicle.MdiParent = this.ParentForm; vehicle.Show(); } else { declarationInfo = DeclarationFactory.SelectByID(_declerationID); if (!string.IsNullOrEmpty(txtExportNumber.Text)) { declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text); } declarationInfo.CreatedDate = DateTime.Now; declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.ProductAmount = txtExportProductAmount.Text; declarationInfo.HasDeclaration = cbExportHasDeclaration.Checked; // Update Mode var vehicle = new frmVehicle(4, this, ref _vehicleInfosTemp, declarationInfo, _userInfo); vehicle.MdiParent = this.ParentForm; vehicle.Show(); } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }
/// <summary> /// Get information from UI /// </summary> /// <returns></returns> private tblDeclaration GetDeclarationInfo(ref tblDeclaration declarationInfo) { declarationInfo.DeclarationType = (short)_declerationType; declarationInfo.Number = !string.IsNullOrEmpty(txtExportNumber.Text) ? Convert.ToInt32(txtExportNumber.Text.Trim()) : 0; declarationInfo.Type = txtTypeExport.Text.Trim(); declarationInfo.CompanyName = txtExportCompanyName.Text; declarationInfo.CompanyCode = txtExportCompanyCode.Text; declarationInfo.CustomsCode = txtCustomsCode.Text.Trim(); declarationInfo.RegisterDate = dtpExportRegisterDate.Value; declarationInfo.ProductAmount = txtProductAmount.Text.Trim(); declarationInfo.Unit = txtExportUnit.Text.Trim(); declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.ModifiedByID = _userInfo.UserID; //declarationInfo.ModifiedDate = CommonFactory.GetCurrentDate(); //declarationInfo.CreatedDate = CommonFactory.GetCurrentDate(); declarationInfo.Money = !string.IsNullOrEmpty(txtMoney.Text) ? Convert.ToInt32(txtMoney.Text.Trim()) : 0; declarationInfo.TypeOption = short.Parse(((ComboBoxItem)cbTNTX.SelectedItem).Value); if (cbTNTX.SelectedIndex > 0 && pnTXTN.Visible) { if (!string.IsNullOrEmpty(txtNumberHandover.Text.Trim())) { declarationInfo.NumberHandover = int.Parse(txtNumberHandover.Text.Trim()); } declarationInfo.DateHandover = dtpHandover.Value; declarationInfo.PersonHandoverID = _userInfo.UserID; } if (!string.IsNullOrEmpty(txtNumberTemp.Text.Trim())) { declarationInfo.NumberTemp = txtNumberTemp.Text.Trim(); declarationInfo.NumberTempInfo = txtNumberTempInfo.Text.Trim(); } return declarationInfo; }
//private void btnReset_Click(object sender, EventArgs e) //{ // try // { // txtExportNumber.Text = ""; // txtExportProductName.Text = ""; // txtExportCompanyName.Text = ""; // txtExportProductAmount.Text = ""; // txtExportUnit.Text = ""; // txtTypeExport.Text = ""; // txtExportCompanyCode.Text = ""; // txtExportCompanyCode.Text = ""; // dtpExportRegisterDate.Value = DateTime.Now; // grdVehicle.Rows.Clear(); // } // catch (Exception ex) // { // logger.Error(ex.ToString()); // if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString()); // } //} private void btnUpdateVehicle_Click(object sender, EventArgs e) { try { var declarationInfo = new tblDeclaration(); if (!string.IsNullOrEmpty(txtExportNumber.Text)) { declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text); } declarationInfo.CreatedDate = CommonFactory.GetCurrentDate(); declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.ProductAmount = txtProductAmount.Text; // New mode if (grdVehicle.SelectedRows.Count == 1 && this._mode == 0) { var vehicle = new frmVehicle(1, _mainForm, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.SelectedRows[0].Cells["Count"].Value), declarationInfo, _userInfo, _declerationType); vehicle.Show(this); } else if (grdVehicle.SelectedRows.Count == 1 && this._mode == 1) // Update Mode { var vehicle = new frmVehicle(2, _mainForm, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.SelectedRows[0].Cells["Count"].Value), declarationInfo, _userInfo, _declerationType); vehicle.Show(this); } else { MessageBox.Show("Bạn cần chọn 1 phương tiện cần cập nhật."); } } catch (Exception ex) { logger.Error(ex.ToString()); if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString()); } }
private void btnAdd_Click(object sender, EventArgs e) { try { if (!Validate()) return; var declaratioInfo = new tblDeclaration(); var declarationInfo = GetDeclarationInfo(ref declaratioInfo); var listVehicleInfo = new List<tblVehicle>(); var listVehicleUpdate = new List<tblVehicle>(); tblVehicle vehicleInfo; // Validate Vehicle information if (grdVehicle.Rows.Count > 0) { List<tblVehicleFeeSetting> listFee = null; if (_statusFee == 1) { listFee = VehicleFeeSettingFactory.getAllVehicleFeeSetting(); } for (int i = 0; i < grdVehicle.Rows.Count; i++) { if (grdVehicle.Rows[i].Cells["VehicleID"].Value != null && Convert.ToInt64(grdVehicle.Rows[i].Cells["VehicleID"].Value) > 0) // Update this vehicle only. { // Get vehcleInfor from database vehicleInfo = VehicleFactory.GetByID(Convert.ToInt64(grdVehicle.Rows[i].Cells["VehicleID"].Value)); } else { vehicleInfo = new tblVehicle(); } // Do not save the record that platNumber is empty if (grdVehicle.Rows[i].Cells["PlateNumber"].Value != null && grdVehicle.Rows[i].Cells["PlateNumber"].Value != "") { vehicleInfo.PlateNumber = grdVehicle.Rows[i].Cells["PlateNumber"].Value.ToString(); } else // Don't insert the record that the platnumber is null { continue; } if (grdVehicle.Rows[i].Cells["NumberOfContainer"].Value != null) vehicleInfo.NumberOfContainer = grdVehicle.Rows[i].Cells["NumberOfContainer"].Value.ToString(); if (grdVehicle.Rows[i].Cells["VehicleType"].Value != null) { vehicleInfo.vehicleTypeId = Int32.Parse(grdVehicle.Rows[i].Cells["VehicleType"].Value.ToString()); } if (grdVehicle.Rows[i].Cells["ExportGoodType"].Value != null) { vehicleInfo.ExportGoodTypeId = Int32.Parse(grdVehicle.Rows[i].Cells["ExportGoodType"].Value.ToString()); } if (grdVehicle.Rows[i].Cells["ImportGoodType"].Value != null) { vehicleInfo.ImportGoodTypeId = Int32.Parse(grdVehicle.Rows[i].Cells["ImportGoodType"].Value.ToString()); } if (grdVehicle.Rows[i].Cells["DriverName"].Value != null) vehicleInfo.DriverName = grdVehicle.Rows[i].Cells["DriverName"].Value.ToString(); if (grdVehicle.Rows[i].Cells["IsExport"].Value != null) vehicleInfo.IsExport = Convert.ToBoolean(grdVehicle.Rows[i].Cells["IsExport"].Value); // Set Export Date if (vehicleInfo.IsExport != null && vehicleInfo.IsExport.Value && grdVehicle.Rows[i].Cells["ExportDate"].Value != null) { vehicleInfo.ExportDate = Convert.ToDateTime(grdVehicle.Rows[i].Cells["ExportDate"].Value); } if (grdVehicle.Rows[i].Cells["IsImport"].Value != null) vehicleInfo.IsImport = Convert.ToBoolean(grdVehicle.Rows[i].Cells["IsImport"].Value); // Set Import Date if (vehicleInfo.IsImport != null && vehicleInfo.IsImport.Value && grdVehicle.Rows[i].Cells["ImportDate"].Value != null) { vehicleInfo.ImportDate = Convert.ToDateTime(grdVehicle.Rows[i].Cells["ImportDate"].Value); if (grdVehicle.Rows[i].Cells["ImportStatus"].Value != null) vehicleInfo.ImportStatus = grdVehicle.Rows[i].Cells["ImportStatus"].Value.ToString(); if (grdVehicle.Rows[i].Cells["HasGoodsImported"].Value != null) vehicleInfo.HasGoodsImported = bool.Parse(grdVehicle.Rows[i].Cells["HasGoodsImported"].Value.ToString()); } if (grdVehicle.Rows[i].Cells["Note"].Value != null) vehicleInfo.Note = grdVehicle.Rows[i].Cells["Note"].Value.ToString(); if (grdVehicle.Rows[i].Cells["Status"].Value != null) vehicleInfo.Status = grdVehicle.Rows[i].Cells["Status"].Value.ToString(); //Set Fee if (_statusFee == 1) { var currentDate = CommonFactory.GetCurrentDate(); if (_declerationType.Equals(Common.DeclerationType.Export)) { vehicleInfo.ExportReceiptNumber = "9999"; var feeSetting = listFee.Where(f =>f.VehicleTypeId == vehicleInfo.vehicleTypeId && f.GoodsTypeId == vehicleInfo.ExportGoodTypeId).FirstOrDefault(); var amount = feeSetting != null ? (feeSetting.Fee ?? 0) : 0; vehicleInfo.feeExportAmount = amount; vehicleInfo.feeExportDate = currentDate; vehicleInfo.feeExportStatus = (int)FeeStatus.PaidFee; vehicleInfo.confirmFeeExportBy = _userInfo.UserID; } else { vehicleInfo.ImportReceiptNumber = "9999"; var feeSetting = listFee.Where(f => f.VehicleTypeId == vehicleInfo.vehicleTypeId && f.GoodsTypeId == vehicleInfo.ImportGoodTypeId).FirstOrDefault(); var amount = feeSetting != null ? (feeSetting.Fee ?? 0) : 0; vehicleInfo.feeImportAmount = amount; vehicleInfo.feeImportDate = currentDate; vehicleInfo.feeImportStatus = (int)FeeStatus.PaidFee; vehicleInfo.confirmFeeImportBy = _userInfo.UserID; } } else { var currentDate = CommonFactory.GetCurrentDate(); if (_declerationType.Equals(Common.DeclerationType.Export)) { if ((grdVehicle.Rows[i].Cells["ExportReceiptNumber"].Value == null) || string.IsNullOrEmpty(grdVehicle.Rows[i].Cells["ExportReceiptNumber"].Value.ToString().Trim()) || (grdVehicle.Rows[i].Cells["feeExportAmount"].Value == null)) { if (vehicleInfo.feeExportStatus == (int)FeeStatus.PaidFee) { vehicleInfo.ExportReceiptNumber = null; vehicleInfo.feeExportAmount = null; vehicleInfo.feeExportDate = null; vehicleInfo.feeExportStatus = (int)FeeStatus.HasNotPayFee; vehicleInfo.confirmFeeExportBy = _userInfo.UserID; } } else { vehicleInfo.ExportReceiptNumber = grdVehicle.Rows[i].Cells["ExportReceiptNumber"].Value.ToString().Trim(); vehicleInfo.feeExportAmount = Convert.ToInt64(grdVehicle.Rows[i].Cells["feeExportAmount"].Value); vehicleInfo.feeExportDate = currentDate; vehicleInfo.feeExportStatus = (int)FeeStatus.PaidFee; vehicleInfo.confirmFeeExportBy = _userInfo.UserID; } } else { if ((grdVehicle.Rows[i].Cells["ImportReceiptNumber"].Value == null) || string.IsNullOrEmpty(grdVehicle.Rows[i].Cells["ImportReceiptNumber"].Value.ToString().Trim()) || (grdVehicle.Rows[i].Cells["feeImportAmount"].Value == null)) { if (vehicleInfo.feeImportStatus == (int)FeeStatus.PaidFee) { vehicleInfo.ImportReceiptNumber = null; vehicleInfo.feeImportAmount = null; vehicleInfo.feeImportDate = null; vehicleInfo.feeImportStatus = (int)FeeStatus.HasNotPayFee; vehicleInfo.confirmFeeExportBy = _userInfo.UserID; } } else { vehicleInfo.ImportReceiptNumber = grdVehicle.Rows[i].Cells["ImportReceiptNumber"].Value.ToString().Trim(); vehicleInfo.feeImportAmount = Convert.ToInt64(grdVehicle.Rows[i].Cells["feeImportAmount"].Value); vehicleInfo.feeImportDate = currentDate; vehicleInfo.feeImportStatus = (int)FeeStatus.PaidFee; vehicleInfo.confirmFeeImportBy = _userInfo.UserID; } } } var vehicleRow = (ViewAllVehicleHasGood) grdVehicle.Rows[i].DataBoundItem; if (vehicleRow.StatusChangeGood != null) { vehicleInfo.StatusChangeGood = vehicleRow.StatusChangeGood; vehicleInfo.ListVehicleChangeGood = vehicleRow.ListVehicleChangeGood ?? VehicleFactory.GetListVehicleChangeById(vehicleRow.VehicleID); } if (grdVehicle.Rows[i].Cells["VehicleID"].Value != null && Convert.ToInt64(grdVehicle.Rows[i].Cells["VehicleID"].Value) > 0) // Update this vehicle only. { listVehicleUpdate.Add(vehicleInfo); continue; } // If this vehicle is set import/export, set the confirmImport by /confirmExpor by if (vehicleInfo.IsExport != null && vehicleInfo.IsExport.Value) { vehicleInfo.ConfirmExportBy = _userInfo.UserID; } if (vehicleInfo.IsImport != null && vehicleInfo.IsImport.Value) { vehicleInfo.ConfirmImportBy = _userInfo.UserID; } // Add to list vehicles listVehicleInfo.Add(vehicleInfo); } // End for } //cap nhat So tiep nhap tai khai Xuat chuyen khai trong nam //cap nhat khi la xuat khau chuyen cua khau if (declarationInfo.DeclarationType == (short)Common.DeclerationType.Export && declarationInfo.TypeOption==1) { long receiveNumber = ApplicationObjectFactory.updateTotalReceiveNumber(); declarationInfo.ReceiveNumberInYear = receiveNumber; } // TODO: Need to check return value DeclarationFactory.AddDeclaration(declarationInfo, listVehicleInfo, listVehicleUpdate, _userInfo.UserID); //MessageBox.Show(ConstantInfo.MESSAGE_INSERT_SUCESSFULLY); if (declarationInfo.DeclarationType == (short)Common.DeclerationType.Export && declarationInfo.TypeOption == 1) { FrmReceiveNumber frmReceiveNumber = new FrmReceiveNumber(declarationInfo.ReceiveNumberInYear.GetValueOrDefault()); frmReceiveNumber.MdiParent = this.MdiParent; frmReceiveNumber.Show(this); } switch (this.Owner.Name.ToUpper()) { case "FRMDECLERATION": { // Bind data to the gridivew ((frmDecleration)Owner).BindData(); // close the form //this.Close(); } break; case "FRMMAINFORM": { // Just close from if this form is opened from main from //this.Close(); } break; default: break; } // Reset form ResetForm(); } catch (Exception ex) { logger.Error(ex.ToString()); if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString()); } }
private void grdVehicle_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (_userInfo.UserPermission.Contains(ConstantInfo.PERMISSON_CAP_NHAT_PHUONG_TIEN)) { try { if (e.RowIndex >= 0 && grdVehicle.SelectedRows.Count == 1) { var declarationInfo = new tblDeclaration(); if (!string.IsNullOrEmpty(txtExportNumber.Text)) { declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text); } declarationInfo.CreatedDate = CommonFactory.GetCurrentDate(); declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.ProductAmount = txtProductAmount.Text; // Bind the gridview data to the vehicleInfo object, make sure, the vehicleInfotem dat is same as the gridview. // Validate data of the gridview. // Clear the tem data //_vehicleInfosTemp.Clear(); _vehicleInfosTemp = (List<ViewAllVehicleHasGood>)grdVehicle.DataSource; // New mode if (this._mode == 0) { var vehicle = new frmVehicle(1, _mainForm, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["Count"].Value), declarationInfo, _userInfo, _declerationType); vehicle.Show(this); } else if (this._mode == 1) // Update Mode { var vehicle = new frmVehicle(2, _mainForm, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["Count"].Value), declarationInfo, _userInfo, _declerationType); vehicle.Show(this); } } } catch (Exception ex) { logger.Error(ex.ToString()); if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString()); } } }
/// <summary> /// Get Declaration from Controls /// </summary> /// <returns></returns> private tblDeclaration GetDeclarationInfo() { var declarationInfo = new DAL.tblDeclaration(); if (!string.IsNullOrEmpty(txtExportNumber.Text)) { declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text.Trim()); } declarationInfo.ExportType = txtTypeExport.Text.Trim(); declarationInfo.CompanyName = txtExportCompanyName.Text; declarationInfo.CompanyCode = txtExportCompanyCode.Text; declarationInfo.RegisterDate = dtpExportRegisterDate.Value; declarationInfo.ProductAmount = txtExportProductAmount.Text.Trim(); declarationInfo.Unit = txtExportUnit.Text.Trim(); declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.HasDeclaration = cbExportHasDeclaration.Checked; // import if (!string.IsNullOrEmpty(txtImportNumber.Text.Trim())) { declarationInfo.ImportNumber = Convert.ToInt32(txtImportNumber.Text.Trim()); } declarationInfo.ImportType = txtTypeImport.Text.Trim(); declarationInfo.ImportCompanyName = txtImportCompanyName.Text; declarationInfo.ImportCompanyCode = txtImportCompanyCode.Text; declarationInfo.ImportRegisterDate = dtpImportRegisterDate.Value; declarationInfo.ImportProductAmount = txtImportProductAmount.Text.Trim(); declarationInfo.ImportUnit = txtImportUnit.Text.Trim(); declarationInfo.ImportProductName = txtImportProductName.Text; declarationInfo.ImportHasDeclaration = cbImportHasDeclaration.Checked; declarationInfo.ModifiedDate = DateTime.Now; declarationInfo.ModifiedByID = _userInfo.UserID; return declarationInfo; }
/// <summary> /// Insert to Declaration and list vehicle /// </summary> /// <param name="declarationInfo"></param> /// <param name="vehicleInfos"></param> /// <param name="listVehicleUpdate"></param> /// <param name="userID"></param> public static int AddDeclaration(tblDeclaration declarationInfo, List<tblVehicle> vehicleInfos, List<tblVehicle> listVehicleUpdate, int userID) { var result = -1; var currentDate = CommonFactory.GetCurrentDate(); var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); //--------------Luu vào bảng tờ khai ---------------- //declarationInfo.tblUser = db.tblUsers.Where(g => g.UserID.Equals(userID)).FirstOrDefault(); // Set Created date and Last modified date declarationInfo.CreatedDate = currentDate; declarationInfo.ModifiedDate = currentDate; declarationInfo.CreatedByID = userID; db.AddTotblDeclarations(declarationInfo); db.SaveChanges(); // Return if insert fail if (declarationInfo.DeclarationID <= 0) return -1; // -------- Trong trường hợp đây là tạo mới, thì add vehicle --------------- // Add vehicle foreach (var vehicle in vehicleInfos) { // Update movidifedDate and Created date vehicle.CreatedDate = currentDate; vehicle.ModifiedDate = currentDate; db.AddTotblVehicles(vehicle); db.SaveChanges(); //insert to the tblVehicleChange List<long> listVehicleId = new List<long>(); if (vehicle.ListVehicleChangeGood != null) { listVehicleId= vehicle.ListVehicleChangeGood.Select(x => x.VehicleId).ToList(); } VehicleFactory.AddVehicleChangeByVehicleId(vehicle.VehicleID, listVehicleId); // Insert to the tblVehicleDeclerateion var vehicleDeclara = new tblDeclarationVehicle(); vehicleDeclara.VehicleID = vehicle.VehicleID; vehicleDeclara.DeclarationID = declarationInfo.DeclarationID; db.AddTotblDeclarationVehicles(vehicleDeclara); db.SaveChanges(); // Add data to tblDecleVehicle } // -------- Trong trường hợp đây là cập nhật, thì add vehicle --------------- // Update the vehicle if (listVehicleUpdate.Count > 0) { foreach (var vehicle in listVehicleUpdate) { // Update Vehicle info VehicleFactory.UpdateVehicle(vehicle, 0); // Add to tblDeclerateVehcle var declerartionTem = db.tblDeclarations.Where(g => g.DeclarationID == declarationInfo.DeclarationID).FirstOrDefault(); var vehicleDeclara = new tblDeclarationVehicle(); vehicleDeclara.VehicleID = vehicle.VehicleID; vehicleDeclara.DeclarationID = declerartionTem.DeclarationID; db.AddTotblDeclarationVehicles(vehicleDeclara); db.SaveChanges(); } } db.Connection.Close(); return result; }
private void grdVehicle_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { try { if (e.RowIndex >= 0 && grdVehicle.SelectedRows.Count == 1) { var declarationInfo = new tblDeclaration(); if (!string.IsNullOrEmpty(txtExportNumber.Text)) { declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text); } declarationInfo.CreatedDate = DateTime.Now; declarationInfo.ProductName = txtExportProductName.Text; declarationInfo.ProductAmount = txtExportProductAmount.Text; declarationInfo.HasDeclaration = cbExportHasDeclaration.Checked; // Bind the gridview data to the vehicleInfo object, make sure, the vehicleInfotem dat is same as the gridview. // Validate data of the gridview. // Clear the tem data //_vehicleInfosTemp.Clear(); _vehicleInfosTemp = (List<VehicleInfo>)grdVehicle.DataSource; //VehicleInfo vehicleInfo; //// Add data to the tem object //for (int i = 0; i < grdVehicle.Rows.Count; i++) //{ // var row = grdVehicle.Rows[i]; // vehicleInfo = new VehicleInfo(); // if (row.Cells[ConstantInfo.TBL_VEHICLE_PLATE_NUMBER].Value != null) // { // vehicleInfo.PlateNumber = row.Cells[ConstantInfo.TBL_VEHICLE_PLATE_NUMBER].Value.ToString(); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_DRIVER_NAME].Value != null) // { // vehicleInfo.DriverName = row.Cells[ConstantInfo.TBL_VEHICLE_DRIVER_NAME].Value.ToString(); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_STATUS].Value != null) // { // vehicleInfo.Status = row.Cells[ConstantInfo.TBL_VEHICLE_STATUS].Value.ToString(); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_NOTE].Value != null) // { // vehicleInfo.Note = row.Cells[ConstantInfo.TBL_VEHICLE_NOTE].Value.ToString(); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_EXPORT_HOUR].Value != null) // { // vehicleInfo.ExportHour = row.Cells[ConstantInfo.TBL_VEHICLE_EXPORT_HOUR].Value.ToString(); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_IS_EXPORT].Value != null) // vehicleInfo.IsExport = Convert.ToBoolean(row.Cells[ConstantInfo.TBL_VEHICLE_IS_EXPORT].Value.ToString());{ // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_EXPORT_DATE].Value != null) // { // vehicleInfo.ExportDate = // Convert.ToDateTime(row.Cells[ConstantInfo.TBL_VEHICLE_EXPORT_DATE].Value.ToString()); // } // if ((row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_DATE].Value != null)) // { // vehicleInfo.ImportDate = Convert.ToDateTime(row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_DATE].Value.ToString()); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_HOUR].Value != null) // { // vehicleInfo.ImportHour = row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_HOUR].Value.ToString(); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_IS_IMPORT].Value != null) // { // vehicleInfo.IsImport = Convert.ToBoolean(row.Cells[ConstantInfo.TBL_VEHICLE_IS_IMPORT].Value.ToString()); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_VEHICLE_ID].Value != null) // { // vehicleInfo.VehicleID = Convert.ToInt32(row.Cells[ConstantInfo.TBL_VEHICLE_VEHICLE_ID].Value.ToString()); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_NUMBER_OF_CONTAINER].Value != null) // { // vehicleInfo.NumberOfContainer = Convert.ToInt32(row.Cells[ConstantInfo.TBL_VEHICLE_NUMBER_OF_CONTAINER].Value.ToString()); // } // if (row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_HOUR].Value != null ) // { // vehicleInfo.ImportHour = row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_HOUR].Value.ToString(); // } // // If it is new mode, use Count as the flash, it store item count // if (this._mode == 0) // { // if (row.Cells["Count"].Value != null) // { // vehicleInfo.Count = Convert.ToInt32(row.Cells["Count"].Value); // } // } // _vehicleInfosTemp.Add(vehicleInfo); //} // New mode if (this._mode == 0) { var vehicle = new frmVehicle(1, this, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["Count"].Value), declarationInfo, _userInfo); vehicle.MdiParent = this.ParentForm; vehicle.Show(); } else if (this._mode == 1) // Update Mode { var vehicle = new frmVehicle(2, this, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["Count"].Value), declarationInfo, _userInfo); vehicle.MdiParent = this.ParentForm; vehicle.Show(); } } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }
private tblDeclaration GetDeclarationInfo() { var declarationInfo = new tblDeclaration(); declarationInfo.Number = 0; declarationInfo.ImportNumber = 0; declarationInfo.ExportType = ""; declarationInfo.CompanyName = ""; declarationInfo.CompanyCode = ""; declarationInfo.RegisterDate = DateTime.Now; declarationInfo.ProductAmount = ""; declarationInfo.Unit = ""; declarationInfo.ProductName = ""; //declarationInfo.HasDeclaration = Name declarationInfo.ImportType = ""; declarationInfo.ImportCompanyName = ""; declarationInfo.ImportCompanyCode = ""; declarationInfo.ImportRegisterDate = DateTime.Now; declarationInfo.ImportProductAmount = ""; declarationInfo.ImportUnit = ""; declarationInfo.ImportProductName = ""; //declarationInfo.ImportHasDeclaration = cbImportHasDeclaration.Checked; declarationInfo.ModifiedDate = DateTime.Now; declarationInfo.ModifiedByID = _userInfo.UserID; return declarationInfo; }