Esempio n. 1
0
 private void btn_Update_Click(object sender, EventArgs e)
 {
     if (txt_ShipmentCode.Text.Trim() != "")
     {
         try
         {
             DataTable dt = new DataTable();
             Database.ERPSOFT.t_TL_Shipment t_TL_Shipment = new Database.ERPSOFT.t_TL_Shipment();
             dt = t_TL_Shipment.GetTop1Table();
             dt.Rows[0]["ShipmentCode"]   = txt_ShipmentCode.Text.Trim();
             dt.Rows[0]["ShipmentType"]   = cb_shipmentType.SelectedItem.ToString().Trim();
             dt.Rows[0]["ShipmentInfor1"] = txt_departurePort.Text.Trim();
             dt.Rows[0]["ShipmentInfor2"] = txt_DestinationPort.Text.Trim();
             var updateResult = t_TL_Shipment.UpdateBuyerInfor(dt);
             if (updateResult)
             {
                 LoadDataInformation();
             }
         }
         catch (Exception ex)
         {
             SystemLog.Output(SystemLog.MSG_TYPE.Err, "update parameter of buyer fail", ex.Message);
         }
     }
 }
        private void ShipmentTypeSelectWin_Load(object sender, EventArgs e)
        {
            Database.ERPSOFT.t_TL_Shipment t_TL_Shipment = new Database.ERPSOFT.t_TL_Shipment();
            DataTable dt = t_TL_Shipment.GetAllDataTable();

            dtgv_ShipmentSelect.DataSource = dt;
            DataGridViewCheckBoxColumn checkBoxCell = new DataGridViewCheckBoxColumn();

            checkBoxCell.Name         = "checkbox";
            checkBoxCell.HeaderText   = "Select";
            checkBoxCell.DisplayIndex = 0;
            dtgv_ShipmentSelect.Columns.Add(checkBoxCell);
        }
Esempio n. 3
0
        private void LoadDataInformation()
        {
            OrderSelected = -1;
            dtgv_ShipmentInfor.Columns.Clear();
            Database.ERPSOFT.t_TL_Shipment t_TL_Shipment = new Database.ERPSOFT.t_TL_Shipment();
            DataTable dtData = t_TL_Shipment.GetAllDataTable();

            dtgv_ShipmentInfor.DataSource = dtData;
            DataGridViewCheckBoxColumn checkBoxCell = new DataGridViewCheckBoxColumn();

            checkBoxCell.Name         = "checkbox";
            checkBoxCell.HeaderText   = "Select";
            checkBoxCell.DisplayIndex = 0;
            dtgv_ShipmentInfor.Columns.Add(checkBoxCell);
        }
Esempio n. 4
0
        private void btn_Search_Click(object sender, EventArgs e)
        {
            OrderSelected = -1;
            dtgv_ShipmentInfor.Columns.Clear();
            Database.ERPSOFT.t_TL_Shipment t_TL_Shipment = new Database.ERPSOFT.t_TL_Shipment();
            DataTable dtData = t_TL_Shipment.GetdatabyTextSearch(txt_ShipmentSearch.Text.Trim());

            dtgv_ShipmentInfor.DataSource = dtData;
            DataGridViewCheckBoxColumn checkBoxCell = new DataGridViewCheckBoxColumn();

            checkBoxCell.Name         = "checkbox";
            checkBoxCell.HeaderText   = "Select";
            checkBoxCell.DisplayIndex = 0;
            dtgv_ShipmentInfor.Columns.Add(checkBoxCell);
        }
Esempio n. 5
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            OrderSelected = -1;
            dtgv_ShipmentInfor.Columns.Clear();
            Database.ERPSOFT.t_TL_Shipment t_TL_Shipment = new Database.ERPSOFT.t_TL_Shipment();
            var insertRow = t_TL_Shipment.InsertRowTableBuyerInfor(txt_ShipmentCode.Text.Trim(), cb_shipmentType.SelectedItem.ToString().Trim(),
                                                                   txt_departurePort.Text.Trim(), txt_DestinationPort.Text.Trim());
            DataTable dtData = t_TL_Shipment.GetAllDataTable();

            dtgv_ShipmentInfor.DataSource = dtData;
            DataGridViewCheckBoxColumn checkBoxCell = new DataGridViewCheckBoxColumn();

            checkBoxCell.Name         = "checkbox";
            checkBoxCell.HeaderText   = "Select";
            checkBoxCell.DisplayIndex = 0;
            dtgv_ShipmentInfor.Columns.Add(checkBoxCell);
        }
Esempio n. 6
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            var mesResult = MessageBox.Show("Do you want to delete this shipment code: " + txt_ShipmentCode.Text.Trim() + " ?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (mesResult == DialogResult.Yes)
            {
                Database.ERPSOFT.t_TL_Shipment t_TL_Shipment = new Database.ERPSOFT.t_TL_Shipment();
                var deleteResult = t_TL_Shipment.DeleteRowby(txt_ShipmentCode.Text.Trim());
                if (deleteResult)
                {
                    LoadDataInformation();
                    MessageBox.Show("you deleted sucessful", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("you deleted fail", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        public bool ExportToPackingList(DataTable dtPickingList, string PathSave, string PathQRCode)
        {
            Excel.Application xlApp;
            Excel.Workbook    xlWorkBook;
            Excel.Worksheet   xlWorkSheet;
            Excel.Worksheet   xlWorkSheet1;


            object misValue = System.Reflection.Missing.Value;

            try
            {
                xlApp      = new Excel.Application();
                xlWorkBook = xlApp.Workbooks.Open(PathFormExportFGs, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

                #region Packing List
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                string strWorksheetName = xlWorkSheet.Name;//Get the name of worksheet.
                xlWorkSheet.Cells[7, "I"] = DateTime.Now.ToString("dd.MM.yyyy");
                xlWorkSheet.Cells[9, "I"] = dtPickingList.Rows[0]["Invoice"];
                xlWorkSheet.Cells[8, "D"] = dtPickingList.Rows[0]["Client"];
                xlWorkSheet.Cells[9, "D"] = dtPickingList.Rows[0]["KeyID"].ToString() + "-" + dtPickingList.Rows[0]["KeyNo"].ToString();
                try
                {
                    string shippingType = dtPickingList.Rows[0]["TL203"].ToString();
                    Database.ERPSOFT.t_TL_Shipment t_TL_Shipment = new Database.ERPSOFT.t_TL_Shipment();
                    DataTable dtShipment = t_TL_Shipment.GetdatabyTextSearch(shippingType);
                    if (dtShipment.Rows.Count > 0)
                    {
                        xlWorkSheet.Cells[10, "C"] = dtShipment.Rows[0]["ShipmentType"];
                    }
                }
                catch (Exception ex)
                {
                    SystemLog.Output(SystemLog.MSG_TYPE.Err, "Can't get shipment Type", ex.Message);
                }

                // xlWorkSheet.Cells[9, "D"] = dtPickingList.Rows[0]["CustomerOrder"];
                xlWorkSheet.Shapes.AddPicture(PathQRCode, MsoTriState.msoFalse, MsoTriState.msoCTrue, 30, 10, 100, 100);
                for (int i = 0; i < dtPickingList.Rows.Count; i++)
                {
                    xlWorkSheet.Cells[14 + 2 * i, "A"] = (i + 1).ToString("000");
                    xlWorkSheet.Cells[14 + 2 * i, "B"] = dtPickingList.Rows[i]["CustomerOrder"];
                    xlWorkSheet.Cells[14 + 2 * i, "C"] = dtPickingList.Rows[i]["Product"];
                    xlWorkSheet.Cells[14 + 2 * i, "E"] = dtPickingList.Rows[i]["Quantity"];
                    string Product = dtPickingList.Rows[i]["Product"].ToString();
                    Database.ERPSOFT.t_TL_Product t_TL_Product = new Database.ERPSOFT.t_TL_Product();
                    DataTable dt = new DataTable();
                    dt = t_TL_Product.GetdataExactllyProduct(Product);
                    if (dt.Rows.Count == 1)
                    {
                        try
                        {
                            xlWorkSheet.Cells[14 + 2 * i, "D"] = dt.Rows[0]["MB004"];
                            xlWorkSheet.Cells[14 + 2 * i, "F"] = dt.Rows[0]["MB005"];

                            if (dtPickingList.Rows[i]["TL201"].ToString().Trim() == "Package")
                            {
                                xlWorkSheet.Cells[14 + 2 * i, "J"] = dt.Rows[0]["MB006"];
                                var    Vsplit  = dt.Rows[0]["MB006"].ToString().Split('*');
                                double SoThung = Math.Ceiling(double.Parse(dtPickingList.Rows[i]["Quantity"].ToString()) / double.Parse(dt.Rows[0]["MB005"].ToString()));
                                xlWorkSheet.Cells[14 + 2 * i, "G"] = SoThung;
                                double NetPacking = Database.INV.INVMD.ConvertToWeightKg(Product, double.Parse(dtPickingList.Rows[i]["Quantity"].ToString()));
                                xlWorkSheet.Cells[14 + 2 * i, "H"] = NetPacking;
                                double KhoiLuongThung = SoThung * (double.Parse(dt.Rows[0]["MB007"].ToString()));
                                xlWorkSheet.Cells[14 + 2 * i, "I"] = NetPacking + KhoiLuongThung;
                                double TheTich = double.Parse(Vsplit[0].Trim()) * double.Parse(Vsplit[1].Trim()) * double.Parse(Vsplit[2].Trim()) * SoThung;
                                xlWorkSheet.Cells[14 + 2 * i, "K"] = TheTich;
                            }
                            else if (dtPickingList.Rows[i]["TL201"].ToString().Trim() == "Pallet")
                            {
                                xlWorkSheet.Cells[14 + 2 * i, "J"] = dt.Rows[0]["MB008"];
                                var    Vsplit  = dt.Rows[0]["MB008"].ToString().Split('*');
                                double SoThung = Math.Ceiling(double.Parse(dtPickingList.Rows[i]["Quantity"].ToString()) / double.Parse(dt.Rows[0]["MB005"].ToString()));
                                xlWorkSheet.Cells[14 + 2 * i, "G"] = SoThung;
                                double NetPacking = Database.INV.INVMD.ConvertToWeightKg(Product, double.Parse(dtPickingList.Rows[i]["Quantity"].ToString()));
                                xlWorkSheet.Cells[14 + 2 * i, "H"] = NetPacking;
                                double KhoiLuongThung = SoThung * (double.Parse(dt.Rows[0]["MB007"].ToString()));

                                double KLPallet = double.Parse(dt.Rows[0]["MB009"].ToString());
                                double KLNep    = double.Parse(dt.Rows[0]["MB010"].ToString());
                                xlWorkSheet.Cells[14 + 2 * i, "I"] = NetPacking + KhoiLuongThung + KLPallet + KLNep;
                                double TheTich = double.Parse(Vsplit[0].Trim()) * double.Parse(Vsplit[1].Trim()) * double.Parse(Vsplit[2].Trim()) * SoThung;
                                xlWorkSheet.Cells[14 + 2 * i, "K"] = TheTich;
                            }
                        }
                        catch (Exception ex)
                        {
                            SystemLog.Output(SystemLog.MSG_TYPE.Err, "fill values into form fail ", ex.Message);
                        }
                    }
                    //xlWorkSheet.Cells[9, "I"] = dtPickingList.Rows[0]["Invoice"];
                    //xlWorkSheet.Cells[8, "D"] = dtPickingList.Rows[0]["Client"];
                    //xlWorkSheet.Cells[9, "D"] = dtPickingList.Rows[0]["CustomerOrder"];
                }
                #endregion

                xlWorkSheet1 = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2);
                string strWorksheet1Name = xlWorkSheet1.Name;//Get the name of worksheet.
                xlWorkSheet1.Cells[7, "F"] = DateTime.Now.ToString("dd.MM.yyyy");
                xlWorkSheet1.Cells[9, "F"] = dtPickingList.Rows[0]["Warehouse"];
                xlWorkSheet1.Cells[7, "C"] = dtPickingList.Rows[0]["KeyID"].ToString() + "-" + dtPickingList.Rows[0]["KeyNo"].ToString();
                xlWorkSheet1.Cells[9, "C"] = Class.valiballecommon.GetStorage().UserName;
                xlWorkSheet1.Shapes.AddPicture(PathQRCode, MsoTriState.msoFalse, MsoTriState.msoCTrue, 30, 10, 100, 100);
                for (int i = 0; i < dtPickingList.Rows.Count; i++)
                {
                    xlWorkSheet1.Cells[14 + 2 * i, "A"] = (i + 1).ToString("000");
                    xlWorkSheet1.Cells[14 + 2 * i, "B"] = dtPickingList.Rows[i]["CustomerOrder"];
                    xlWorkSheet1.Cells[14 + 2 * i, "C"] = dtPickingList.Rows[i]["Product"];
                    xlWorkSheet1.Cells[14 + 2 * i, "E"] = dtPickingList.Rows[i]["Quantity"];
                    xlWorkSheet1.Cells[14 + 2 * i, "F"] = dtPickingList.Rows[i]["LotNo"];
                    xlWorkSheet1.Cells[14 + 2 * i, "G"] = dtPickingList.Rows[i]["Location"];
                    string Product = dtPickingList.Rows[i]["Product"].ToString();
                    Database.ERPSOFT.t_TL_Product t_TL_Product = new Database.ERPSOFT.t_TL_Product();
                    DataTable dt = new DataTable();
                    dt = t_TL_Product.GetdataExactllyProduct(Product);
                    if (dt.Rows.Count == 1)
                    {
                        xlWorkSheet1.Cells[14 + 2 * i, "D"] = dt.Rows[0]["MB004"];
                    }
                }

                xlWorkBook.SaveAs(PathSave, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                xlWorkBook.Close(true, misValue, misValue);
                xlApp.Quit();
                reOject(xlWorkSheet);
                reOject(xlWorkSheet1);
                reOject(xlWorkBook);
                reOject(xlApp);
                return(true);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "Export packing list and picking list", ex.Message);
            }
            return(false);
        }
        public bool ExportCustomsDecalarationsGroupByProduct(string PathSave, DataTable dtexport, List <SummaryDelivery> summaries, string buyerCode, string shipmentCode)
        {
            Excel.Application xlApp;
            Excel.Workbook    xlWorkBook;
            Excel.Worksheet   xlWorkSheet;
            Excel.Worksheet   xlWorkSheet2;
            Excel.Worksheet   xlWorkSheet3;

            object misValue = System.Reflection.Missing.Value;

            try
            {
                xlApp      = new Excel.Application();
                xlWorkBook = xlApp.Workbooks.Open(PathFormExportFGs, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                #region Sales Invoice
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                string strWorksheetName = xlWorkSheet.Name;
                xlWorkSheet.Cells[11, "K"] = dtexport.Rows[0]["Invoice"];
                xlWorkSheet.Cells[12, "K"] = DateTime.Now.ToString("dd-MM-yyyy");

                int    TotalMoney     = 0;
                double douTotalMonney = 0;

                //Thong tin buyer
                Database.ERPSOFT.t_TL_BuyerInfor t_TL_BuyerInfor = new Database.ERPSOFT.t_TL_BuyerInfor();
                DataTable dtBuyer = t_TL_BuyerInfor.GetdatabyTextSearch(buyerCode);
                Database.ERPSOFT.t_TL_Shipment t_TL_Shipment = new Database.ERPSOFT.t_TL_Shipment();
                DataTable dtShipment = t_TL_Shipment.GetdatabyTextSearch(shipmentCode);
                xlWorkSheet.Cells[11, "C"] = dtBuyer.Rows[0]["Buyer_Infor"].ToString();
                xlWorkSheet.Cells[91, "B"] = dtBuyer.Rows[0]["Buyer_Consignee"].ToString();
                //Thong tin transportation



                for (int i = 0; i < summaries.Count; i++)
                {
                    xlWorkSheet.Cells[23 + i, "A"] = (i + 1).ToString("0000");
                    // xlWorkSheet.Cells[23 + i, "C"] = dtexport.Rows[i]["Product"];
                    xlWorkSheet.Cells[23 + i, "D"] = summaries[i].Product;
                    xlWorkSheet.Cells[23 + i, "G"] = summaries[i].TotalQuantity;
                    xlWorkSheet.Cells[23 + i, "H"] = summaries[i].Unit;
                    if (summaries[i].Currency.Trim() == "USD")
                    {
                        xlWorkSheet.Cells[23 + i, "I"] = "$ " + summaries[i].PriceUnit;
                    }
                    else if (summaries[i].Currency.Trim() == "EUR")
                    {
                        xlWorkSheet.Cells[23 + i, "I"] = "€ " + summaries[i].PriceUnit;
                    }

                    xlWorkSheet.Cells[23 + i, "K"] = double.Parse(summaries[i].PriceUnit.ToString()) * double.Parse(summaries[i].TotalQuantity.ToString());
                    douTotalMonney += double.Parse(summaries[i].PriceUnit.ToString()) * double.Parse(summaries[i].TotalQuantity.ToString());

                    xlWorkSheet.Cells[23 + i, "E"] = "Vietnam";


                    string Product = summaries[i].Product.Trim();
                    Database.ERPSOFT.t_TL_Product t_TL_Product = new Database.ERPSOFT.t_TL_Product();
                    DataTable dt = new DataTable();
                    dt = t_TL_Product.GetdataExactllyProduct(Product);
                    if (dt.Rows.Count == 1)
                    {
                        try
                        {
                            xlWorkSheet.Cells[23 + i, "C"] = dt.Rows[0]["MB004"].ToString().Trim();
                        }

                        catch (Exception ex)
                        {
                            SystemLog.Output(SystemLog.MSG_TYPE.Err, "Error", ex.Message);
                        }
                    }
                }

                TotalMoney = (int)(douTotalMonney);
                var test = douTotalMonney - TotalMoney;

                int    numberCent        = (int)(Math.Round((douTotalMonney - TotalMoney) * 100, 2));
                string ConvertToText     = NumberConverterToText.Converter.ConvertNumberToString(TotalMoney);
                string convertToCentText = NumberConverterToText.Converter.ConvertNumberToString(numberCent);
                if (dtexport.Rows[0]["Currency"].ToString().Trim() == "USD")
                {
                    xlWorkSheet.Cells[89, "A"] = "SAY TOTAL US DOLLAR " + ConvertToText.ToUpper() + " AND CENTS " + convertToCentText.ToUpper() + " ONLY";
                    xlWorkSheet.Cells[22, "I"] = "USD";
                    xlWorkSheet.Cells[22, "K"] = "USD";
                    xlWorkSheet.Cells[86, "I"] = "USD";
                }
                else if (dtexport.Rows[0]["Currency"].ToString().Trim() == "EUR")
                {
                    xlWorkSheet.Cells[89, "A"] = "SAY TOTAL EU DOLLAR " + ConvertToText.ToUpper() + " AND CENTS " + convertToCentText.ToUpper() + " ONLY";
                    xlWorkSheet.Cells[22, "I"] = "EUR";
                    xlWorkSheet.Cells[22, "K"] = "EUR";
                    xlWorkSheet.Cells[86, "I"] = "EUR";
                }
                #endregion
                #region Delivery Notes

                xlWorkSheet2 = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2);
                string strWorksheet2Name = xlWorkSheet2.Name;
                xlWorkSheet2.Cells[11, "K"] = dtexport.Rows[0]["Invoice"];
                xlWorkSheet2.Cells[12, "K"] = DateTime.Now.ToString("dd-MM-yyyy");
                xlWorkSheet2.Cells[11, "C"] = dtBuyer.Rows[0]["Buyer_Infor"].ToString();
                xlWorkSheet2.Cells[15, "C"] = dtShipment.Rows[0]["ShipmentType"].ToString();



                for (int i = 0; i < summaries.Count; i++)
                {
                    xlWorkSheet2.Cells[23 + i, "A"] = (i + 1).ToString("0000");
                    // xlWorkSheet.Cells[23 + i, "C"] = dtexport.Rows[i]["Product"];
                    xlWorkSheet2.Cells[23 + i, "D"] = summaries[i].Product;
                    xlWorkSheet2.Cells[23 + i, "G"] = summaries[i].TotalQuantity;
                    xlWorkSheet2.Cells[23 + i, "H"] = summaries[i].Unit;

                    if (summaries[i].Currency.ToString().Trim() == "USD")
                    {
                        xlWorkSheet2.Cells[23 + i, "I"] = "$ " + summaries[i].PriceUnit;
                    }
                    else if (summaries[i].Currency.ToString().Trim() == "EUR")
                    {
                        xlWorkSheet2.Cells[23 + i, "I"] = "€ " + summaries[i].PriceUnit;
                    }

                    xlWorkSheet2.Cells[23 + i, "K"] = double.Parse(summaries[i].PriceUnit.ToString()) * double.Parse(summaries[i].TotalQuantity.ToString());
                    //   TotalMoney += (int)(double.Parse(dtexport.Rows[i]["PriceUnit"].ToString()) * double.Parse(dtexport.Rows[i]["Quantity"].ToString()));
                    xlWorkSheet2.Cells[23 + i, "E"] = "Vietnam";



                    string Product = summaries[i].Product.Trim();
                    Database.ERPSOFT.t_TL_Product t_TL_Product = new Database.ERPSOFT.t_TL_Product();
                    DataTable dt = new DataTable();
                    dt = t_TL_Product.GetdataExactllyProduct(Product);
                    if (dt.Rows.Count == 1)
                    {
                        try
                        {
                            xlWorkSheet2.Cells[23 + i, "C"] = dt.Rows[0]["MB004"].ToString().Trim();
                        }
                        catch (Exception ex)
                        {
                            SystemLog.Output(SystemLog.MSG_TYPE.Err, "Error", ex.Message);
                        }
                    }
                }

                if (dtexport.Rows[0]["Currency"].ToString().Trim() == "USD")
                {
                    xlWorkSheet2.Cells[22, "I"] = "USD";
                    xlWorkSheet2.Cells[22, "K"] = "USD";
                }
                else if (dtexport.Rows[0]["Currency"].ToString().Trim() == "EUR")
                {
                    xlWorkSheet2.Cells[22, "I"] = "EUR";
                    xlWorkSheet2.Cells[22, "K"] = "EUR";
                }



                #endregion

                #region Sales Contract
                xlWorkSheet3 = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(3);
                string strWorksheet3Name = xlWorkSheet3.Name;
                xlWorkSheet3.Cells[25, "K"] = DateTime.Now.ToString("dd-MM-yyyy");
                // xlWorkSheet3.Cells[12, "K"] = DateTime.Now.ToString("dd-MM-yyyy");
                xlWorkSheet3.Cells[15, "C"]  = dtBuyer.Rows[0]["Buyer_Infor"].ToString();
                xlWorkSheet3.Cells[20, "B"]  = dtBuyer.Rows[0]["Buyer_Consignee"].ToString();
                xlWorkSheet3.Cells[109, "D"] = dtShipment.Rows[0]["ShipmentType"].ToString();
                xlWorkSheet3.Cells[111, "D"] = dtShipment.Rows[0]["ShipmentInfor1"].ToString();
                xlWorkSheet3.Cells[112, "D"] = dtShipment.Rows[0]["ShipmentInfor2"].ToString();



                for (int i = 0; i < summaries.Count; i++)
                {
                    xlWorkSheet3.Cells[33 + i, "A"] = (i + 1).ToString("0000");
                    // xlWorkSheet.Cells[23 + i, "C"] = dtexport.Rows[i]["Product"];
                    xlWorkSheet3.Cells[33 + i, "D"] = summaries[i].Product;
                    xlWorkSheet3.Cells[33 + i, "G"] = summaries[i].TotalQuantity;
                    xlWorkSheet3.Cells[33 + i, "H"] = summaries[i].Unit;

                    if (summaries[i].Currency.Trim() == "USD")
                    {
                        xlWorkSheet3.Cells[33 + i, "I"] = "$ " + summaries[i].PriceUnit;
                    }
                    else if (summaries[i].Currency.Trim().Trim() == "EUR")
                    {
                        xlWorkSheet3.Cells[33 + i, "I"] = "€ " + summaries[i].PriceUnit;
                    }

                    xlWorkSheet3.Cells[33 + i, "K"] = double.Parse(summaries[i].PriceUnit.ToString()) * double.Parse(summaries[i].TotalQuantity.ToString());
                    //  TotalMoney += (int)(double.Parse(dtexport.Rows[i]["PriceUnit"].ToString()) * double.Parse(dtexport.Rows[i]["Quantity"].ToString()));



                    xlWorkSheet3.Cells[33 + i, "F"] = "Vietnam";
                    string Product = summaries[i].Product.Trim();
                    Database.ERPSOFT.t_TL_Product t_TL_Product = new Database.ERPSOFT.t_TL_Product();
                    DataTable dt = new DataTable();
                    dt = t_TL_Product.GetdataExactllyProduct(Product);
                    if (dt.Rows.Count == 1)
                    {
                        try
                        {
                            xlWorkSheet3.Cells[33 + i, "C"] = dt.Rows[0]["MB004"].ToString().Trim();
                        }
                        catch (Exception ex)
                        {
                            SystemLog.Output(SystemLog.MSG_TYPE.Err, "Error", ex.Message);
                        }
                    }
                }

                if (dtexport.Rows[0]["Currency"].ToString().Trim() == "USD")
                {
                    xlWorkSheet3.Cells[99, "A"] = "SAY TOTAL US DOLLAR " + ConvertToText.ToUpper() + " AND CENTS " + convertToCentText.ToUpper() + " ONLY";
                    xlWorkSheet3.Cells[32, "I"] = "USD";
                    xlWorkSheet3.Cells[32, "K"] = "USD";
                    xlWorkSheet3.Cells[97, "I"] = "USD";
                }
                else if (dtexport.Rows[0]["Currency"].ToString().Trim() == "EUR")
                {
                    xlWorkSheet3.Cells[99, "A"] = "SAY TOTAL EU DOLLAR " + ConvertToText.ToUpper() + " AND CENTS " + convertToCentText.ToUpper() + " ONLY";
                    xlWorkSheet3.Cells[32, "I"] = "EUR";
                    xlWorkSheet3.Cells[32, "J"] = "EUR";
                    xlWorkSheet3.Cells[97, "I"] = "EUR";
                }


                #endregion


                xlWorkBook.SaveAs(PathSave, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                xlWorkBook.Close(true, misValue, misValue);

                xlApp.Quit();
                reOject(xlWorkSheet);
                reOject(xlWorkSheet2);
                reOject(xlWorkSheet3);
                reOject(xlWorkBook);
                reOject(xlApp);
            }
            catch (Exception EX)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "ExportCustomsDecalaration(string PathSave,DataTable dtexport)", "export fail");
                return(false);
            }
            return(true);
        }