private static void DoPrintEirOut(ContInOut cont) { EirOutPrint_ t_ = new EirOutPrint_(cont); ReportDocument document = new ReportDocument(); string printerName = document.PrinterSettings.PrinterName; document.PrinterSettings.PrinterName = ConfigurationSettings.AppSettings["eiroutprint.printer1.name"]; if (!document.PrinterSettings.IsValid) { document.PrinterSettings.PrinterName = printerName; } document.ReportMaker = t_; int num = 0; int num2 = 0; try { num = Convert.ToInt32(ConfigurationSettings.AppSettings["eiroutprint.left"]); } catch (Exception) { } try { num2 = Convert.ToInt32(ConfigurationSettings.AppSettings["eiroutprint.top"]); } catch (Exception) { } document.PrintController = new StandardPrintController(); document.DefaultPageSettings.Margins.Bottom = 0; document.DefaultPageSettings.Margins.Left = num; document.DefaultPageSettings.Margins.Top = num2; document.DefaultPageSettings.Margins.Right = 0; try { System.Console.WriteLine("Printing starting...."); document.Print(); System.Console.WriteLine("Printing complete."); } catch (Exception exception) { System.Console.WriteLine("Printing error: " + exception.Message); } }
private static bool PrintEir(ContCard card) { System.Console.Write("Step 2. Checking INOUTREV at " + DateTime.Now.ToString("hh:mm:ss") + "..."); InOutRevenue revenue = new InOutRevenue(); InOutRevenueDAL revenueDal = new InOutRevenueDAL(); revenue = revenueDal.FillInOutRevenueByInOutRevenueId(card.RefID); System.Console.WriteLine("OK"); System.Console.Write("Step 3. Checking CUSTDO at " + DateTime.Now.ToString("hh:mm:ss") + "..."); CustDo custDo = new CustDo(); CustDoDAL custDoDAL = new CustDoDAL(); custDo = custDoDAL.FillCustDoByCustDoId(revenue.RefId); System.Console.WriteLine("OK"); System.Console.Write("Step 4. Checking CONTINOUT at " + DateTime.Now.ToString("hh:mm:ss") + "..."); ContInOut cont = new ContInOut(); ContInOutDAL contInOutDAL = new ContInOutDAL(); cont = contInOutDAL.FillContInOutById(card.ContInOutID); if (cont.ContInOutId == 0) { System.Console.WriteLine("Error: Container is Invalid."); return(false); } if (cont.DtmOut.Length > 0) { System.Console.WriteLine("Error: Container is Gated Out: " + cont.Cont + " " + cont.DtmOut); return(false); } System.Console.WriteLine("OK"); cont.VesselVoyage = custDo.VesselVoyage; cont.VesselVoyageName = custDo.VesselVoyageName; cont.Destination = custDo.Destination; cont.DestinationName = custDo.DestinationName; cont.DoNumber = custDo.DoNumber; cont.NoSeriOrOut = revenue.NoSeri; cont.ActOut = custDo.ActOut; cont.Shipper = (custDo.ExBatalRealShipper.Length == 0) ? custDo.Shipper : custDo.ExBatalRealShipper; if (custDo.ExBatalRealShipper.Length > 0) { cont.Remarks = "EBO"; } cont.DtmOutDepoIn = DateTime.Today.ToString("yyyy-MM-dd HH:mm:ss"); cont.NoMobilOut = card.NoMobilOut; if (cont.AngkutanOut.Length == 0) { cont.AngkutanOut = card.AngkutanOut; } cont.Seal = card.Seal1; if (cont.DtmOut.Length == 0) { cont.DtmOut = GlobalWebServiceDAL.GetServerDtm().AddMinutes(1.0).ToString("yyyy-MM-dd HH:mm:ss"); } if (cont.DtmOut.Length == 0) { System.Console.WriteLine("Error: DtmOut Empty"); return(false); } TruckInDepo depo = new TruckInDepo(); TruckInDepoDAL depoDAL = new TruckInDepoDAL(); depo = depoDAL.FillByNomobilNotOut(cont.NoMobilOut); if (depo.TruckInDepoId == 0) { depo.DtmOut = GlobalWebServiceDAL.GetServerDtm(); } cont.EirOut = CtsCounter.NextValCtsCounter("EIRCTR").ToString(); cont.Location = ""; try { int contCount; ContInOut out2; if (revenue.TakeDef.Contains(cont.Cont)) { goto Label_04FD; } List <ContInOut> list = new List <ContInOut>(); list = contInOutDAL.FillByNoSeriOrOut(revenue.NoSeri, cont.Size, cont.Type, revenue.TakeDef); int count = list.Count; System.Console.WriteLine("Checking over release of " + count.ToString() + " parties at " + DateTime.Now.ToString("hh:mm:ss") + "..."); System.Console.Write("Please wait...."); ContSpec spec = new ContSpec(); string size = cont.Size; if (size != null) { if (size != "20") { if (size == "40") { goto Label_042E; } if (size == "45") { goto Label_0438; } } else { spec[0] = revenue.Take20; } } goto Label_0442; Label_042E: spec[0] = revenue.Take40; goto Label_0442; Label_0438: spec[0] = revenue.Take45; Label_0442: contCount = 0; foreach (ContSpec item in spec) { if (item.ToString() == cont.Type) { contCount = item.ContTotalCount; } } System.Console.WriteLine("completed at " + DateTime.Now.ToString("hh:mm:ss")); if (contCount <= count) { System.Console.WriteLine("Error: Too Many Container Released"); return(false); } Label_04FD: out2 = new ContInOut(); ContInOutDAL contInOutDAL2 = new ContInOutDAL(); out2 = contInOutDAL2.FillContInOutById(cont.ContInOutId); if (out2.DtmOut.Length > 0) { System.Console.WriteLine("Error: Container " + out2.Cont + " Already Gate Out At " + out2.DtmOut + " !!!"); return(false); } contInOutDAL.UpdateContInOut(cont); if (depo.TruckInDepoId == 0) { System.Console.Write("Step 5. Updating truckindepo at " + DateTime.Now.ToString("hh:mm:ss") + "..."); //depo.Update(null, tr); System.Console.WriteLine("OK"); } System.Console.Write("Step 6. Committing changes at " + DateTime.Now.ToString("hh:mm:ss") + "..."); System.Console.WriteLine("OK"); ContInOut out3 = new ContInOut(); ContInOutDAL contInOutDAL3 = new ContInOutDAL(); out3 = contInOutDAL3.FillContInOutById(cont.ContInOutId); if (out3.DtmOut.Length == 0) { System.Console.WriteLine("Re-Checking: continout dtmout is empty"); return(false); } System.Console.WriteLine("Re-Checking: continout dtmout is OK at " + out3.DtmOut); DoPrintEirOut(cont); return(true); } catch (Exception exception) { System.Console.WriteLine("Error printing : " + exception.Message); return(false); } }