Exemple #1
0
        private void SaveAdjustmentModel()
        {
            DateTime todaydate      = DateTime.Now;
            DateTime dtSuppliedDate = DateTime.Parse(txtCreInvoiceDate.Text);
            DateTime dtJob          = DateTime.Parse(lblJobDate.Text);
            DateTime dtRef          = DateTime.Parse(txtReferenceDate.Text);


            if (dtSuppliedDate < dtJob)
            {
                lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00093");
                return;
            }

            var data = ExtractData();

            if (Mode == "A")
            {
                hdnLastNo.Value = new CreditorInvoiceBLL().SaveCreditorInvoice(data, Mode).ToString();
            }
            else
            {
                hdnLastNo.Value = new CreditorInvoiceBLL().SaveCreditorInvoice(data, Mode).ToString();
                hdnLastNo.Value = CreInvoiceId.ToString();
            }
            //if (result > 0)
            //{
            if (hdnLastNo.Value.ToInt() > 0)
            {
                ModalPopupExtender1.Show();
                //string encryptedId = GeneralFunctions.EncryptQueryString(ViewState["jobId"].ToString());
                //Response.Redirect("~/Forwarding/Transaction/Dashboard.aspx?JobId=" + encryptedId);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), DateTime.Now.Ticks.ToString(), "alert('Error Occured');", true);
            }
        }
Exemple #2
0
        private void LoadDefault()
        {
            var    creInvoiceId = string.Empty;
            string EstimateId   = "";

            if (_roleId == (int)UserRole.fuser)
            {
                trApproval.Visible = false;
            }

            rdoPayment_SelectedIndexChanged(null, null);
            if (!ReferenceEquals(Request.QueryString["CreInvoiceId"], null))
            {
                creInvoiceId    = GeneralFunctions.DecryptQueryString(Request.QueryString["CreInvoiceId"].ToString());
                ViewState["Id"] = creInvoiceId;
            }
            else
            {
                ViewState["Id"] = null;
            }

            if (!ReferenceEquals(Request.QueryString["JobNo"], null))
            {
                lblJobNumber.Text = GeneralFunctions.DecryptQueryString(Request.QueryString["JobNo"].ToString());
            }
            //creInvoiceId = Request.QueryString["CreInvoiceId"];

            string jobId = "";

            txtReferenceDate.Text = DateTime.Now.GetDateTimeFormats('d')[0];
            if (!ReferenceEquals(Request.QueryString["JobID"], null))
            {
                jobId = GeneralFunctions.DecryptQueryString(Request.QueryString["JobID"].ToString());
            }
            JobID = jobId;
            GetJobAndSetValue(jobId);

            ViewState["JobID"] = jobId;

            //GetPartyValuesSetToDdl();
            GetPartyTypes();
            chkRoff.Checked    = false;
            txtRoff.Enabled    = false;
            txtRoff.Text       = "";
            rfvComment.Enabled = false;

            if (!string.IsNullOrEmpty(creInvoiceId))
            {
                var creditorInvoice = new CreditorInvoiceBLL().GetCreditorInvoice(new SearchCriteria {
                    StringOption1 = CreInvoiceId.ToString()
                }).FirstOrDefault();
                var temp = new List <CreditorInvoiceCharge>();

                if (creditorInvoice != null)
                {
                    if (creditorInvoice.CreditorInvoiceCharges != null)
                    {
                        DataSet ds = new DataSet();
                        if (ViewState["ddlCharges"] == null)
                        {
                            ds = new EstimateBLL().GetCharges((ISearchCriteria)null);
                            ViewState["ddlCharges"] = ds;
                        }
                        else
                        {
                            ds = (DataSet)ViewState["ddlCharges"];
                        }

                        DataSet dllCds = new DataSet();
                        if (ViewState["ddlCurrency"] == null)
                        {
                            dllCds = new EstimateBLL().GetCurrency((ISearchCriteria)null);
                            ViewState["ddlCurrency"] = dllCds;
                        }
                        else
                        {
                            dllCds = (DataSet)ViewState["ddlCurrency"];
                        }

                        DataSet dllUs = new DataSet();
                        if (ViewState["dllUs"] == null)
                        {
                            dllUs = new EstimateBLL().GetUnitMaster(new SearchCriteria {
                                StringOption1 = companyId, StringOption2 = "", SortExpression = "UnitName"
                            });
                            ViewState["ddlUnitType"] = dllUs;
                        }
                        else
                        {
                            dllUs = (DataSet)ViewState["ddlUnitType"];
                        }

                        foreach (var obj in creditorInvoice.CreditorInvoiceCharges)
                        {
                            DataRow t = ds.Tables[0].AsEnumerable().Where(x => x["ChargeId"].ToString() == obj.ChargeId.ToString()).FirstOrDefault();
                            obj.ChargeName = t["ChargeName"].ToString();
                            DataRow t1 = dllCds.Tables[0].AsEnumerable().Where(x => x["pk_CurrencyID"].ToString() == obj.CurrencyId.ToString()).FirstOrDefault();
                            obj.Currency = t1["CurrencyName"].ToString();
                            DataRow t2 = dllUs.Tables[0].AsEnumerable().Where(x => x["pk_UnitTypeID"].ToString() == obj.UnitTypeID.ToString()).FirstOrDefault();
                            obj.UnitType = t2["UnitName"].ToString();
                            try { obj.Total = obj.Rate * obj.Unit; }
                            catch { obj.Total = 0; }
                        }
                        temp = creditorInvoice.CreditorInvoiceCharges;
                        creditorInvoice.InvoiceAmount = creditorInvoice.CreditorInvoiceCharges.Sum(x => x.GTotal);
                    }

                    ViewState["Charges"] = temp;
                    ddlCreditorName.Items.Clear();
                    ddlPartyType.SelectedValue = creditorInvoice.PartyTypeID.ToString();
                    GetPartyValuesSetToDdl(ddlPartyType.SelectedValue.ToInt());
                    //ddlCreditorName.Items.Add(new ListItem("--Select--", "0"));
                    //ddlCreditorName.Items.Add(new ListItem(creditorInvoice.CreditorName, creditorInvoice.CreditorId.ToString()));

                    ddlCreditorName.SelectedValue = creditorInvoice.CreditorId.ToString();


                    txtCreInvoiceDate.Text = creditorInvoice.CreInvoiceDate.Value.ToShortDateString();
                    txtCreInvoiceNo.Text   = creditorInvoice.CreInvoiceNo;
                    txtReferenceDate.Text  = creditorInvoice.ReferenceDate.Value.ToShortDateString();
                    //lblHouseBLDate.Text      = creditorInvoice.HouseBLDate.Value.ToShortDateString();
                    //lblHouseBLNo.Text        = creditorInvoice.HouseBLNo;
                    lblInvoiceAmount.Text  = creditorInvoice.InvoiceAmount.ToString();
                    hdnInvoiceAmount.Value = creditorInvoice.InvoiceAmount.ToString();
                    txtRoff.Text           = creditorInvoice.RoundingOff.ToString();
                    if (creditorInvoice.RoundingOff == 0)
                    {
                        chkRoff.Checked = false;
                    }
                    else
                    {
                        chkRoff.Checked = true;
                    }
                    rdbApproval.SelectedValue = creditorInvoice.approved.ToString();

                    if (creditorInvoice.approved.ToInt() == 0)
                    {
                        txtComment.Text = "";
                    }
                    else
                    {
                        txtComment.Text = creditorInvoice.comment;
                    }

                    //if (!string.IsNullOrEmpty(creditorInvoice.approved.ToString()))
                    //{
                    //    rdbApproval.Items.FindByValue(creditorInvoice.approved.ToString().ToLower() == "Approve" ? "1" : "0").Selected = true;
                    //    txtComment.Text = creditorInvoice.comment;
                    //}
                    //else
                    //    txtComment.Text = "";

                    lblJobNumber.Text = creditorInvoice.JobNumber;
                    // lblLocation.Text         = creditorInvoice.Location;
                    lblOurInvoiceRef.Text = creditorInvoice.OurInvoiceRef;
                    txtExRate.Text        = creditorInvoice.ROE.ToString();
                    GetJobAndSetValue(creditorInvoice.JobNumber);


                    grvInvoice.DataSource = temp;
                    grvInvoice.DataBind();
                    ViewState["Charges"] = temp;


                    //ViewState["jobId"] = creditorInvoice.JobNumber;
                }
                else
                {
                    SetEmptyGrid();
                }
            }
            else
            {
                SetEmptyGrid();
            }

            if (Mode == "A")
            {
                //var value = Request.QueryString["IsPayment"];
                //if (string.IsNullOrEmpty(value) || !(value == "1" || value == "0"))
                //{
                //    throw new Exception("Invalid Request Transaction type");
                //}
                //ViewState["IsPayment"] = value;

                var ex = new EstimateBLL().GetExchange(new SearchCriteria()
                {
                    StringOption1 = "2", Date = lblJobDate.Text.ToDateTime()
                });
                txtExRate.Text            = Convert.ToString(ex.Tables[0].Rows[0]["USDXchRate"]);
                rdbApproval.SelectedValue = "0";
            }

            //grvInvoice.ShowFooter = false;
        }