private bool ValidateInputDataConfirmArrived() { isConfirmed = false; if (String.IsNullOrWhiteSpace(cbbMasterBill.Text) || String.IsNullOrWhiteSpace(cbbBoxId.Text)) { MessageBox.Show("Bạn cần phải nhập Master airway bill (MAWB) và Mã thùng trước", "Thông báo", MessageBoxButtons.OK); cbbMasterBill.Focus(); return(false); } if (!CheckIsBoxIdExistsInManifest(cbbBoxId.Text)) { MessageBox.Show("Không tồn tại dữ liệu.", "Thông báo", MessageBoxButtons.OK); cbbBoxId.Focus(); return(false); } BoxInforEntity box = _boxInforServices.GetByBoxId(cbbBoxId.Text); if (box == null) { listManifest = _repositoryShipment.GetManifestByBoxId(cbbBoxId.Text.Trim()); listManifest = listManifest.GroupBy(t => t.ShipmentNo).Select(p => p.First()).ToList(); var result = MessageBox.Show("Tổng số đơn hàng: " + listManifest.Count + "\nBạn có muốn xác nhận không?", cbbBoxId.Text, MessageBoxButtons.YesNo); return(result == DialogResult.Yes); } else { lstShipmentInfor = (List <ShipmentEntity>)_shipmentServices.GetByBoxId(box.Id); var result = MessageBox.Show("Tổng số đơn hàng: " + lstShipmentInfor.Count + "\nBạn có muốn mở không?", cbbBoxId.Text, MessageBoxButtons.YesNo); return(result == DialogResult.Yes); } }
public int CreateBoxInfor(BoxInforEntity boxInfor) { using (var scope = new TransactionScope()) { Mapper.CreateMap <BoxInforEntity, BoxInfo>(); var boxInforService = Mapper.Map <BoxInforEntity, BoxInfo>(boxInfor); _unitOfWork.BoxInforRepository.Insert(boxInforService); _unitOfWork.SaveWinform(); scope.Complete(); return(boxInforService.Id); } }
private void SaveShipment(string masterBill) { int countTotal = 0; List <BoxIdEntity> listBoxid = repositoryShipment.GetBoxIdByAirwaybill(masterBill); if (listBoxid.Count > 0) { foreach (var box in listBoxid) { int countBox = 0; BoxInforEntity boxEntity = _boxInforServices.GetByBoxId(box.BoxId); if (boxEntity == null) { boxEntity = new BoxInforEntity(); boxEntity.BoxId = box.BoxId; boxEntity.DateCreated = DateTime.Now; boxEntity.EmployeeId = currentEmployee.Id; boxEntity.ShipmentQuantity = 0; boxEntity.MasterBillId = currentMasterBillId; currentBoxIdInt = _boxInforServices.CreateBoxInfor(boxEntity); boxEntity.Id = currentBoxIdInt; currentBoxId = boxEntity.BoxId; } else { currentBoxIdInt = boxEntity.Id; currentBoxId = boxEntity.BoxId; } List <ManifestEntity> listManifest = new List <ManifestEntity>(); listManifest = repositoryShipment.GetManifestByBoxId(box.BoxId); listManifest = listManifest.GroupBy(t => t.ShipmentNo).Select(p => p.First()).ToList(); if (listManifest != null && listManifest.Count > 0) { List <ShipmentEntity> listShipment = new List <ShipmentEntity>(); foreach (var item in listManifest) { ShipmentEntity shipment = new ShipmentEntity(); shipment.Mawb = item.MasterAirWayBill; shipment.ShipmentId = item.ShipmentNo; shipment.BoxId = currentBoxIdInt; shipment.DateCreated = DateTime.Now; shipment.EmployeeId = currentEmployee.Id; shipment.WarehouseId = FormLogin.mWarehouse.Id; shipment.Address = item.Address; shipment.BoxIdString = item.BoxID; if (_shipmentOutServices.GetStatusCompletion(item.ShipmentNo)) { shipment.Status = "Clearance"; } else { shipment.Status = "Check"; } shipment.Content = item.Content; shipment.Country = item.Country; shipment.DeclarationNo = item.DeclarationNo; shipment.Destination = item.Destination; shipment.NumberPackage = 1; shipment.TotalValue = item.TotalValue; shipment.Sender = item.CompanyName; shipment.Consignee = item.Destination; shipment.Receiver = item.ContactName; shipment.Weight = Math.Round(item.Weight, 3); shipment.ReceiverTel = item.Tel; listShipment.Add(shipment); } countBox = repositoryShipment.CreateShipment(listShipment); if (countBox > 0) { countTotal += countBox; _boxInforServices.CreateOrUpdateByQuery(countBox, boxEntity.Id); } } } MessageBox.Show("Đã xác nhận đến thành công!\nTổng số đơn hàng là " + countTotal, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnOpenBoxOut_Click(object sender, EventArgs e) { try { if (btnOpenBoxOut.Text.Equals("Mở", StringComparison.CurrentCultureIgnoreCase)) { if (String.IsNullOrWhiteSpace(cbbMasterBillOut.Text) || String.IsNullOrWhiteSpace(cbbBoxIdOut.Text)) { MessageBox.Show("Bạn phải nhập mã Airwaybill", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } currentMasterOut = _masterBillServices.GetByMasterBillId(cbbMasterBillOut.Text); if (currentMasterOut == null) { nhapMoiKhongCanXacNhan = true; currentMasterOut = new MasterAirwayBillEntity { MasterAirwayBill = cbbMasterBillOut.Text, DateArrived = dtpNgayXuat.Value, EmployeeId = currentEmployee.Id, DateCreated = DateTime.Now }; currentMasterBillId = _masterBillServices.CreateMasterAirwayBill(currentMasterOut); currentMasterBill = currentMasterOut.MasterAirwayBill; currentMasterOut.Id = currentMasterBillId; } else { currentMasterBill = currentMasterOut.MasterAirwayBill; currentMasterBillId = currentMasterOut.Id; } /// Chuyển sang BOX OUT currentBoxOut = _boxOutServices.GetByBoxCodeandAirWaybill(cbbBoxIdOut.Text, currentMasterOut.Id); if (currentBoxOut == null) { nhapMoiKhongCanXacNhan = true; currentBoxOut = new BoxOutEntity { BoxId = cbbBoxIdOut.Text, ShipmentQuantity = 0, MasterBillId = currentMasterBillId, EmployeeId = currentEmployee.Id, DateCreated = DateTime.Now, DateInt = _repositoryShipment.DateToInt(DateTime.Now) }; currentBoxIdInt = _boxOutServices.CreateBoxOut(currentBoxOut); currentBoxId = currentBoxOut.BoxId; currentBoxOut.Id = currentBoxIdInt; } else { currentBoxIdInt = currentBoxOut.Id; currentBoxId = currentBoxOut.BoxId; } if (!LoadShipmentsByBoxId(currentBoxOut, grvShipmentListOut)) { return; } OpenBoxOut(); // Dữ liệu xác nhận đến #region Dữ liệu xác nhận đến BoxInforEntity boxEntity = _boxInforServices.GetByBoxId(cbbBoxIdOut.Text.Trim()); if (boxEntity != null) { lblCountIn.Text = _boxInforServices.GetByBoxId(boxEntity.Id).ShipmentQuantity.ToString(); } IEnumerable <ShipmentEntity> lstShipmentInfor = _shipmentServices.GetByBoxId(boxEntity.Id); if (lstShipmentInfor != null) { lstShipmentInfor = lstShipmentInfor.Where(t => t.Status == "Check"); lblClearance.Text = lstShipmentInfor.Count().ToString(); } #endregion txtShipmentIdOut.BackColor = Color.LightYellow; btnOpenBoxOut.Text = "Đóng"; } else { currentBoxOut = _boxOutServices.GetByBoxCode(cbbBoxIdOut.Text); if (currentBoxOut == null) { return; } else { IEnumerable <ShipmentOutEntity> lstshipment = _shipmentOutServices.GetByBoxId(currentBoxOut.Id); if (lstshipment == null) { _boxOutServices.Delete(currentBoxOut.Id); } else { _boxOutServices.CreateOrUpdateByQuery(lstshipment.Count(), currentBoxOut.Id); } } CloseBoxOut(); btnOpenBoxOut.Text = "Mở"; } } catch (Exception ex) { Ultilities.FileHelper.WriteLog(Ultilities.ExceptionLevel.Function, "btnOpenBoxOut_Click", ex); return; } }
private void btnOpenClose_Click(object sender, EventArgs e) { if (btnOpenClose.Text.Equals("Mở", StringComparison.CurrentCultureIgnoreCase)) { if (!ValidateInputDataConfirmArrived()) { return; } MasterAirwayBillEntity masterBill = _masterBillServices.GetByMasterBillId(cbbMasterBill.Text); if (masterBill == null) { masterBill = new MasterAirwayBillEntity(); masterBill.MasterAirwayBill = cbbMasterBill.Text; masterBill.DateArrived = dtpNgayDen.Value; masterBill.DateCreated = DateTime.Now; masterBill.EmployeeId = currentEmployee.Id; currentMasterBillId = _masterBillServices.CreateMasterAirwayBill(masterBill); currentMasterBill = masterBill.MasterAirwayBill; masterBill.Id = currentMasterBillId; cbbMasterBill.SelectedText = masterBill.MasterAirwayBill; } else { currentMasterBillId = masterBill.Id; currentMasterBill = masterBill.MasterAirwayBill; } BoxInforEntity boxEntity = _boxInforServices.GetByBoxId(cbbBoxId.Text); if (boxEntity == null) { boxEntity = new BoxInforEntity(); boxEntity.BoxId = cbbBoxId.Text; boxEntity.ShipmentQuantity = numberShipment; boxEntity.MasterBillId = currentMasterBillId; boxEntity.DateCreated = DateTime.Now; boxEntity.EmployeeId = currentEmployee.Id; currentBoxIdInt = _boxInforServices.CreateBoxInfor(boxEntity); boxEntity.Id = currentBoxIdInt; currentBoxId = boxEntity.BoxId; } else { currentBoxIdInt = boxEntity.Id; currentBoxId = boxEntity.BoxId; } OpenBox(); LoadShipmentsByBoxIdInXacNhanDen(cbbBoxId.Text, grvShipments); btnOpenClose.Text = "Đóng"; } else { if (!isConfirmed) { SaveShipment(); } BoxInforEntity boxEntity = _boxInforServices.GetByBoxId(cbbBoxId.Text); if (boxEntity == null) { return; } else { IEnumerable <ShipmentEntity> lstshipment = _shipmentServices.GetByBoxId(boxEntity.Id); if (lstshipment == null) { _boxInforServices.Delete(boxEntity.Id); } else { _boxInforServices.CreateOrUpdateByQuery(lstshipment.Count(), boxEntity.Id); } } CloseBox(); btnOpenClose.Text = "Mở"; } MasterAirwayBillEntity itemMaster = _masterBillServices.GetByMasterBillId(cbbMasterBill.Text); }
private void ChiTietSanLuongNhapKhoTheoThung() { List <ReportDetailEntity> listDetail = new List <ReportDetailEntity>(); BoxInforEntity boxSelected = (BoxInforEntity)cbbBoxId.SelectedItem; int totalShipment = 0; List <ShipmentEntity> listShipment = (List <ShipmentEntity>)_shipmentServices.GetByBoxId(boxSelected.Id); if (listShipment != null & listShipment.Count > 0) { foreach (var ship in listShipment) { ReportDetailEntity entity = new ReportDetailEntity(); entity.MasterId = cbbMasterBill.Text; entity.BoxId = boxSelected.BoxId; entity.ShipmentId = ship.ShipmentId; entity.Weight = ship.Weight; entity.Content = ship.Content; listDetail.Add(entity); } totalShipment = listShipment.Count; } string fileName = Environment.CurrentDirectory + @"\ChiTietSanLuongNhapKhoTheoThung" + DateTime.Now.ToString("ddMMyyyHHmmss") + ".doc"; string companyName = "CÔNG TY CP CÔNG NGHỆ THẦN TỐC\t\t\t\t\t\tIMW03"; string headlineText = "BẢNG KÊ CHI TIẾT SẢN LƯỢNG NHẬP KHO"; string ngayDen = "NGÀY ĐẾN : " + dtpNgayDen.Value.ToString("dd/MM/yyyy") + "\n" + "MÃ THÙNG: " + boxSelected.BoxId + "\t\t\tTỔNG SỐ ĐƠN HÀNG: " + totalShipment; string boPhanGiaoNhan = "BỘ PHẬN KHO\t\t\t\t\t\tBỘ PHẬN GIAO NHẬN"; // A formatting object for our headline: var headLineFormat = new Formatting(); headLineFormat.FontFamily = new System.Drawing.FontFamily("Times New Roman"); headLineFormat.Size = 18D; headLineFormat.Position = 12; headLineFormat.Bold = true; // A formatting object for our normal paragraph text: var paraFormat = new Formatting(); paraFormat.FontFamily = new System.Drawing.FontFamily("Times New Roman"); paraFormat.Size = 12D; paraFormat.Position = 10; paraFormat.Bold = false; var paraRightFormat = new Formatting(); paraRightFormat.FontFamily = new System.Drawing.FontFamily("Times New Roman"); paraRightFormat.Size = 12D; paraRightFormat.Position = 12; paraRightFormat.Bold = true; // Create the document in memory: var doc = DocX.Create(fileName); Table table = doc.AddTable(listDetail.Count + 1, 7); //table.ColumnWidths.Add(100); table.ColumnWidths.Add(500); table.ColumnWidths.Add(100); table.Rows[0].Cells[0].Paragraphs.First().Append("STT").Font(new FontFamily("Times New Roman")); //table.Rows[0].Cells[0].Width = 50; table.Rows[0].Cells[1].Paragraphs.First().Append("Vận đơn chủ (MAWB)").Font(new FontFamily("Times New Roman")).Alignment = Alignment.center; //table.Rows[0].Cells[1].Width = 800; table.Rows[0].Cells[2].Paragraphs.First().Append("Mã đơn hàng (ShipmentNo)").Font(new FontFamily("Times New Roman")).Alignment = Alignment.center; table.Rows[0].Cells[3].Paragraphs.First().Append("Mã thùng (BoxId)").Font(new FontFamily("Times New Roman")).Alignment = Alignment.center; table.Rows[0].Cells[4].Paragraphs.First().Append("Nội dung (Content)").Font(new FontFamily("Times New Roman")).Alignment = Alignment.center; table.Rows[0].Cells[5].Paragraphs.First().Append("Số lượng (Quantity)").Font(new FontFamily("Times New Roman")).Alignment = Alignment.center; table.Rows[0].Cells[6].Paragraphs.First().Append("Trọng lượng (Weight)").Font(new FontFamily("Times New Roman")).Alignment = Alignment.center; //table.Rows[0].Cells[2].Width = 100; table.Rows[0].Cells[0].FillColor = Color.FromName("DarkGray"); table.Rows[0].Cells[1].FillColor = Color.FromName("DarkGray"); table.Rows[0].Cells[2].FillColor = Color.FromName("DarkGray"); table.Rows[0].Cells[3].FillColor = Color.FromName("DarkGray"); table.Rows[0].Cells[4].FillColor = Color.FromName("DarkGray"); table.Rows[0].Cells[5].FillColor = Color.FromName("DarkGray"); table.Rows[0].Cells[6].FillColor = Color.FromName("DarkGray"); for (int i = 0; i < totalShipment; i++) { table.Rows[i + 1].Cells[0].Paragraphs.First().Append((i + 1) + "").Font(new FontFamily("Times New Roman")); table.Rows[i + 1].Cells[1].Paragraphs.First().Append(listDetail[i].MasterId).Font(new FontFamily("Times New Roman")); table.Rows[i + 1].Cells[2].Paragraphs.First().Append(listDetail[i].ShipmentId).Font(new FontFamily("Times New Roman")); table.Rows[i + 1].Cells[3].Paragraphs.First().Append(listDetail[i].BoxId).Font(new FontFamily("Times New Roman")); table.Rows[i + 1].Cells[4].Paragraphs.First().Append(listDetail[i].Content).Font(new FontFamily("Times New Roman")); table.Rows[i + 1].Cells[5].Paragraphs.First().Append("").Font(new FontFamily("Times New Roman")); table.Rows[i + 1].Cells[6].Paragraphs.First().Append("" + listDetail[i].Weight).Font(new FontFamily("Times New Roman")); } doc.InsertParagraph(companyName, false, paraFormat); doc.InsertParagraph(Environment.NewLine); // Insert the now text obejcts; Paragraph title = doc.InsertParagraph(headlineText, false, headLineFormat); title.Alignment = Alignment.center; doc.InsertParagraph(ngayDen, false, paraFormat); doc.InsertTable(table); doc.InsertParagraph(Environment.NewLine); Paragraph giaoNhan = doc.InsertParagraph(boPhanGiaoNhan, false, paraRightFormat); giaoNhan.Alignment = Alignment.center; // Save to the output directory: doc.SaveAs(fileName); // Open in Word: Process.Start("WINWORD.EXE", "\"" + fileName + "\""); }
private void LuuXacNhanDen() { List <ManifestEntity> listBoxInfo = manifestList.Where(t => t.MasterAirWayBill == cbbMasterBill.Text).GroupBy(t => t.BoxID).Select(p => p.First()).ToList(); if (listBoxInfo != null && listBoxInfo.Count > 0) { int count = 0; foreach (var itemBoxID in listBoxInfo) { BoxInforEntity boxEntity = _boxInforServices.GetByBoxId(itemBoxID.BoxID); if (boxEntity == null) { boxEntity = new BoxInforEntity(); boxEntity.BoxId = itemBoxID.BoxID; boxEntity.DateCreated = DateTime.Now; boxEntity.EmployeeId = currentEmployee.Id; boxEntity.ShipmentQuantity = manifestList.Where(t => t.BoxID == itemBoxID.BoxID).Count(); boxEntity.MasterBillId = currentMasterBillId; currentBoxIdInt = _boxInforServices.CreateBoxInfor(boxEntity); boxEntity.Id = currentBoxIdInt; currentBoxId = boxEntity.BoxId; } else { currentBoxIdInt = boxEntity.Id; currentBoxId = boxEntity.BoxId; } List <ManifestEntity> listShipmentNo = new List <ManifestEntity>(); listManifest = _repositoryShipment.GetManifestByBoxId(boxEntity.BoxId); listManifest = listManifest.GroupBy(t => t.ShipmentNo).Select(p => p.First()).ToList(); // Add shipment here // List<ManifestEntity> listShipmentNo = manifestList.Where(t => t.BoxID == itemBoxID.BoxID).GroupBy(t => t.ShipmentNo).Select(p => p.First()).ToList(); if (listShipmentNo != null && listShipmentNo.Count > 0) { List <ShipmentEntity> listShipment = new List <ShipmentEntity>(); foreach (var item in listShipmentNo) { ShipmentEntity shipment = new ShipmentEntity(); shipment.ShipmentId = item.ShipmentNo; shipment.BoxId = currentBoxIdInt; shipment.DateCreated = DateTime.Now; shipment.EmployeeId = currentEmployee.Id; shipment.WarehouseId = FormLogin.mWarehouse.Id; shipment.Address = item.Address; shipment.BoxIdString = item.BoxID; shipment.Content = item.Content; shipment.Country = item.Country; shipment.DeclarationNo = item.DeclarationNo; shipment.Destination = item.Destination; shipment.NumberPackage = 1; shipment.Sender = item.CompanyName; shipment.Consignee = item.Destination; shipment.Receiver = item.ContactName; shipment.Weight = Math.Round(item.Weight, 3); listShipment.Add(shipment); } count = _shipmentServices.CreateOrUpdate(listShipment); } } MessageBox.Show("Đã lưu xác nhận đến thành công!\nTổng số đơn hàng là " + count, "Lưu xác nhận đến", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void SaveShipment() { try { string boxstring = cbbBoxId.Text.Trim(); int count = 0; BoxInforEntity boxEntity = _boxInforServices.GetByBoxId(cbbBoxId.Text.Trim()); if (boxEntity == null) { boxEntity = new BoxInforEntity(); boxEntity.BoxId = boxstring; boxEntity.DateCreated = DateTime.Now; boxEntity.EmployeeId = currentEmployee.Id; boxEntity.ShipmentQuantity = 0; //manifestList.Where(t => t.BoxID == boxstring).Count(); boxEntity.MasterBillId = currentMasterBillId; currentBoxIdInt = _boxInforServices.CreateBoxInfor(boxEntity); boxEntity.Id = currentBoxIdInt; currentBoxId = boxEntity.BoxId; } else { currentBoxIdInt = boxEntity.Id; currentBoxId = boxEntity.BoxId; } if (_repositoryShipment.ShipmentExistByBoxId(boxEntity.Id)) { return; } List <ManifestEntity> listManifest = new List <ManifestEntity>(); listManifest = _repositoryShipment.GetManifestByBoxId(boxstring); listManifest = listManifest.GroupBy(t => t.ShipmentNo).Select(p => p.First()).ToList(); if (listManifest != null && listManifest.Count > 0) { List <ShipmentEntity> listShipment = new List <ShipmentEntity>(); foreach (var item in listManifest) { if (_repositoryShipment.ShipmentExist(item.ShipmentNo)) { continue; } ShipmentEntity shipment = new ShipmentEntity(); shipment.Mawb = item.MasterAirWayBill; shipment.ShipmentId = item.ShipmentNo; shipment.BoxId = currentBoxIdInt; shipment.DateCreated = DateTime.Now; shipment.EmployeeId = currentEmployee.Id; shipment.WarehouseId = FormLogin.mWarehouse.Id; shipment.Address = item.Address; shipment.BoxIdString = item.BoxID; shipment.Content = item.Content; shipment.Country = item.Country; shipment.DeclarationNo = item.DeclarationNo; shipment.Destination = item.Destination; shipment.NumberPackage = 1; shipment.Sender = item.CompanyName; shipment.Consignee = item.Destination; shipment.Receiver = item.ContactName; shipment.Weight = Math.Round(item.Weight, 3); shipment.ReceiverTel = item.Tel; listShipment.Add(shipment); } count += _shipmentServices.CreateOrUpdate(listShipment); } MessageBox.Show("Đã lưu xác nhận đến thành công!\nTổng số đơn hàng là " + count, "Lưu xác nhận đến", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { } }