public int CreateBoxOut(BoxOutEntity boxOut) { using (var scope = new TransactionScope()) { Mapper.CreateMap <BoxOutEntity, BoxOut>(); var boxOutService = Mapper.Map <BoxOutEntity, BoxOut>(boxOut); _unitOfWork.BoxOutRepository.Insert(boxOutService); _unitOfWork.SaveWinform(); scope.Complete(); return(boxOutService.Id); } }
private bool LoadShipmentsByBoxId(BoxOutEntity boxEntity, DataGridView shipmentGrid) { ShipmentRepository _repositoryShipment = new ShipmentRepository(); ShipmentExport shipmentexport = new ShipmentExport(); try { if (boxEntity == null) { shipmentGrid.DataSource = null; return(false); } List <ShipmentExport> listShipment = _repositoryShipment.GetListShipmentByBoxId(boxEntity.Id); string text = ""; DialogResult process = DialogResult.Yes; if (listShipment != null && listShipment.Count > 0) { text += "Tổng số đơn hàng: " + listShipment.Count; text += "\nXuất kho ngày " + boxEntity.DateCreated.ToString("dd/MM/yyyy"); text += "\nBạn muốn mở không ?"; process = MessageBox.Show(text, boxEntity.BoxId, MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (process == DialogResult.Yes) { if (listShipment != null) { AddShipmentListToGrid(listShipment, shipmentGrid); } return(true); } else { shipmentGrid.DataSource = null; return(false); } } catch (Exception ex) { Ultilities.FileHelper.WriteLog(Ultilities.ExceptionLevel.Function, "LoadShipmentsByBoxId", ex); return(false); } }
private void ChiTietSanLuongXuatKho() { BoxOutEntity box = _boxOutServices.GetByBoxCode(cbbBoxIdOut.Text); if (box == null) { MessageBox.Show("Chọn mã thùng để in báo cáo!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } List <ShipmentExport> listDetail = _repositoryShipment.GetListShipmentByBoxId(box.Id); DataTable table = new DataTable(); table.Columns.Add(StringHeaderReports.STT); table.Columns.Add(StringHeaderReports.MAWB); table.Columns.Add(StringHeaderReports.BOXID); table.Columns.Add(StringHeaderReports.SHIPMENTNO); //table.Columns.Add(StringHeaderReports.DECLARATION_NO, typeof(string)); table.Columns.Add(StringHeaderReports.CONTENT); //table.Columns.Add(StringHeaderReports.NUMBER_PACKAGE); table.Columns.Add(StringHeaderReports.WEIGHT); int totalThung = 0, index = 1; int totalShipment; if (listDetail != null && listDetail.Count > 0) { totalShipment = listDetail.Count; totalThung = 1; int boxId = listDetail[0].BoxIdRef; for (int i = 0; i < totalShipment; i++) { // var shipment = listShipDetail.Find(t => t.ShipmentId == listDetail[i].ShipmentId); DataRow row = table.NewRow(); row[StringHeaderReports.STT] = index; row[StringHeaderReports.MAWB] = listDetail[i].MasterBillIdString; row[StringHeaderReports.SHIPMENTNO] = "'" + listDetail[i].ShipmentId; row[StringHeaderReports.BOXID] = listDetail[i].BoxIdString; row[StringHeaderReports.WEIGHT] = listDetail[i].Weight; row[StringHeaderReports.CONTENT] = listDetail[i].Content; table.Rows.Add(row); index++; if (boxId != listDetail[i].BoxIdRef) { totalThung++; boxId = listDetail[i].BoxIdRef; } } } else { MessageBox.Show("Chưa có hàng hóa nào được xuất kho!"); return; } string infoHeader = "MÃ THÙNG: "; string value = box.BoxId; Dictionary <string, string> first = new Dictionary <string, string>(); first.Add("NGÀY XUẤT : ", dtpNgayXuat.Value.ToString("dd/MM/yyyy")); Dictionary <string, string> second = new Dictionary <string, string>(); second.Add(infoHeader, value); second.Add("TỔNG SỐ ĐƠN HÀNG: ", "" + totalShipment); FormUltils.getInstance().ExportToExcel(table, "CT_Xuat_Kho_Theo_Thung", StringHeaderReports.REPORTS_NAME_CHI_TIET_XUAT_KHO, StringHeaderReports.REPORT_CODE_01, first, second); #region word report //int totalShipment; //if (listDetail != null && listDetail.Count > 0) //{ // totalShipment = listDetail.Count; //} //else //{ // MessageBox.Show("Chưa có đơn hàng của mã thùng này nào được xuất kho!", "Không có dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //string fileName = Environment.CurrentDirectory + @"\ChiTietSanLuongXuatKho" + DateTime.Now.ToString("ddMMyyyHHmmss") + ".doc"; //string companyName = "CÔNG TY CP CÔNG NGHỆ THẦN TỐC\t\t\t\t\t\tEMW01"; //string headlineText = "BẢNG KÊ CHI TIẾT SẢN LƯỢNG XUẤT KHO"; //string ngayDen = "NGÀY ĐẾN : " + dtpNgayXuat.Value.ToString("dd/MM/yyyy") + "\n" // + "MÃ SỐ THÙNG: " + box.BoxId // + "\t\t\tTỔNG ĐƠ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].MasterBillIdString).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].BoxIdString).Font(new FontFamily("Times New Roman")); // table.Rows[i + 1].Cells[4].Paragraphs.First().Append("").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("").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 + "\""); #endregion }
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; } }