Example #1
0
 /// <summary>
 /// Iports the invoice from XML.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="url">The URL.</param>
 /// <param name="listIndex">Index of the list.</param>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="progressChanged">The progress changed.</param>
 public static void IportInvoiceFromXml(Stream stream, string url, int listIndex, string fileName, ProgressChangedEventHandler progressChanged)
 {
     try
     {
         using (Entities edc = new Entities(url))
         {
             String message = String.Format("Import of the invoice message {0} starting.", fileName);
             ActivityLogCT.WriteEntry(edc, m_Title, message);
             InvoiceXml document = InvoiceXml.ImportDocument(stream);
             InvoiceLib entry    = Element.GetAtIndex <InvoiceLib>(edc.InvoiceLibrary, listIndex);
             GetXmlContent(document, edc, entry);
             ActivityLogCT.WriteEntry(edc, m_Title, String.Format("Import of the invoice message {0} finished", fileName));
         }
     }
     catch (CAS.SmartFactory.IPR.WebsiteModel.InputDataValidationException _iove)
     {
         _iove.ReportActionResult(url, fileName);
         ActivityLogCT.WriteEntry(m_Title, "Import of the invoice message failed", url);
     }
     catch (Exception ex)
     {
         ActivityLogCT.WriteEntry("Aborted Invoice message import because of the error", ex.Message, url);
         ActivityLogCT.WriteEntry(m_Title, "Import of the invoice message failed", url);
     }
 }
Example #2
0
        public string UpdateInvRequestLine(int PgID, int ObjID, int IRLineID, int InvReqID, int ItemNbr, int iDocType, string ProdType, string ProdCode, string Desc, string A1, string A2, string A3, string A4, string A5, string A6, string A7, string A8,
                                           string A9, string A10, string A11, string A12, string A13, double OrigQty, double OrigQty2, double RevQty, double RevQty2, double OrigPrice, double RevPrice, double TotalCRDBAmt, int InvAdj, int RedTag, double RtnQty, double RtnPkg,
                                           double RtnQtyCheckedIn, string Tickets, string Explanation, string LocCode, int IsRtn, int Active, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                InvoiceLib inv = new InvoiceLib();
                DataTable  dt  = inv.UpdateInvRequestLine(IRLineID, InvReqID, ItemNbr, iDocType, ProdType, ProdCode, Desc, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, OrigQty, OrigQty, RevQty, RevQty2, OrigPrice, RevPrice, TotalCRDBAmt,
                                                          InvAdj, RedTag, RtnQty, RtnPkg, RtnQtyCheckedIn, Tickets, Explanation, LocCode, IsRtn, Active, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "UpdateInvRequestLine", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Upd InvRequest Line", IRLineID, ByID, ex.Message, 0, "UpdateInvRequestLine function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
Example #3
0
        public string UpdateInvRequestData(int PgID, int ObjID, int RequestID, int InvReqID, string DtReq, int ReqByID, string DocType, int DispID, string StatusCode, string CustCode, string CustCtlNbr, int CarrierID,
                                           string VendorCode, int InvNbr, string InvDt, int OrdNbr, int ShipNbr, int OtherNbr1, int OtherNbr2, int OtherNbr3, int CreditRepID, int SalesPID, string SalesLead, string ShipFmLoc, string LocCode2,
                                           string LocCode3, string ReasonCode, string ReasonDetail, int CustReqCopy, int Setting1, int Setting2, int Setting3, int Setting4, int Setting5, int Setting6, double OrigAmt, double AdjInvoiceAmt,
                                           double AdjAmt, double FrtRate, double OtherAmt, string OtherVal1, string OtherVal2, string ProdVal1, string ProdVal2, string ProdVal3, string RequiredDt, string TgtDT, string ActDate1, string ActDate2,
                                           string TransDT1, string TransDT2, int NbrProd, int Active, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                InvoiceLib inv = new InvoiceLib();
                DataTable  dt  = inv.UpdateInvRequestData(RequestID, InvReqID, DtReq, ReqByID, DocType, DispID, StatusCode, CustCode, CustCtlNbr, CarrierID, VendorCode, InvNbr, InvDt, OrdNbr, ShipNbr, OtherNbr1, OtherNbr2, OtherNbr3,
                                                          CreditRepID, SalesPID, SalesLead, ShipFmLoc, LocCode2, LocCode3, ReasonCode, ReasonDetail, CustReqCopy, Setting1, Setting2, Setting3, Setting4, Setting5, Setting6, OrigAmt, AdjInvoiceAmt, AdjAmt, FrtRate,
                                                          OtherAmt, OtherVal1, OtherVal2, ProdVal1, ProdVal2, ProdVal3, RequiredDt, TgtDT, ActDate1, ActDate2, TransDT1, TransDT2, NbrProd, Active, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "UpdateInvRequestData", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Upd InvRequest", InvReqID, ByID, ex.Message, 0, "UpdateInvRequestData function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
Example #4
0
        private static InvoiceContent CreateInvoiceContent(Entities edc, InvoiceLib parent, InvoiceItemXml item, ErrorsList errors)
        {
            Batch _batch = Batch.FindLookup(edc, item.Batch);

            if (_batch == null)
            {
                errors.Add(new Warnning(String.Format("Cannot find batch {0} for stock record {1}.", item.Batch, item.Description), true));
                return(null);
            }
            InvoiceContentStatus _invoiceContentStatus = InvoiceContentStatus.OK;
            double?_Quantity = item.Bill_qty_in_SKU.ConvertToDouble();

            if (_batch.FGQuantityAvailable.Value < _Quantity.Value)
            {
                _invoiceContentStatus = InvoiceContentStatus.NotEnoughQnt;
            }
            return(new InvoiceContent()
            {
                InvoiceContent2BatchIndex = _batch,
                InvoiceIndex = parent,
                SKUDescription = item.Description,
                ProductType = _batch.ProductType,
                Quantity = _Quantity,
                Units = item.BUn,
                Title = "Creating",
                InvoiceContentStatus = _invoiceContentStatus
            });
        }
Example #5
0
		protected void LoadSalesGroupList()
		{
			try
			{
				InvoiceLib il = new InvoiceLib();
				DataTable dt = il.SelectSalesGroupList(1, _UserID);
				lbxSalesGroupF.DataTextField = "slsgrp";
				lbxSalesGroupF.DataValueField = "slsgrp";
				lbxSalesGroupF.DataSource = dt;
				lbxSalesGroupF.DataBind();
			}
			catch (Exception ex)
			{
				this.lblErrorMsg.Text = "Error when loading sales group list: " + ex.Message;
			}
		}
Example #6
0
    protected void LoadControllerList() {
     try
			{
				//ddlControllerF
				InvoiceLib IL = new InvoiceLib();
				DataTable dt = IL.SelectControllerList(0, _UserID);
				lbxControllerF.DataTextField = "username";
				lbxControllerF.DataValueField = "username";
				lbxControllerF.DataSource = dt;
				lbxControllerF.DataBind();
			}
			catch (Exception ex)
			{
				this.lblErrorMsg.Text = "Error while loading controller list: " + ex.Message;
			}
    }
        private void Show(InvoiceLib invoice, InvoiceContent invoiceContent, Batch batch)
        {
            m_InvoiceTextBox.Text = invoice == null?String.Empty.NotAvailable() : invoice.Title;

            if (invoiceContent != null)
            {
                m_InvoiceContentTextBox.Text  = invoiceContent.Title;
                m_InvoiceQuantityTextBox.Text = m_ControlState.InvoiceContent.Quantity.Value.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                m_InvoiceContentTextBox.Text  = String.Empty.NotAvailable();
                m_InvoiceQuantityTextBox.Text = String.Empty;
            }
            m_BatchTextBox.Text = batch == null?String.Empty.NotAvailable() : batch.Title;
        }
Example #8
0
    protected void LoadCreditGroupList() {
			try
			{
				//ddlCreditGroupF
				InvoiceLib il = new InvoiceLib();
				DataTable dt = il.SelectCreditGroupList(0, _UserID);
				lbxCreditGroupF.DataTextField = "grp";
				lbxCreditGroupF.DataValueField = "grp";
				lbxCreditGroupF.DataSource = dt;
				lbxCreditGroupF.DataBind();
			}
			catch (Exception ex)
			{
				this.lblErrorMsg.Text = "Error generated while loading credit group list: " + ex.Message;
			}
		}
Example #9
0
 internal static void GetXmlContent(InvoiceXml xml, Entities edc, InvoiceLib entry)
 {
     entry.ClearenceIndex         = null;
     entry.InvoiceLibraryReadOnly = false;
     try
     {
         entry.InvoiceLibraryStatus = GetXmlContent(xml.Item, edc, entry);
         edc.SubmitChanges();
     }
     catch (Exception)
     {
         entry.BillDoc = String.Empty.NotAvailable();
         entry.InvoiceLibraryStatus = false;
         edc.SubmitChanges();
         throw;
     }
 }
Example #10
0
 protected void LoadARTypeList() {
   try {
     InvoiceLib inv = new InvoiceLib();
     DataTable dt = inv.GetInvoiceTypesList(0, 1, _UserID);
     this.lbxARTypeF.DataTextField = "codedesc";
     this.lbxARTypeF.DataValueField = "code";
     this.lbxARTypeF.DataSource = dt;
     this.lbxARTypeF.DataBind();
     if (dt.Rows.Count < 1)
     {
       this.lblErrorMsg.Text = "No AR Types were loaded.";
     }
   }
   catch (Exception ex) {
     this.lblErrorMsg.Text = "Error when loading AR Type List: " + ex.Message;
   }
 }
Example #11
0
 protected void LoadSalesPersList()
 {
   try {
     InvoiceLib inv = new InvoiceLib();
     DataTable dt = inv.GetInvoiceSalesPersList(0, _UserID);
     this.lbxSalesPersonF.DataTextField = "FullName";
     this.lbxSalesPersonF.DataValueField = "SalesUID";
     this.lbxSalesPersonF.DataSource = dt;
     this.lbxSalesPersonF.DataBind();
     if (dt.Rows.Count < 1)
     {
       this.lblErrorMsg.Text = "No sales people were found when populating list.";
     }
   }
   catch (Exception ex) {
     this.lblErrorMsg.Text = "Error while loading sales person list: " + ex.Message;
   }
 }
 protected override GenericStateMachineEngine.ActionResult Create()
 {
     try
     {
         List <string> _errors = new List <string>();
         double?       _nq     = Parent.m_InvoiceQuantityTextBox.TextBox2Double(_errors);
         if (_errors.Count > 0)
         {
             return(ActionResult.NotValidated(_errors[0]));
         }
         if (_nq.HasValue && _nq.Value < 0)
         {
             return(ActionResult.NotValidated
                        (String.Format(Resources.NegativeValueNotAllowed.GetLocalizedString(), Parent.m_InvoiceQuantityLabel.Text)));
         }
         Batch      _batch = Parent.m_ControlState.Batch;
         InvoiceLib _invc  = Parent.m_ControlState.Invoice;
         if (!_batch.Available(_nq.Value))
         {
             string _tmplt = Resources.QuantityIsUnavailable.GetLocalizedString();
             return(ActionResult.NotValidated(String.Format(CultureInfo.CurrentCulture, _tmplt, _batch.AvailableQuantity())));
         }
         InvoiceContent _nic = new InvoiceContent()
         {
             InvoiceContent2BatchIndex = _batch,
             InvoiceIndex         = _invc,
             SKUDescription       = _batch.SKUIndex.Title,
             ProductType          = _batch.ProductType,
             Quantity             = _nq.Value,
             InvoiceContentStatus = InvoiceContentStatus.OK,
             Title = _batch.SKUIndex.Title,
             Units = _batch.ProductType.Value.Units()
         };
         Parent.m_DataContextManagement.DataContext.InvoiceContent.InsertOnSubmit(_nic);
         Parent.m_DataContextManagement.DataContext.SubmitChanges();
         _nic.CreateTitle();
         Parent.m_DataContextManagement.DataContext.SubmitChanges();
     }
     catch (Exception ex)
     {
         return(GenericStateMachineEngine.ActionResult.Exception(ex, "Create"));
     }
     return(GenericStateMachineEngine.ActionResult.Success);
 }
Example #13
0
        public string SelectVendorList(int PgID, int ObjID, string Seed, int Sort, int Min, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                InvoiceLib il = new InvoiceLib();
                DataTable  dt = il.SelectVendorList(Seed, Sort, Min, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "SelectVendorList", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Vendor List", 0, ByID, ex.Message, 0, "SelectVendorList function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
Example #14
0
        public string SelectInvoiceItems(int PgID, int ObjID, int ReqID, int InvoiceID, string SubDocType, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                InvoiceLib i  = new InvoiceLib();
                DataTable  dt = i.SelectInvoiceItems(ReqID, InvoiceID, SubDocType, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "SelectInvoiceItems", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Invoice Items", InvoiceID, ByID, ex.Message, 0, "SelectInvoiceItems function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
Example #15
0
        public string UpdateRequest(int PgID, int ObjID, int ReqID, string sDate, int ReqByID, int DispID, string Stat, int NbrComp, int Critical, int InvNbr, int OrdNbr, string Cmt, string EmailTo, string DocTypes,
                                    string DocTypeIDs, string RequiredOn, int Active, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                InvoiceLib inv = new InvoiceLib();
                DataTable  dt  = inv.UpdateRequest(ReqID, sDate, ReqByID, DispID, Stat, NbrComp, Critical, InvNbr, OrdNbr, Cmt, EmailTo, DocTypes, DocTypeIDs, RequiredOn, Active, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "UpdateRequest", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Upd Request", ReqID, ByID, ex.Message, 0, "UpdateRequest function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
Example #16
0
        public string SelectRequestDocsData(int PgID, int ObjID, int ReqID, int InvReqID, int ByID)
        {
            // Pulls list of doc types for one request ID
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                InvoiceLib i  = new InvoiceLib();
                DataTable  dt = i.SelectRequestDocsData(ReqID, InvReqID, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "SelectInvoiceRequestData", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("InvAdj Data", InvReqID, ByID, ex.Message, 0, "SelectInvoiceRequestData function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
Example #17
0
		protected void btnExportToPDF_Click(object sender, EventArgs e)
		{
			this.lblErrorMsg.Text = "";
			try
			{
				// handle filter parameters
				string artype = this.lbxARTypeF.SelectedValue;
				string branch = this.lbxBranchYardF.SelectedValue;
				string country = this.lbxCountryF.SelectedValue;
				string contr = this.lbxControllerF.SelectedValue;
				string creditgrp = this.lbxCreditGroupF.SelectedValue;
				string curr = this.ddlCurrencyF.SelectedValue;
				string cust = this.txtCustomerF.Text;
				string custnbr = this.txtCustNbrF.Text;
				string payterm = this.lbxPaymentTermsF.SelectedValue;
				string salesgrp = this.lbxSalesGroupF.SelectedValue;
				string salespers = this.lbxSalesPersonF.SelectedValue;
				string Src = this.ddlSourceTypeF.SelectedValue;
				int Threshold = Convert.ToInt32(this.ddlThresholdF.SelectedValue);
				string sBegin = this.txtBeginInvDateF.Text;
				DateTime? asofdate = null;
				DateTime? bdate = null;
				if (sBegin.Length > 0)
				{
					bdate = Convert.ToDateTime(sBegin);
				}

				// load aging data
				InvoiceLib inv = new InvoiceLib();
				DataTable dt = inv.SelectARAgingData("01", creditgrp, salespers, cust, custnbr, artype, salesgrp, contr, payterm, country, branch, curr, asofdate, Threshold, bdate, Src, 0, _UserID);
				if (dt.Rows.Count > 0)
				{
					string FileName = "AR_Aging_";
					DateTime now = DateTime.Now;
					FileName = FileName + now.ToString("MM_dd_yyyy");

					Document pdfDoc = new Document(PageSize.A4.Rotate(), 30, 30, 40, 25);
					System.IO.MemoryStream mStream = new System.IO.MemoryStream();
					PdfWriter writer = PdfWriter.GetInstance(pdfDoc, mStream);
					int cols = dt.Columns.Count;
					int rows = dt.Rows.Count;
					iTextSharp.text.Font font5 = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 5);
					pdfDoc.Open();

					PdfPTable pdfTable = new PdfPTable(cols);
					pdfTable.DefaultCell.BorderWidth = 1;
					pdfTable.WidthPercentage = 100;
					pdfTable.DefaultCell.Padding = 1;
					PdfPRow row = null;
					float[] widths = new float[] { 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f, 4f };
					pdfTable.SetWidths(widths);
					pdfTable.WidthPercentage = 100;

					string colname = "";
					string parag = "CAT Availability dated " + now.ToString("MM/dd/yyyy");
					PdfPCell Tcell = new PdfPCell(new Phrase(parag));
					Tcell.Colspan = dt.Columns.Count;
					Tcell.HorizontalAlignment = Element.ALIGN_CENTER;

					// Add header title
					pdfTable.AddCell(Tcell);
					PdfPCell cell;

					// Add column titles
					foreach (DataColumn c in dt.Columns)
					{
						pdfTable.AddCell(new Phrase(c.ColumnName, font5));
					}

					// Add all rows to table
					if (dt.Rows.Count > 0)
					{
						foreach (DataRow r in dt.Rows)
						{
							// Add Column by column for each row
							for (int i = 0; i < dt.Columns.Count; i++)
							{
								pdfTable.AddCell(new Phrase(r[i].ToString(), font5));
							}
						}
					}

					pdfDoc.Add(pdfTable);
					pdfDoc.Close();
					Response.ContentType = "application/octet-stream";
					Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ".pdf");
					Response.Clear();
					Response.BinaryWrite(mStream.ToArray());
					Response.End();
				}
				else
				{
					this.lblErrorMsg.Text = "No rows could be extracted that matched your filtering criteria.";
				}
			}
			catch (DocumentException de)
			{
				this.lblErrorMsg.Text = "Error while generating PDF: " + de.Message;
			}
			catch (IOException ioEx)
			{
				this.lblErrorMsg.Text = "Error while generating PDF: " + ioEx.Message;
			}
			catch (Exception ex)
			{
				this.lblErrorMsg.Text = "Error when exporting to PDF: " + ex.Message;
			}
		}
Example #18
0
		protected void btnExportToExcel_Click(object sender, EventArgs e)
		{
			try
			{
				string FileName = "AR_Aging_";
				DateTime now = DateTime.Now;
				FileName = FileName + now.ToString("MM_dd_yyyy");

				// handle filter parameters
				string artype = this.lbxARTypeF.SelectedValue;
				string branch = this.lbxBranchYardF.SelectedValue;
				string country = this.lbxCountryF.SelectedValue;
				string contr = this.lbxControllerF.SelectedValue;
				string creditgrp = this.lbxCreditGroupF.SelectedValue;
				string curr = this.ddlCurrencyF.SelectedValue;
				string cust = this.txtCustomerF.Text;
				string custnbr = this.txtCustNbrF.Text;
				string payterm = this.lbxPaymentTermsF.SelectedValue;
				string salesgrp = this.lbxSalesGroupF.SelectedValue;
				string salespers = this.lbxSalesPersonF.SelectedValue;
				string Src = this.ddlSourceTypeF.SelectedValue;
				int Threshold = Convert.ToInt32(this.ddlThresholdF.SelectedValue);
				string sBegin = this.txtBeginInvDateF.Text;
				DateTime? asofdate = null;
				DateTime? bdate = null;
				if (sBegin.Length > 0)
				{
					bdate = Convert.ToDateTime(sBegin);
				}

				// load aging data
				InvoiceLib inv = new InvoiceLib();
				DataTable dt = inv.SelectARAgingData("01", creditgrp, salespers, cust, custnbr, artype, salesgrp, contr, payterm, country, branch, curr, asofdate, Threshold, bdate, Src, 0, _UserID);
				if (dt.Rows.Count > 0 )
				{
					string tab = "";
					Response.Clear();
					Response.Buffer = true;
					Response.AddHeader("content-disposition", "attachment;filename=" + FileName + ".xls");
					Response.Charset = "";
					Response.ContentType = "application/vnd.ms-excel";
					foreach (DataColumn dc in dt.Columns)
					{
						Response.Write(tab + dc.ColumnName);
						tab = "\t";
					}
					Response.Write("\n");
					int i;
					foreach (DataRow dr in dt.Rows)
					{
						tab = "";
						for (i = 0; i < dt.Columns.Count; i++)
						{
							Response.Write(tab + dr[i].ToString());
							tab = "\t";
						}
						Response.Write("\n");
					}
					Response.Flush();
					Response.End();
				}
				else
				{
					this.lblErrorMsg.Text = "No rows could be extracted that matched your filtering criteria.";
				}
			}
			catch (Exception ex)
			{
				this.lblErrorMsg.Text = "Error when exporting to Excel: " + ex.Message;
			}
		}
Example #19
0
        private static bool GetXmlContent(InvoiceItemXml[] invoiceEntries, Entities edc, InvoiceLib parent)
        {
            List <InvoiceContent> _invcs    = new List <InvoiceContent>();
            ErrorsList            _warnings = new ErrorsList();
            bool _result = true;

            foreach (InvoiceItemXml item in invoiceEntries)
            {
                try
                {
                    InvoiceContent _ic = CreateInvoiceContent(edc, parent, item, _warnings);
                    if (_ic == null)
                    {
                        continue;
                    }
                    _invcs.Add(_ic);
                    _result &= _ic.InvoiceContentStatus.Value == InvoiceContentStatus.OK;
                    if (parent.BillDoc.IsNullOrEmpty())
                    {
                        parent.BillDoc             = item.Bill_doc.ToString();
                        parent.InvoiceCreationDate = item.Created_on;
                    }
                }
                catch (Exception ex)
                {
                    string _msg = "Cannot create new entry for the invoice No={0}/{1}, SKU={2}, because of error: {3}";
                    _warnings.Add(new Warnning(String.Format(_msg, item.Bill_doc, item.Item, item.Description, ex.Message), true));
                }
            }
            if (_warnings.Count > 0)
            {
                throw new InputDataValidationException("there are fatal errors in the XML message.", "GetBatchLookup", _warnings);
            }
            edc.InvoiceContent.InsertAllOnSubmit(_invcs);
            edc.SubmitChanges();
            foreach (InvoiceContent _ic in _invcs)
            {
                _ic.CreateTitle();
            }
            edc.SubmitChanges();
            return(_result);
        }
        internal static CigaretteExportFormCollection GetFormContent(Entities entities, InvoiceLib invoice, Clearence clearance, string documentName, int sadConsignmentNumber, NamedTraceLogger.TraceAction trace)
        {
            trace("Entering FinishedGoodsFormFactory.GetFormContent", 40, TraceSeverity.Verbose);
            int _position = 1;
            List <CigaretteExportForm> _consignment = new List <CigaretteExportForm>();

            invoice.ClearenceIndex         = clearance;
            invoice.InvoiceLibraryReadOnly = true;
            foreach (InvoiceContent item in invoice.InvoiceContent(entities))
            {
                ExportInvoiceEntry(entities, item, _consignment, documentName, ref _position, sadConsignmentNumber, trace);
            }
            trace("FinishedGoodsFormFactory.GetFormContent - finished processing invoice items", 40, TraceSeverity.Verbose);
            return(GetCigaretteExportFormCollection(_consignment, documentName, invoice.BillDoc));
        }
Example #21
0
    // ******************************************************************************

    protected void LoadAgingList(int LType)
    {
			string Msg = "Error loading data grid data: ";
			try
			{
				// handle filter parameters
				string artype = this.lbxARTypeF.SelectedValue;
				string branch = this.lbxBranchYardF.SelectedValue;
				string country = this.lbxCountryF.SelectedValue;
				string contr = this.lbxControllerF.SelectedValue;
				string creditgrp = this.lbxCreditGroupF.SelectedValue;
				string curr = this.ddlCurrencyF.SelectedValue;
				string cust = this.txtCustomerF.Text;
				string custnbr = this.txtCustNbrF.Text;
				string payterm = this.lbxPaymentTermsF.SelectedValue;
				string salesgrp = this.lbxSalesGroupF.SelectedValue;
				string salespers = this.lbxSalesPersonF.SelectedValue;
				string Src = this.ddlSourceTypeF.SelectedValue;
				int Threshold = Convert.ToInt32(this.ddlThresholdF.SelectedValue);
				string sBegin = this.txtBeginInvDateF.Text;
				DateTime? asofdate = null;
				DateTime? bdate = null;
				if (sBegin.Length > 0)
				{
					bdate = Convert.ToDateTime(sBegin);
				}

        ViewState["ARTypeF"] = artype;
        ViewState["BranchYardF"] = branch;
				ViewState["CountryF"] = country;
				ViewState["ControllerF"] = contr;
        ViewState["CreditGroupF"] = creditgrp;
        ViewState["CurrencyF"] = curr;
        ViewState["CustomerF"] = cust;
        ViewState["PayTermsF"] = payterm;
        ViewState["SalesGroupF"] = salesgrp;
        ViewState["SalesPersonF"] = salespers;
				ViewState["SourceTypeF"] = Src;
				ViewState["ThresholdF"] = Threshold.ToString();

        // reset to first page if necessary
        if (LType == 1)
        {
          _PgNbr = 0;
          ViewState["PgNbr"] = 0;
          gvInvoiceList.PageIndex = 0;
        }

				// load aging data
				InvoiceLib inv = new InvoiceLib();
				DataTable dt = new DataTable();
				dt = inv.SelectARAgingData("01", creditgrp, salespers, cust, custnbr, artype, salesgrp, contr, payterm, country, branch, curr, asofdate, Threshold, bdate, Src, 0, _UserID);
				//string Company, string CreditGrp, string SalesPers, string Cust, string ARType, string SalesGrp, string Controller, string PayTerms, string Country, string Branch, string Currency, DateTime? AsOfDate, string Src, int Sort, int ByI
				Msg = "Error binding data grid: ";
				this.gvInvoiceList.DataSource = dt;
				this.gvInvoiceList.DataBind();
				if (dt.Rows.Count < 1)
				{
					this.lblErrorMsg.Text = "No AR Aging data was returned that match all of the filters you have set.";
				}
			}
			catch (Exception ex)
      {
        this.lblErrorMsg.Text = Msg + ex.Message;
      }
		}