コード例 #1
0
        public static string RestoreOriginalValues()
        {
            System.Web.SessionState.HttpSessionState currentSession = HttpContext.Current.Session;

            string       retVal       = string.Empty;
            string       userID       = !string.IsNullOrEmpty(currentSession[vs_userID].ToString()) ? currentSession[vs_userID].ToString() : string.Empty;
            int?         preInvoiceID = (int?)currentSession[vs_preInvoiceID];
            eInvoiceType?invoiceType  = (eInvoiceType?)currentSession[vs_preInvoiceType];

            if (preInvoiceID != null && preInvoiceID > 0 && invoiceType != null && userID != string.Empty)
            {
                try
                {
                    Facade.IPalletForceImportPreInvoice facPFImport = new Facade.PreInvoice();
                    facPFImport.RestoreOriginalValues((int)preInvoiceID, (eInvoiceType)invoiceType, userID);
                }
                catch (Exception ex)
                {
                    retVal = RetrieveErrorMessages(ex);
                }
            }
            else
            {
                retVal = string.Format("{0}|{1}", 1, "There was an error retrieving the preinvoice details. Please reload the page and try again.");
            }

            ////Pause the app for 10 seconds.
            //DateTime dt = DateTime.Now.AddSeconds(10);
            //DateTime newdate = DateTime.Now;

            //do { newdate = DateTime.Now; }
            //while (newdate < dt);

            return(retVal);
        }
コード例 #2
0
        void gvBatches_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                int preInvoiceBatchID = int.Parse(gvBatches.MasterTableView.DataKeyValues[e.Item.ItemIndex][_preInvoiceBatchID].ToString());

                switch (e.CommandName.ToLower())
                {
                case "continuegroup":
                    HiddenField  hidInvoiceType = (HiddenField)e.Item.FindControl("hidInvoiceType");
                    eInvoiceType invoiceType    = (eInvoiceType)int.Parse(hidInvoiceType.Value);
                    if (invoiceType == eInvoiceType.ClientInvoicing)
                    {
                        Response.Redirect(string.Format("../groupage/autorunconfirmation.aspx?bid={0}", preInvoiceBatchID));
                    }
                    else if (invoiceType == eInvoiceType.SubContractorSelfBill)
                    {
                        Response.Redirect(string.Format("../subcontractorsb/autorunconfirmation.aspx?bid={0}", preInvoiceBatchID));
                    }
                    break;

                case "removegroup":
                    Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                    facPreInvoice.DeleteBatch(preInvoiceBatchID);
                    gvBatches.Rebind();
                    break;
                }
            }
        }
コード例 #3
0
        public static string ValidFileImport()
        {
            string retVal = string.Empty;

            System.Web.SessionState.HttpSessionState currentSession = HttpContext.Current.Session;

            if (currentSession[vs_pfImportedInvoice] != null)
            {
                #region Import File

                Entities.PalletForceImportedInvoice pfii = (Entities.PalletForceImportedInvoice)currentSession[vs_pfImportedInvoice];

                try
                {
                    Facade.IPalletForceImportPreInvoice facPFImport = new Facade.PreInvoice();
                    currentSession[vs_pfImportedInvoice] = facPFImport.ValidatePFImportedItems(pfii, currentSession[vs_userID].ToString());
                    retVal = bool.TrueString;
                }
                catch (Exception ex)
                {
                    #region File Removal on Error
                    retVal = FileRemovalOnError(currentSession[vs_uploadedFilePath].ToString(), ex);
                    #endregion
                }
                #endregion
            }

            return(retVal);
        }
コード例 #4
0
ファイル: MatchOrder.aspx.cs プロジェクト: norio-soft/proteo
        void btnMatchOrder_Click(object sender, EventArgs e)
        {
            int itemID = -1;

            int.TryParse(hdnItemID.Value, out itemID);

            if (this.ImportedInvoiceItemId == -1)
            {
                if (itemID > 0)
                {
                    Entities.PalletForceImportedInvoiceItem pfInvoiceItem = PFInvoice.PalletForceImportedInvoiceItems.SingleOrDefault(pfiii => pfiii.PalletForceImportedItemID == PFInvoiceItemID);

                    if (pfInvoiceItem != null)
                    {
                        pfInvoiceItem.OrderID = itemID;
                    }
                }

                Facade.IPalletForceImportPreInvoice facPFIPreInvoice = new Facade.PreInvoice();
                bool retVal = facPFIPreInvoice.UpdatePalletForcePreInvoiceItem(PFInvoice, PFInvoiceItemID, PreInvoiceID, ((Entities.CustomPrincipal)Page.User).UserName);

                if (retVal)
                {
                    this.ReturnValue = bool.TrueString;
                    this.Close();
                }
            }
            else
            if (itemID > 0)
            {
                // if this was called from the invoicingImport then we just want to return the importedInvoiceItemId and the ORder selected.
                this.ReturnValue = ImportedInvoiceItemId.ToString() + "," + itemID.ToString();
                this.Close();
            }
        }
コード例 #5
0
        private void ConfigureDisplay()
        {
            Facade.IPalletForceImportPreInvoice facPFPreInvoice = new Facade.PreInvoice();

            grdPalletForcePreInvoices.DataSource = facPFPreInvoice.GetAllImportedPreInvoices();
            grdPalletForcePreInvoices.DataBind();
        }
コード例 #6
0
 private List <Entities.SubContractorDataItem> LoadBatch()
 {
     using (Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice())
     {
         rdiInvoiceDate.SelectedDate = facPreInvoice.GetBatchInvoiceDate(BatchID);
         return(facPreInvoice.GetJobSubContractorsForBatch(BatchID));
     }
 }
コード例 #7
0
        private void LoadBatchSummary()
        {
            Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
            DataSet            ds            = facPreInvoice.GetSummaryForBatchForSubbySelfBill(BatchID);

            grdSubbies.DataSource = ds;

            lblInvoicedate.Text = facPreInvoice.GetBatchInvoiceDate(BatchID).ToString("dd/MM/yyyy");
        }
コード例 #8
0
        private void LoadBatchSummary()
        {
            Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
            DataSet            ds            = facPreInvoice.GetSummaryForBatch(BatchID);

            this.grdOrders.DataSource = ds;

            lblInvoicedate.Text = ((DateTime)ds.Tables[0].Rows[0]["InvoiceDate"]).ToString("dd/MM/yy");
        }
コード例 #9
0
        void btnCreateBatch_Click(object sender, EventArgs e)
        {
            if (grdSubbies.Items.Count > 0 && Page.IsValid)
            {
                string     jobSubConIdAndInvoiceNo = String.Empty;
                GridColumn invoiceColumn           = this.grdSubbies.Columns.FindByUniqueName("InvoiceNo");
                bool       byPassCheckbox          = false;

                if (invoiceColumn != null)
                {
                    byPassCheckbox = invoiceColumn.Display;
                }

                // Get the JobSubContractIDs that we are to Invoice
                List <int> jobSubContractIDs = new List <int>();
                foreach (GridItem row in grdSubbies.Items)
                {
                    TextBox txtInvoiceNo = (TextBox)row.FindControl("txtInvoiceNo");

                    if (row.Selected || byPassCheckbox)
                    {
                        int jobSubContractID = int.Parse(row.OwnerTableView.DataKeyValues[row.ItemIndex]["JobSubContractID"].ToString());

                        if (!String.IsNullOrEmpty(txtInvoiceNo.Text))
                        {
                            jobSubConIdAndInvoiceNo += jobSubContractID.ToString() + ":" + txtInvoiceNo.Text + ",";
                            jobSubContractIDs.Add(jobSubContractID);
                        }
                        else if (byPassCheckbox == false)
                        {
                            jobSubContractIDs.Add(jobSubContractID);
                        }
                    }
                }

                Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                if (IsUpdate())
                {
                    facPreInvoice.UpdateBatchForSubbySelfBill(BatchID, rdiInvoiceDate.SelectedDate.Value, jobSubContractIDs, this.Page.User.Identity.Name);
                }
                else
                {
                    BatchID = facPreInvoice.CreateBatchForSubbySelfBill(rdiInvoiceDate.SelectedDate.Value, jobSubContractIDs, this.Page.User.Identity.Name);
                }

                int batchID = BatchID;
                BatchID = -1;
                string url = "autorunconfirmation.aspx?bID=" + batchID.ToString();

                if (!String.IsNullOrEmpty(jobSubConIdAndInvoiceNo))
                {
                    url += "&InvoiceNumbers=" + jobSubConIdAndInvoiceNo;
                }

                Response.Redirect(url);
            }
        }
コード例 #10
0
        private DataSet LoadBatch()
        {
            int batchID = int.Parse(Request.QueryString["bID"]);

            Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
            DataSet            dsBatch       = facPreInvoice.GetOrdersForBatch(batchID);

            rdiInvoiceDate.SelectedDate = (DateTime)dsBatch.Tables[0].Rows[0]["InvoiceDate"];
            return(dsBatch);
        }
コード例 #11
0
        void gvPreInvoices_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
        {
            GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;

            if (parentItem.Edit)
            {
                return;
            }

            Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
            e.DetailTableView.DataSource = facPreInvoice.GetItemsForPreInvoice(int.Parse(parentItem.GetDataKeyValue("PreInvoiceID").ToString()));
        }
コード例 #12
0
        void btnRemove_Click(object sender, EventArgs e)
        {
            Facade.IPalletForceImportPreInvoice facPFImportPreInvoice = new Facade.PreInvoice();
            Entities.PalletForceImportedInvoice pfImportedInvoice     = facPFImportPreInvoice.GetImportedInvoiceForPreInvoiceID(PreInvoiceID);

            bool retVal = facPFImportPreInvoice.DeleteImportedPreInvoice(PreInvoiceID, pfImportedInvoice.Filename);

            if (retVal)
            {
                btnGeneric_Click(null, null);
            }
        }
コード例 #13
0
ファイル: MatchOrder.aspx.cs プロジェクト: norio-soft/proteo
        private void ConfigureDisplay()
        {
            string headerText = "Rate";

            if (this.PreInvoiceID > 0)
            {
                Facade.IPalletForceImportPreInvoice facPreInvoice = new Facade.PreInvoice();
                PFInvoice = facPreInvoice.GetImportedInvoiceForPreInvoiceID(PreInvoiceID, true);
                ItemIDs   = PFInvoice.GetOrdersOnInvoice();

                switch (PFInvoice.InvoiceType)
                {
                case eInvoiceType.PFDepotCharge:
                    headerText = "Sub Contract Rate";
                    break;

                case eInvoiceType.PFHubCharge:
                    headerText = "Hub Charge";
                    break;

                case eInvoiceType.PFSelfBillDeliveryPayment:
                    headerText = "Order Rate";
                    break;
                }

                if (consignmentNo != String.Empty)
                {
                    lblRefCaption.Text = "Consignment No";
                    lblRef.Text        = txtSearch.Text = consignmentNo;
                }
            }
            else
            if (LoadNo != String.Empty)
            {
                lblRefCaption.Text = "Load No";
                lblRef.Text        = txtSearch.Text = LoadNo;
            }

            grdOrders.Columns.FindByUniqueName("CurrentRate").HeaderText = headerText;

            dteStartDate.SelectedDate = new DateTime(DateTime.Today.Year, DateTime.Today.AddMonths(-1).Month, DateTime.Today.Day);
            dteEndDate.SelectedDate   = DateTime.Today;

            Facade.IBusinessType facBT = new Facade.BusinessType();
            cblBusinessType.DataSource = facBT.GetAll();
            cblBusinessType.DataBind();

            foreach (ListItem li in cblBusinessType.Items)
            {
                li.Selected = true;
            }
        }
コード例 #14
0
        private void RefreshPreInvoices()
        {
            Facade.IWorkflowPreInvoice facPreInvoice = new Facade.PreInvoice();
            this.DsPreInvoices = facPreInvoice.GetAllWithDetails();

            ReloadCreatedByFilters();

            gvPreInvoices.Rebind();
            //Facade.IWorkflowPreInvoice facPreInvoice = new Facade.PreInvoice();
            //this.DsPreInvoices = facPreInvoice.GetAllWithDetails();
            //this.gvPreInvoices.DataSource = this.DsPreInvoices;
            //this.gvPreInvoices.DataBind();
        }
コード例 #15
0
        protected void cboTaxRate_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList cboTaxRate = (DropDownList)sender;
            int          taxRateID  = 0;

            if (int.TryParse(cboTaxRate.SelectedValue, out taxRateID))
            {
                GridDataItem gdi          = (GridDataItem)cboTaxRate.Parent.Parent;
                int          preInvoiceID = 0;
                if (int.TryParse(gdi.GetDataKeyValue("PreInvoiceID").ToString(), out preInvoiceID))
                {
                    Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                    facPreInvoice.UpdateTaxRate(preInvoiceID, taxRateID, ((Entities.CustomPrincipal)Page.User).UserName);
                    gvPreInvoices.MasterTableView.Rebind();
                }
            }
        }
コード例 #16
0
        public static string CreatePalletForceInvoice()
        {
            System.Web.SessionState.HttpSessionState currentSession = HttpContext.Current.Session;

            string       retVal       = string.Empty;
            string       userID       = !string.IsNullOrEmpty(currentSession[vs_userID].ToString()) ? currentSession[vs_userID].ToString() : string.Empty;
            int          invoiceID    = -1;
            int?         preInvoiceID = (int?)currentSession[vs_preInvoiceID];
            eInvoiceType?invoiceType  = (eInvoiceType?)currentSession[vs_preInvoiceType];

            if (preInvoiceID.HasValue && preInvoiceID.Value > 0 && invoiceType != null && userID != string.Empty)
            {
                Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();

                List <int> preInvoiceIDs = new List <int>();
                preInvoiceIDs.Add(preInvoiceID.Value);

                List <Entities.PreInvoice> preInvoices = facPreInvoice.GetPreInvoices(preInvoiceIDs);

                if (preInvoices != null && preInvoices.Count > 0)
                {
                    try
                    {
                        Entities.PreInvoice currentPreInvoice = preInvoices[0];
                        invoiceID = facPreInvoice.CreateInvoice(currentPreInvoice, userID);

                        if (invoiceID > 0)
                        {
                            facPreInvoice.DeletePreInvoice(currentPreInvoice.PreInvoiceID);
                        }
                    }
                    catch (Exception ex)
                    {
                        retVal = RetrieveErrorMessages(ex);
                    }
                }
            }
            else
            {
                retVal = string.Format("{0}|{1}", 1, "There was an error retrieving the preinvoice details. Please reload the page and try again.");
            }

            return(retVal);
        }
コード例 #17
0
        private void ConfigureDisplay()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["pfID"]))
            {
                PreInvoiceID = int.Parse(Request.QueryString["pfID"]);
            }

            if (PreInvoiceID > 0)
            {
                Facade.IPalletForceImportPreInvoice facPFiii = new Facade.PreInvoice();
                Facade.IPreInvoice facPreInvoice             = new Facade.PreInvoice();

                Entities.PalletForceImportedInvoice pfImportedInvoice = facPFiii.GetImportedInvoiceForPreInvoiceID(PreInvoiceID);
                Entities.PreInvoice preInvoice = facPreInvoice.GetPreInvoice(PreInvoiceID);

                preInvoiceDate = pfImportedInvoice.InvoiceDate;
                preInvoiceNo   = pfImportedInvoice.InvoiceNo;
                preInvoiceType = pfImportedInvoice.InvoiceType;

                lblSystemItemTotal.Text = preInvoice.NetAmount.ToString("C", ci);

                UploadedFileExtension = Path.GetExtension(pfImportedInvoice.Filename);
                UploadedFileName      = Path.GetFileName(pfImportedInvoice.Filename);
                UploadedFilePath      = pfImportedInvoice.Filename;

                UploadedFileDetails.Style["display"] = "";
                UploadInvoiceFile.Style["display"]   = "none";
            }

            DisplayFileDetails();

            RebindGrid();
            UserID = ((Entities.CustomPrincipal)Page.User).UserName;

            // Define button visibilty.
            // If the pre-invoice has been created allow removal.
            btnRemove.Visible = btnRemove1.Visible = PreInvoiceID > 0;
            // If the pre-invoice has been created and all items are matched, allow creation.
            btnApprove.Visible = btnApprove1.Visible = PreInvoiceID > 0 && UnMatchedItems == 0;
        }
コード例 #18
0
        public static string CreatePalletForcePreInvoice()
        {
            int    preInvoiceID = -1;
            string retVal       = string.Empty;

            System.Web.SessionState.HttpSessionState currentSession = HttpContext.Current.Session;

            //Check to see if the file already exists.
            Facade.IPalletForceImportPreInvoice facPFImport = new Facade.PreInvoice();
            string uploadedFilePath = currentSession[vs_uploadedFilePath].ToString();

            if (currentSession[vs_pfImportedInvoice] != null)
            {
                #region Import File

                Entities.PalletForceImportedInvoice pfii = (Entities.PalletForceImportedInvoice)currentSession[vs_pfImportedInvoice];

                try
                {
                    preInvoiceID = facPFImport.CreatePalletForcePreInvoice(pfii, uploadedFilePath, currentSession[vs_userID].ToString());
                    retVal       = preInvoiceID.ToString();
                }
                catch (Exception ex)
                {
                    #region File Removal on Error
                    retVal = FileRemovalOnError(uploadedFilePath, ex);
                    #endregion
                }
                finally
                {
                    currentSession[vs_preInvoiceID] = preInvoiceID;
                }

                #endregion
            }

            return(retVal);
        }
コード例 #19
0
        private void RebindGrid()
        {
            // A function to return the value of difference amount from the group of orders found.
            Func <IEnumerable <DataRow>, decimal?> getImportedItemDifferenceAmount = drs =>
                                                                                     drs.Any(dr => dr.Field <int?>("PFInvoiceItemID").HasValue) ? drs.First(dr => dr.Field <int?>("PFInvoiceItemID").HasValue).Field <decimal?>("DifferenceAmount").Value : (decimal?)null;

            // Get Counts of Invoice Items
            Func <IEnumerable <DataRow>, int?> getImportedItemCount = drs => drs.Where(dr => dr.Field <int?>("PFInvoiceItemID").HasValue).Count();

            // Get Invoice Totals
            //Func<IEnumerable<DataRow>, decimal?> getImportedItemValue = drs => drs.Where(dr => dr.Field<int?>("OrderID").HasValue).Sum(dr => dr.Field<decimal?>("Cost").Value);
            Func <IEnumerable <DataRow>, decimal?> getDifferenceItemValue = drs => drs.Where(dr => dr.Field <int?>("PFInvoiceItemID").HasValue).Sum(dr => dr.Field <decimal?>("DifferenceAmount").Value);

            Facade.IPalletForceImportPreInvoice facPFPreInvoice = new Facade.PreInvoice();
            DataSet ds = null;

            switch (preInvoiceType)
            {
            case eInvoiceType.PFDepotCharge:
                ds = facPFPreInvoice.GetImportedDepotChargePreInvoice(PreInvoiceID);
                break;

            case eInvoiceType.PFHubCharge:
                ds = facPFPreInvoice.GetImportedHubChargePreInvoice(PreInvoiceID);
                break;

            case eInvoiceType.PFSelfBillDeliveryPayment:
                ds = facPFPreInvoice.GetImportedSelfBillDeliveryPreInvoice(PreInvoiceID);
                break;
            }

            if (ds != null)
            {
                int?unMatchedItems    = 0;
                var queryInvoiceItems = ds.Tables[0].Rows.Cast <DataRow>().AsEnumerable();
                var resultRows        = from row in queryInvoiceItems
                                        group row by row["OrderID"] into g
                                        select new
                {
                    OrderID          = g.Key,
                    DifferenceAmount = getImportedItemDifferenceAmount(g),
                    OrderCount       = g.Count(),
                    Items            = g
                };

                lvPreInvoiceItems.DataSource = resultRows;
                lvPreInvoiceItems.DataBind();

                // Get any unmatched palletforce invoice items.
                if (ds.Tables.Count > 1)
                {
                    var queryUnmatchedItems = ds.Tables[1].Rows.Cast <DataRow>().AsEnumerable();
                    lvPreInvoiceUnMatchedItems.DataSource = queryUnmatchedItems;
                    lvPreInvoiceUnMatchedItems.DataBind();

                    unMatchedItems = queryUnmatchedItems.Count();
                }

                lblInvoiceItems.Text = getImportedItemCount(queryInvoiceItems).Value.ToString();
                lblMatchedItems.Text = unMatchedItems.Value.ToString();

                if (unMatchedItems.HasValue && unMatchedItems.Value > 0)
                {
                    lblMatchedItems.ForeColor = System.Drawing.Color.Red;
                    UnMatchedItems            = unMatchedItems.Value;
                    lblUnMatchedItems.Text    = unMatchedItems.Value.ToString();
                }
                else
                {
                    lblMatchedItems.ForeColor = System.Drawing.Color.Black;
                    lblUnMatchedItems.Text    = "0";
                }

                //lblSystemItemTotal.Text = getImportedItemValue(queryInvoiceItems).Value.ToString("C", ci);
                lblDifferenceValue.Text = getDifferenceItemValue(queryInvoiceItems).Value.ToString("C", ci);
            }
        }
コード例 #20
0
 void gvGroups_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     Facade.IWorkflowPreInvoice facPreInvoice = new Facade.PreInvoice();
     gvGroups.DataSource = facPreInvoice.GetAll();
 }
コード例 #21
0
        public static string ImportFile(string fileName)
        {
            string       retVal           = string.Empty;
            string       uploadedFilePath = string.Empty;
            eInvoiceType invoiceType;

            System.Web.SessionState.HttpSessionState currentSession = HttpContext.Current.Session;

            //Replace with system defined regular expression
            if (fileName.ToLower().Contains("hubinv"))
            {
                invoiceType = eInvoiceType.PFHubCharge;
            }
            else if (fileName.ToLower().Contains("chargeinv"))
            {
                invoiceType = eInvoiceType.PFDepotCharge;
            }
            else
            {
                invoiceType = eInvoiceType.PFSelfBillDeliveryPayment;
            }

            //Check to see if the file already exists.
            Facade.IPalletForceImportPreInvoice facPFImport = new Facade.PreInvoice();
            bool fileAlreadyImported = facPFImport.CheckImportedFiles(fileName);

            if (currentSession[vs_uploadedFilePath] != null && currentSession[vs_userID] != null && !fileAlreadyImported)
            {
                #region Import File

                uploadedFilePath = currentSession[vs_uploadedFilePath].ToString();

                if (File.Exists(uploadedFilePath))
                {
                    try
                    {
                        currentSession[vs_pfImportedInvoice] = facPFImport.ImportPalletForceInvoice(uploadedFilePath, invoiceType, currentSession[vs_userID].ToString());
                        retVal = bool.TrueString;
                    }
                    catch (Exception ex)
                    {
                        #region File Removal on Error
                        retVal = FileRemovalOnError(uploadedFilePath, ex);
                        #endregion
                    }
                }
                else
                {
                    retVal = string.Format("{0}|{1}", 4, -1);
                }

                #endregion
            }
            else
            {
                #region Remove and send Error Message

                if (currentSession[vs_uploadedFilePath] != null)
                {
                    try
                    {
                        File.Delete(currentSession[vs_uploadedFilePath].ToString());
                    }
                    catch (Exception ex) { }
                    finally
                    {
                        retVal = fileAlreadyImported ?  string.Format("{0}|{1}", 3, -1) : string.Format("{0}|{1}", 2, -1);
                    }
                }
                else
                {
                    retVal = string.Format("{0}|{1}", 2, -1);
                }

                StaticResetSessionVaribles(currentSession);

                #endregion
            }

            return(retVal.ToString());
        }
コード例 #22
0
 private void SetUseHeadedPaperParameter(int preInvoiceID, bool useHeadedPaper)
 {
     Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
     facPreInvoice.UpdateUseHeadedPaper(preInvoiceID, useHeadedPaper, ((Entities.CustomPrincipal)Page.User).UserName);
 }
コード例 #23
0
 void gvPreInvoices_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     Facade.IWorkflowPreInvoice facWorkflowPreInvoice = new Facade.PreInvoice();
     gvPreInvoices.DataSource = facWorkflowPreInvoice.GetForWorkflowInstanceID(WorkflowInstanceID);
 }
コード例 #24
0
        void gvPreInvoices_ItemCommand(object source, GridCommandEventArgs e)
        {
            string userName = ((Entities.CustomPrincipal)Page.User).UserName;

            switch (e.CommandName.ToLower())
            {
                #region Client Reference Editing

            case "cancelclientreference":
                e.Item.Edit = false;
                gvPreInvoices.Rebind();
                break;

            case "editclientreference":
                e.Item.Edit = true;
                gvPreInvoices.Rebind();
                break;

            case "editpurchaseorderreference":
                e.Item.Edit = true;
                gvPreInvoices.Rebind();
                break;

            case "updateclientreference":
                e.Item.Edit = false;
                string clientReference = string.Empty;

                LinkButton lnkChangeClientReference = e.Item.FindControl("lnkChangeClientReference") as LinkButton;
                TextBox    txtClientReference       = e.Item.FindControl("txtClientReference") as TextBox;

                if (lnkChangeClientReference != null && txtClientReference != null)
                {
                    string oldClientReference = lnkChangeClientReference.Text;
                    clientReference = txtClientReference.Text;

                    // Only apply the change if the client reference has been altered
                    if (oldClientReference != clientReference)
                    {
                        // Update the client reference
                        int preInvoiceID = int.Parse(((GridDataItem)e.Item).GetDataKeyValue("PreInvoiceID").ToString());
                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                        facPreInvoice.UpdateClientInvoiceReference(preInvoiceID, clientReference, userName);
                    }
                }
                gvPreInvoices.Rebind();
                break;

            case "updatepurchaseorderreference":
                e.Item.Edit = false;
                string purchaseOrderReference = string.Empty;

                LinkButton lnkChangePurchaseOrderReference = e.Item.FindControl("lnkChangePurchaseOrderReference") as LinkButton;
                TextBox    txtPurchaseOrderReference       = e.Item.FindControl("txtPurchaseOrderReference") as TextBox;

                if (lnkChangePurchaseOrderReference != null && txtPurchaseOrderReference != null)
                {
                    string oldPurchaseOrderReference = lnkChangePurchaseOrderReference.Text;
                    purchaseOrderReference = txtPurchaseOrderReference.Text;

                    // Only apply the change if the client reference has been altered
                    if (oldPurchaseOrderReference != purchaseOrderReference)
                    {
                        // Update the client reference
                        int preInvoiceID = int.Parse(((GridDataItem)e.Item).GetDataKeyValue("PreInvoiceID").ToString());
                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                        facPreInvoice.UpdatePurchaseOrderReference(preInvoiceID, purchaseOrderReference, userName);
                    }
                }
                gvPreInvoices.Rebind();
                break;

                #endregion

                #region Rate Editing

            //case "cancelrate":
            //    e.Item.Edit = false;
            //    e.Item.OwnerTableView.Rebind();
            //    gvPreInvoices.MasterTableView.Rebind();
            //    StayOpen = e.Item.OwnerTableView.ParentItem.ItemIndex;
            //    break;
            //case "editrate":
            //    e.Item.Edit = true;
            //    e.Item.OwnerTableView.Rebind();
            //    gvPreInvoices.MasterTableView.Rebind();
            //    StayOpen = e.Item.OwnerTableView.ParentItem.ItemIndex;
            //    break;
            case "update":     // update rate and pallet spaces.
                e.Item.Edit = false;
                decimal rate = 0;

                //LinkButton lnkChangeRate = e.Item.FindControl("lnkChangeRate") as LinkButton;
                HiddenField  hidOldRate = e.Item.FindControl("hidOldRate") as HiddenField;
                TextBox      txtRate    = e.Item.FindControl("txtRate") as TextBox;
                GridDataItem parentItem = e.Item.OwnerTableView.ParentItem;

                int         lcid = int.Parse(parentItem.GetDataKeyValue("LCID").ToString());
                CultureInfo preInvoiceCulture = new CultureInfo(lcid);

                if (Decimal.TryParse(txtRate.Text, System.Globalization.NumberStyles.Currency, preInvoiceCulture, out rate))
                {
                    decimal oldRate = 0;
                    oldRate = decimal.Parse(hidOldRate.Value);

                    // Only apply the rate change if the rate has altered.
                    if (oldRate != rate)
                    {
                        int itemID = int.Parse(txtRate.Attributes["ItemID"]);

                        // Update the rate (depends on item type - depends on invoice type)
                        int          preInvoiceID = int.Parse(parentItem.GetDataKeyValue("PreInvoiceID").ToString());
                        eInvoiceType invoiceType  = (eInvoiceType)int.Parse(parentItem.GetDataKeyValue("InvoiceTypeID").ToString());
                        CultureInfo  culture      = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

                        Facade.IPreInvoice    facPreInvoice = new Facade.PreInvoice();
                        Facade.IExchangeRates facER         = new Facade.ExchangeRates();

                        switch (invoiceType)
                        {
                        case eInvoiceType.ClientInvoicing:
                            Facade.IOrder  facOrder = new Facade.Order();
                            Entities.Order order    = facOrder.GetForOrderID(itemID);
                            order.ForeignRate = rate;

                            if (order.LCID != culture.LCID)
                            {
                                BusinessLogicLayer.IExchangeRates    blER = new BusinessLogicLayer.ExchangeRates();
                                BusinessLogicLayer.CurrencyConverter currencyConverter = blER.CreateCurrencyConverter(order.LCID, order.CollectionDateTime);
                                order.Rate = currencyConverter.ConvertToLocal(order.ForeignRate);
                            }
                            else
                            {
                                order.Rate = decimal.Round(order.ForeignRate, 4, MidpointRounding.AwayFromZero);
                            }

                            //if (order.OrderGroupID > 0)
                            //facPreInvoice.UpdateOrderGroupRate(preInvoiceID, order.OrderGroupID, order.ForeignRate, order.Rate, userName);
                            //else

                            facPreInvoice.UpdateOrderRate(preInvoiceID, itemID, order.ForeignRate, order.Rate, userName);

                            break;

                        case eInvoiceType.SubContractorSelfBill:
                        case eInvoiceType.SubContract:
                            // Needs to be Amended For Currency : TL 12/05/08;
                            Facade.IJobSubContractor  facJSC           = new Facade.Job();
                            Entities.JobSubContractor jobSubContractor = facJSC.GetSubContractorForJobSubContractId(itemID);
                            jobSubContractor.ForeignRate = rate;

                            if (jobSubContractor.LCID != culture.LCID)
                            {
                                jobSubContractor.Rate = facER.GetConvertedRate((int)jobSubContractor.ExchangeRateID, jobSubContractor.ForeignRate);
                            }
                            else
                            {
                                jobSubContractor.Rate = decimal.Round(jobSubContractor.ForeignRate, 4, MidpointRounding.AwayFromZero);
                            }

                            facPreInvoice.UpdateJobSubContractRate(preInvoiceID, itemID, jobSubContractor.ForeignRate, jobSubContractor.Rate, jobSubContractor.ExchangeRateID, userName);
                            break;

                        default:
                            throw new NotSupportedException("You can not alter item rates on invoices of type " + invoiceType.ToString());
                        }

                        this.lblSavedMessage.Text = string.Format("Your changes were saved at {0}", DateTime.Now.ToLongTimeString());
                    }
                }

                e.Item.OwnerTableView.Rebind();
                gvPreInvoices.MasterTableView.Rebind();
                StayOpen = parentItem.ItemIndex;
                break;

                #endregion
            }
        }
コード例 #25
0
        private void SaveBatchChanges()
        {
            string userName = ((Entities.CustomPrincipal)Page.User).UserName;

            // React to the user's options.
            foreach (GridDataItem row in gvPreInvoices.Items)
            {
                string tableName    = row.OwnerTableView.Name;
                int    preInvoiceId = -1;
                int.TryParse(row.GetDataKeyValue("PreInvoiceID").ToString(), out preInvoiceId);

                if (tableName == PreInvoiceTableName && (row.ItemType == GridItemType.Item || row.ItemType == GridItemType.AlternatingItem))
                {
                    HiddenField hidIsDirty = row.FindControl("hidIsDirty") as HiddenField;
                    bool        isDirty    = false;

                    if (bool.TryParse(hidIsDirty.Value, out isDirty) && isDirty)
                    {
                        #region Update PreInvoice
                        DateTime?invoiceDate = null;
                        string   clientReference = string.Empty, purchaseOrderReference = string.Empty;
                        int      taxRateID = -1;

                        RadDateInput rdiInvoiceDate = row.FindControl("rdiInvoiceDate") as RadDateInput;

                        RadTextBox rtClientReference        = row.FindControl("rtClientReference") as RadTextBox;
                        RadTextBox rtPurchaseOrderReference = row.FindControl("rtPurchaseOrderReference") as RadTextBox;

                        DropDownList cboTaxRate = row.FindControl("cboTaxRate") as DropDownList;

                        if (rdiInvoiceDate.SelectedDate.HasValue)
                        {
                            invoiceDate = rdiInvoiceDate.SelectedDate.Value;
                        }

                        clientReference        = rtClientReference.Text;
                        purchaseOrderReference = rtPurchaseOrderReference.Text;

                        int.TryParse(cboTaxRate.SelectedValue, out taxRateID);

                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                        facPreInvoice.UpdatePreinvoiceDetails(preInvoiceId, invoiceDate, clientReference, purchaseOrderReference, taxRateID, userName);
                        #endregion
                    }
                }
                else if (tableName == PreInvoiceItemTableName && (row.ItemType == GridItemType.Item || row.ItemType == GridItemType.AlternatingItem))
                {
                    HiddenField hidInvoiceItemIsDirty = row.FindControl("hidInvoiceItemIsDirty") as HiddenField;
                    bool        isDirty = false;

                    HiddenField hidInvoiceItemPendingDelete = row.FindControl("hidInvoiceItemPendingDelete") as HiddenField;
                    bool        isPendingDelete             = false;

                    if (bool.TryParse(hidInvoiceItemPendingDelete.Value, out isPendingDelete) && isPendingDelete)
                    {
                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();

                        TextBox      txtRate    = row.FindControl("txtRate") as TextBox;
                        GridDataItem parentItem = row.OwnerTableView.ParentItem;

                        int itemID = int.Parse(txtRate.Attributes["ItemID"]);

                        // Update the rate (depends on item type - depends on invoice type)
                        int preInvoiceID = int.Parse(parentItem.GetDataKeyValue("PreInvoiceID").ToString());

                        facPreInvoice.RemovePreInvoiceOrder(preInvoiceID, itemID);
                    }

                    else if (bool.TryParse(hidInvoiceItemIsDirty.Value, out isDirty) && isDirty)
                    {
                        #region Pre Invoice Item

                        decimal      rate       = 0;
                        HiddenField  hidOldRate = row.FindControl("hidOldRate") as HiddenField;
                        TextBox      txtRate    = row.FindControl("txtRate") as TextBox;
                        GridDataItem parentItem = row.OwnerTableView.ParentItem;

                        int         lcid = int.Parse(parentItem.GetDataKeyValue("LCID").ToString());
                        CultureInfo preInvoiceCulture = new CultureInfo(lcid);

                        if (Decimal.TryParse(txtRate.Text, System.Globalization.NumberStyles.Currency, preInvoiceCulture, out rate))
                        {
                            //decimal oldRate = 0;
                            //oldRate = decimal.Parse(hidOldRate.Value);

                            // Only apply the rate change if the rate has altered.
                            //if (oldRate != rate)
                            if (hidOldRate.Value != txtRate.Text)
                            {
                                int itemID = int.Parse(txtRate.Attributes["ItemID"]);

                                // Update the rate (depends on item type - depends on invoice type)
                                int          preInvoiceID = int.Parse(parentItem.GetDataKeyValue("PreInvoiceID").ToString());
                                eInvoiceType invoiceType  = (eInvoiceType)int.Parse(parentItem.GetDataKeyValue("InvoiceTypeID").ToString());
                                CultureInfo  culture      = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

                                Facade.IPreInvoice    facPreInvoice = new Facade.PreInvoice();
                                Facade.IExchangeRates facER         = new Facade.ExchangeRates();

                                switch (invoiceType)
                                {
                                case eInvoiceType.ClientInvoicing:
                                    #region Client Invoice

                                    Facade.IOrder  facOrder = new Facade.Order();
                                    Entities.Order order    = facOrder.GetForOrderID(itemID);
                                    order.ForeignRate = rate;

                                    if (order.LCID != culture.LCID)
                                    {
                                        BusinessLogicLayer.IExchangeRates    blER = new BusinessLogicLayer.ExchangeRates();
                                        BusinessLogicLayer.CurrencyConverter currencyConverter = blER.CreateCurrencyConverter(order.LCID, order.CollectionDateTime);
                                        order.Rate = currencyConverter.ConvertToLocal(order.ForeignRate);
                                    }
                                    else
                                    {
                                        order.Rate = decimal.Round(order.ForeignRate, 4, MidpointRounding.AwayFromZero);
                                    }

                                    facPreInvoice.UpdateOrderRate(preInvoiceID, itemID, order.ForeignRate, order.Rate, userName);

                                    #endregion
                                    break;

                                case eInvoiceType.SubContractorSelfBill:
                                case eInvoiceType.SubContract:
                                    #region Subby Invoicing
                                    // Needs to be Amended For Currency : TL 12/05/08;
                                    Facade.IJobSubContractor  facJSC           = new Facade.Job();
                                    Entities.JobSubContractor jobSubContractor = facJSC.GetSubContractorForJobSubContractId(itemID);
                                    jobSubContractor.ForeignRate = rate;

                                    if (jobSubContractor.LCID != culture.LCID)
                                    {
                                        jobSubContractor.Rate = facER.GetConvertedRate((int)jobSubContractor.ExchangeRateID, jobSubContractor.ForeignRate);
                                    }
                                    else
                                    {
                                        jobSubContractor.Rate = decimal.Round(jobSubContractor.ForeignRate, 4, MidpointRounding.AwayFromZero);
                                    }

                                    facPreInvoice.UpdateJobSubContractRate(preInvoiceID, itemID, jobSubContractor.ForeignRate, jobSubContractor.Rate, jobSubContractor.ExchangeRateID, userName);
                                    #endregion
                                    break;

                                default:
                                    throw new NotSupportedException("You can not alter item rates on invoices of type " + invoiceType.ToString());
                                }
                            }
                        }

                        #endregion
                    }
                }
            }
        }
コード例 #26
0
 void gvBatches_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
     gvBatches.DataSource = facPreInvoice.GetStalledBatches();
 }