Exemplo n.º 1
0
        private void GetJobAndSetValue(string jobId)
        {
            var reader = new CreditorInvoiceBLL().GetJobForCreInv(new SearchCriteria {
                StringOption1 = jobId
            });

            if (reader != null && reader.Tables.Count > 0 && reader.Tables[0].Rows.Count > 0)
            {
                var dr = reader.Tables[0].Rows[0];
                //lblHouseBLDate.Text = Convert.ToDateTime(dr["fwdBLDate"]).ToShortDateString();
                //lblHouseBLNo.Text       = dr["fwdBLNo"].ToString();
                lblJobNumber.Text = dr["JobNo"].ToString();
                lblLocation.Text  = dr["JobLoc"].ToString();
                lblJobDate.Text   = dr["JobDate"].ToString();
                //lblEstimate.Text        = dr["EstimateNo"].ToString();
            }
        }
Exemplo n.º 2
0
        private void LoadDefault()
        {
            var estimateId = Request.QueryString["EstimateId"];

            rdoPayment_SelectedIndexChanged(null, null);
            if (Request.QueryString["EstimateId"] != null)
            {
                estimateId = GeneralFunctions.DecryptQueryString(Request.QueryString["EstimateId"]);
            }

            ViewState["Id"] = estimateId;
            //var units = new EstimateBLL().GetUnitMaster(new SearchCriteria { StringOption1 = companyId });
            //ddlUnitType.DataSource = units;
            //ddlUnitType.DataTextField = "UnitName";
            //ddlUnitType.DataValueField = "pk_UnitTypeID";
            //ddlUnitType.DataBind();
            //ddlUnitType.Items.Insert(0, new ListItem("--Select--", "0"));

            var partyType = new EstimateBLL().GetBillingGroupMaster((ISearchCriteria)null);

            ddlBillingFrom.DataSource = partyType;

            ddlBillingFrom.DataTextField  = "PartyType";
            ddlBillingFrom.DataValueField = "pk_PartyTypeID";
            ddlBillingFrom.DataBind();
            ddlBillingFrom.Items.Insert(0, new ListItem("--Select--", "0"));

            if (!string.IsNullOrEmpty(estimateId))
            {
                var estimate = new EstimateBLL().GetEstimate(new SearchCriteria {
                    StringOption1 = estimateId
                });
                var temp = new List <Charge>();

                ViewState["IsPayment"] = estimate.PorR == "P" ? 1 : 0;
                ViewState["jobId"]     = estimate.JobID;

                if (estimate != null)
                {
                    if (estimate.Charges != null)
                    {
                        temp = estimate.Charges;
                    }
                    ViewState["Estimate"]        = estimate;
                    ddlBillingFrom.SelectedValue = estimate.BillFromId.ToString();

                    ddlParty.Items.Clear();
                    ddlParty.Items.Add(new ListItem("--Select--", "0"));
                    ddlParty.Items.Add(new ListItem(estimate.PartyName, estimate.PartyId.ToString()));

                    ddlParty.SelectedValue = estimate.PartyId.ToString();
                    if (temp != null && temp.Count > 0)
                    {
                        estimate.UnitTypeId = temp.FirstOrDefault().UnitId;
                    }

                    txtExRate.Text = estimate.ROE.ToString();
                    //ddlUnitType.SelectedValue = estimate.UnitTypeId.ToString();
                    rdoPayment.SelectedValue = estimate.TransactionType.ToString();
                    txtCreditInDays.Text     = estimate.CreditDays.ToString();
                    lblJobNo.Text            = estimate.JobNo.ToString();

                    txtEstimateDate.Text = estimate.EstimateDate.ToString().Split(' ')[0];
                    lblEstimateNo.Text   = estimate.EstimateNo.ToString();
                    hdnQuoPath.Value     = "Quotation" + estimateId.ToString().TrimEnd();
                    //lblTotalUnit.Text = temp.Sum(x => x.Unit).ToString();
                    lblCharges.Text       = temp.Sum(x => x.INR).ToString("#########0.00");
                    grvCharges.DataSource = temp;
                    grvCharges.DataBind();
                    ViewState["Charges"] = temp;
                    var path        = Server.MapPath("~/Forwarding/QuoUpload");
                    var newFileName = "Quotation" + estimateId.ToString().TrimEnd();  //  Guid.NewGuid().ToString();

                    if (estimate.JobActive != "P")
                    {
                        btnSave.Visible = false;
                    }

                    //if (!string.IsNullOrEmpty(path))
                    //{
                    //    path += @"\" + hdnQuoPath.Value + ".pdf";
                    //    //System.IO.Path.GetExtension(fileName);
                    //    hdnQuoPath.Value = path;
                    //    if (File.Exists(path))
                    //    {
                    //        lnkQuoUpload.Enabled = true;
                    //        lnkQuoUpload.Text = newFileName + ".pdf";
                    //        //lblUploadedFileName.Text = newFileName;
                    //        //lblUploadedFileName.Visible = true;
                    //    }
                    //}

                    var jobId = GeneralFunctions.DecryptQueryString(Request.QueryString["jobId"]);

                    ViewState["jobId"] = jobId;

                    var reader = new CreditorInvoiceBLL().GetJobForCreInv(new SearchCriteria {
                        StringOption1 = jobId
                    });
                    if (reader != null && reader.Tables.Count > 0 && reader.Tables[0].Rows.Count > 0)
                    {
                        var dr = reader.Tables[0].Rows[0];
                        lblJobDate.Text      = Convert.ToDateTime(dr["JobDate"]).ToShortDateString();
                        lblJobNo.Text        = dr["JobNo"].ToString();
                        lblShippingMode.Text = dr["ShippingMode"].ToString();
                        txtEstimateDate.Text = Convert.ToDateTime(dr["JobDate"]).ToShortDateString();
                    }
                    PopulateUnitType();
                }
                else
                {
                    SetEmptyGrid();
                }
            }
            else
            {
                SetEmptyGrid();
            }

            if (Mode == "A")
            {
                txtCreditInDays.Enabled         = false;
                RequiredFieldValidator3.Enabled = false;
                var value = GeneralFunctions.DecryptQueryString(Request.QueryString["IsPayment"]);
                if (string.IsNullOrEmpty(value) || !(value == "1" || value == "0"))
                {
                    throw new Exception("Invalid Request Transaction type");
                }
                ViewState["IsPayment"] = value;
                txtEstimateDate.Text   = DateTime.Today.ToShortDateString();

                var jobId = GeneralFunctions.DecryptQueryString(Request.QueryString["jobId"]);
                if (string.IsNullOrEmpty(jobId))
                {
                    throw new Exception("Invalid jobId");
                }
                ViewState["jobId"] = jobId;

                var reader = new CreditorInvoiceBLL().GetJobForCreInv(new SearchCriteria {
                    StringOption1 = jobId
                });
                if (reader != null && reader.Tables.Count > 0 && reader.Tables[0].Rows.Count > 0)
                {
                    var dr = reader.Tables[0].Rows[0];
                    lblJobDate.Text      = Convert.ToDateTime(dr["JobDate"]).ToShortDateString();
                    lblJobNo.Text        = dr["JobNo"].ToString();
                    lblShippingMode.Text = dr["ShippingMode"].ToString();
                    txtEstimateDate.Text = Convert.ToDateTime(dr["JobDate"]).ToShortDateString();
                }
                var ex = new EstimateBLL().GetExchange(new SearchCriteria()
                {
                    StringOption1 = "2", Date = lblJobDate.Text.ToDateTime()
                });
                hdnExRate.Value = Convert.ToString(ex.Tables[0].Rows[0]["USDXchRate"]);
                txtExRate.Text  = Convert.ToString(ex.Tables[0].Rows[0]["USDXchRate"]);
                //ddlCurrency_SelectedIndexChanged(null, null);
                PopulateUnitType();

                //lblJobNo.Text = GeneralFunctions.DecryptQueryString(Request.QueryString["JobNo"]);
                //GetPartyValuesSetToDdl();
            }

            //grvCharges.ShowFooter = false;
        }
Exemplo n.º 3
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;
        }