예제 #1
0
        protected void TextEx_TextChanged(object sender, EventArgs e)
        {
            List <CreditorInvoiceCharge> charges = null;
            DataSet ds       = new DataSet();
            var     estimate = new Estimate();

            charges = (List <CreditorInvoiceCharge>)ViewState["Charges"];
            if (charges.Count > 0)
            {
                for (int count = 0; count < charges.Count; count++)
                {
                    if (charges[count].CurrencyId.ToInt() == 2)
                    {
                        charges[count].ConvRate = txtExRate.Text.ToDouble();
                        ds = new EstimateBLL().GetServiceTax(lblJobDate.Text.ToDateTime(), (charges[count].Unit * charges[count].Rate * charges[count].ConvRate).ToDecimal(), charges[count].ChargeId);
                        if (ds.Tables[1].Rows[0]["ServiceTax"].ToInt() == 1 && charges[count].STax != 0)
                        {
                            charges[count].STax = (ds.Tables[0].Rows[0]["stax"].ToDecimal() + ds.Tables[0].Rows[0]["CessAmt"].ToDecimal() + ds.Tables[0].Rows[0]["AddCess"].ToDecimal()).ToDouble();
                        }
                        else
                        {
                            charges[count].STax = 0;
                        }
                        charges[count].GTotal = (charges[count].Unit * charges[count].Rate * charges[count].ConvRate) + charges[count].STax;
                    }
                }
                lblInvoiceAmount.Text = charges.Sum(m => m.GTotal).ToString();
                ViewState["Charges"]  = charges;
                grvInvoice.DataSource = charges;
                grvInvoice.DataBind();
            }
        }
예제 #2
0
        protected void ddlCurrency_SelectedIndexChanged(object sender, EventArgs e)
        {
            var ddlCurrency = (DropDownList)grvCharges.FooterRow.FindControl("ddlCurrency");
            var txtROE      = (TextBox)grvCharges.FooterRow.FindControl("txtROE");

            if (ddlCurrency != null)
            {
                var ex = new EstimateBLL().GetExchange(new SearchCriteria()
                {
                    StringOption1 = ddlCurrency.SelectedValue, Date = lblJobDate.Text.ToDateTime()
                });

                txtROE.Text = "0";
                if (ex != null && ex.Tables.Count > 0 && ex.Tables[0].Rows.Count > 0)
                {
                    //txtROE.Text = Convert.ToString(ex.Tables[0].Rows[0]["USDXchRate"]);
                    txtROE.Text = txtExRate.Text;
                }
                txtROE.Enabled = true;
                if (ddlCurrency.SelectedValue == "1" || ddlCurrency.SelectedValue == "2")
                {
                    txtROE.Enabled = false;
                    if (ddlCurrency.SelectedValue == "1")
                    {
                        txtROE.Text = "1";
                    }
                }
            }
            CalculateAndAssign();
        }
예제 #3
0
        private void GetPartyTypes()
        {
            var partyType = new EstimateBLL().GetBillingGroupMaster((ISearchCriteria)null);

            ddlPartyType.DataSource     = partyType;
            ddlPartyType.DataTextField  = "PartyType";
            ddlPartyType.DataValueField = "pk_PartyTypeID";
            ddlPartyType.DataBind();
            ddlPartyType.Items.Insert(0, new ListItem("--Select--", "0"));
        }
예제 #4
0
        protected void grvInvoice_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                var     dll = (DropDownList)e.Row.FindControl("ddlCharges");
                DataSet ds  = new DataSet();
                if (ViewState["ddlCharges"] == null)
                {
                    ds = new EstimateBLL().GetCharges((ISearchCriteria)null);
                    ViewState["ddlCharges"] = ds;
                }
                else
                {
                    ds = (DataSet)ViewState["ddlCharges"];
                }
                dll.DataSource     = ds;
                dll.DataTextField  = "ChargeName";
                dll.DataValueField = "ChargeId";
                dll.DataBind();
                dll.Items.Insert(0, new ListItem("--Select--", "0"));


                var     dllC   = (DropDownList)e.Row.FindControl("ddlCurrency");
                DataSet dllCds = new DataSet();
                if (ViewState["ddlCurrency"] == null)
                {
                    dllCds = new EstimateBLL().GetCurrency((ISearchCriteria)null);
                    ViewState["ddlCurrency"] = dllCds;
                }
                else
                {
                    dllCds = (DataSet)ViewState["ddlCurrency"];
                }

                dllC.DataSource     = dllCds;
                dllC.DataTextField  = "CurrencyName";
                dllC.DataValueField = "pk_CurrencyID";
                dllC.DataBind();
                dllC.Items.Insert(0, new ListItem("--Select--", "0"));


                //var txt2 = (TextBox)e.Row.FindControl("txtROE");
                //var txt1 = (TextBox)e.Row.FindControl("txtRate");
                //var txt3 = (TextBox)e.Row.FindControl("txtUnit");
                //if (txt1 != null) { txt1.Attributes.Add("onblur", "CalculateINR(this)"); }
                //if (txt3 != null) { txt3.Attributes.Add("onblur", "CalculateINR(this)"); }
                //if (txt2 != null) { txt2.Attributes.Add("onblur", "CalculateINR(this)"); }
            }
            else if (e.Row.RowType == DataControlRowType.DataRow && IsEmptyGrid)
            {
                e.Row.Visible = false;
                IsEmptyGrid   = false;
            }
        }
예제 #5
0
        private void GetPartyValuesSetToDdl()
        {
            //ddlParty.Items.Clear();
            //var creditorInvoice = new CreditorInvoiceBLL().GetCreditor((ISearchCriteria)null);

            var creditorInvoice = new EstimateBLL().GetAllParty(0);

            ddlParty.DataSource     = creditorInvoice;
            ddlParty.DataTextField  = "PartyName";
            ddlParty.DataValueField = "pk_fwPartyID";
            ddlParty.DataBind();
            ddlParty.Items.Insert(0, new ListItem("--Select--", "0"));
        }
예제 #6
0
        protected void ddlCharges_SelectedIndexChanged(object sender, EventArgs e)
        {
            var     ddlChargeID = (DropDownList)grvCharges.FooterRow.FindControl("ddlCharges");
            var     ddlCurrency = (DropDownList)grvCharges.FooterRow.FindControl("ddlCurrency");
            DataSet ds          = new DataSet();

            ds = new EstimateBLL().GetSelectedCharge(ddlChargeID.SelectedValue.ToInt());
            ddlCurrency.SelectedValue = ds.Tables[0].Rows[0]["Currency"].ToString();
            //StaxExist = ds.Tables[0].Rows[0]["ServiceTax"].ToInt();
            ddlCurrency_SelectedIndexChanged(null, null);
            //List<IChargeRate> chargeRates = new InvoiceBLL().GetInvoiceCharges_New(Convert.ToInt64(ddlBLno.SelectedValue), Convert.ToInt32(ddlFChargeName.SelectedValue), Convert.ToInt32(ddlFTerminal.SelectedValue), Convert.ToDecimal(txtExchangeRate.Text), 0, "", Convert.ToDateTime(txtInvoiceDate.Text));
            //List<IExpChargeRate> chargeRates = new InvoiceBLL().GetExpInvoiceCharges_New(Convert.ToInt64(ddlBLno.SelectedValue), Convert.ToInt32(ddlFChargeName.SelectedValue), Convert.ToInt32(ddlFTerminal.SelectedValue), Convert.ToDecimal(0), 0, "", Convert.ToDateTime(txtInvoiceDate.Text));
        }
예제 #7
0
        private void GetPartyValuesSetToDdl(int PartyType)
        {
            ddlParty.Items.Clear();

            DataSet dll = new DataSet();

            dll = new EstimateBLL().GetAllParty(PartyType);

            ddlParty.DataSource     = dll;
            ddlParty.DataTextField  = "PartyName";
            ddlParty.DataValueField = "pk_fwPartyID";
            ddlParty.DataBind();
            ddlParty.Items.Insert(0, new ListItem("--Select--", "0"));
        }
예제 #8
0
        protected void ddlUnitType_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            var ddlUnitTypeID = (DropDownList)grvCharges.FooterRow.FindControl("ddlUnitType");

            ds = new EstimateBLL().GetSingleUnitType(ddlUnitTypeID.SelectedValue.ToInt(), ViewState["jobId"].ToInt());
            var ddlSizeID = (DropDownList)grvCharges.FooterRow.FindControl("ddlSize");
            //var rfvSize = (RequiredFieldValidator)grvCharges.FooterRow.FindControl("rfvSize");
            var txtUnit = (TextBox)grvCharges.FooterRow.FindControl("txtUnit");

            //ds = new EstimateBLL().GetSelectedCharge(ddlChargeID.SelectedValue.ToInt());
            if (ds.Tables[0].Rows[0]["UnitType"].ToString() == "N")
            {
                //ddlSizeID.Enabled = false;
                //rfvSize.Enabled = false;
                if (ds.Tables[0].Rows[0]["UnitName"].ToString() == "CBM")
                {
                    txtUnit.Text = ds.Tables[1].Rows[0]["volcbm"].ToString();
                }
                else if (ds.Tables[0].Rows[0]["UnitName"].ToString() == "M.TON")
                {
                    txtUnit.Text = ds.Tables[1].Rows[0]["weightMT"].ToString();
                }
                else if (ds.Tables[0].Rows[0]["UnitName"].ToString() == "REV.TON")
                {
                    txtUnit.Text = ds.Tables[1].Rows[0]["revton"].ToString();
                }
                else if (ds.Tables[0].Rows[0]["UnitName"].ToString() == "CHRG. WT.(KGS)")
                {
                    txtUnit.Text = ds.Tables[1].Rows[0]["ChargeWt"].ToString();
                }
            }
            else
            {
                CheckContainer();
            }

            //var ddlUnitTypeID = (DropDownList)grvCharges.FooterRow.FindControl("ddlUnitType");
            //var ddlSizeID = (DropDownList)grvCharges.FooterRow.FindControl("ddlSize");
            //var txtUnit = (TextBox)grvCharges.FooterRow.FindControl("txtUnit");

            //if (ddlUnitTypeID.SelectedIndex <> -1 && ddlSizeID.SelectedIndex != -1)
            //{
            //    DataSet ds = new DataSet();
            //    ds = new EstimateBLL().GetContainers(ddlUnitTypeID.SelectedValue.ToString(), ddlSizeID.SelectedValue.ToString());
            //    txtUnit.Text = ds.Tables[0].Rows[0]["Unit"].ToString();
            //}
        }
예제 #9
0
        public bool insertChallan(EstimateBLL c, out int Invoice_No)
        {
            bool isSuccess = false;

            Invoice_No = -1;
            SqlConnection con = new SqlConnection(myconnstrng);

            try
            {
                String sql = "INSERT INTO Estimate_Transactions (Cust_ID,Sub_Total,TDiscount,TSGST,TCGST,TIGST,Grand_Total) VALUES(@Cust_ID,@Sub_Total,@TDiscount,@TSGST,@TCGST,@TIGST,@Grand_Total);select @@IDENTITY;";

                SqlCommand cmd = new SqlCommand(sql, con);

                cmd.Parameters.AddWithValue("@Invoice_No", c.Invoice_No);
                cmd.Parameters.AddWithValue("@Cust_ID", c.Cust_ID);
                cmd.Parameters.AddWithValue("@Sub_Total", c.Sub_Total);
                cmd.Parameters.AddWithValue("@TDiscount", c.TDiscount);
                cmd.Parameters.AddWithValue("@TSGST", c.TSGST);
                cmd.Parameters.AddWithValue("@TCGST", c.TCGST);
                cmd.Parameters.AddWithValue("@TIGST", c.TIGST);
                cmd.Parameters.AddWithValue("@Grand_Total", c.Grand_Total);

                con.Open();

                object o = cmd.ExecuteScalar();

                if (o != null)
                {
                    isSuccess  = true;
                    Invoice_No = int.Parse(o.ToString());
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(isSuccess);
        }
예제 #10
0
        private void GetPartyValuesSetToDdl(int PartyType)
        {
            ddlParty.Items.Clear();
            ddlParty.Items.Add(new ListItem("--Select--", "0"));
            if (Mode == "A")
            {
                if (ViewState["IsPayment"].ToInt() == 0)
                {
                    DataSet dll = new DataSet();

                    dll = new EstimateBLL().GetAllParty(PartyType);

                    ddlParty.DataSource     = dll;
                    ddlParty.DataTextField  = "PartyName";
                    ddlParty.DataValueField = "pk_fwPartyID";
                    ddlParty.DataBind();
                    ddlParty.Items.Insert(0, new ListItem("--Select--", "0"));
                }
                else
                {
                    DataSet dllCreditor = new DataSet();

                    dllCreditor = new EstimateBLL().GetParty(PartyType);

                    ddlParty.DataSource     = dllCreditor;
                    ddlParty.DataTextField  = "PartyName";
                    ddlParty.DataValueField = "pk_fwPartyID";
                    ddlParty.DataBind();
                    ddlParty.Items.Insert(0, new ListItem("--Select--", "0"));
                }
            }
            else
            {
                DataSet dll = new DataSet();

                dll = new EstimateBLL().GetAllParty(PartyType);

                ddlParty.DataSource     = dll;
                ddlParty.DataTextField  = "PartyName";
                ddlParty.DataValueField = "pk_fwPartyID";
                ddlParty.DataBind();
                ddlParty.Items.Insert(0, new ListItem("--Select--", "0"));
            }
        }
예제 #11
0
        private void CheckContainer()
        {
            var ddlUnitTypeID = (DropDownList)grvCharges.FooterRow.FindControl("ddlUnitType");
            var ddlSizeID     = (DropDownList)grvCharges.FooterRow.FindControl("ddlSize");
            var txtUnit       = (TextBox)grvCharges.FooterRow.FindControl("txtUnit");

            if (ddlUnitTypeID.SelectedIndex != 0 && ddlSizeID.SelectedIndex != 0)
            {
                DataSet ds = new DataSet();
                ds = new EstimateBLL().GetContainers(ddlUnitTypeID.SelectedValue.ToInt(), ddlSizeID.SelectedValue.ToString(), ViewState["jobId"].ToInt());
                if (ds.Tables[0].Rows.Count > 0)
                {
                    txtUnit.Text = ds.Tables[0].Rows[0]["Nos"].ToString();
                }
                else
                {
                    txtUnit.Text = "0.00";
                }
            }
        }
예제 #12
0
        protected void TextEx_TextChanged(object sender, EventArgs e)
        {
            List <Charge> charges  = null;
            DataSet       ds       = new DataSet();
            var           estimate = new Estimate();

            //if (txtExRate.Text.ToDecimal() < hdnExRate.Value.ToDecimal())
            //{
            //    ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('Invalid Exchange Rate!');</script>", false);
            //    txtExRate.Text = hdnExRate.Value;
            //}
            charges = (List <Charge>)ViewState["Charges"];
            if (charges.Count > 0)
            {
                for (int count = 0; count < charges.Count; count++)
                {
                    if (charges[count].CurrencyId.ToInt() == 2)
                    {
                        charges[count].ROE = txtExRate.Text.ToDouble();
                        ds = new EstimateBLL().GetServiceTax(lblJobDate.Text.ToDateTime(), (charges[count].Unit * charges[count].Rate * charges[count].ROE).ToDecimal(), charges[count].ChargeMasterId);
                        if (ds.Tables[1].Rows[0]["ServiceTax"].ToInt() == 1)
                        {
                            charges[count].STax = (ds.Tables[0].Rows[0]["stax"].ToDecimal() + ds.Tables[0].Rows[0]["CessAmt"].ToDecimal() + ds.Tables[0].Rows[0]["AddCess"].ToDecimal()).ToDouble();
                        }
                        else
                        {
                            charges[count].STax = 0;
                        }
                        charges[count].INR = (charges[count].Unit * charges[count].Rate * charges[count].ROE) + charges[count].STax;
                    }
                }
                lblCharges.Text       = charges.Sum(m => m.INR).ToString("#########0.00");
                ViewState["Charges"]  = charges;
                grvCharges.DataSource = charges;
                grvCharges.DataBind();
                PopulateUnitType();
            }
        }
예제 #13
0
        private void PopulateUnitType()
        {
            var dllU = (DropDownList)grvCharges.FooterRow.FindControl("ddlUnitType");
            //var dllU = (DropDownList)e.Row.FindControl("ddlUnitType");
            var curtype = "E";

            DataSet dllUs = new DataSet();


            if (ViewState["dllUs"] == null)
            {
                var ddlSize = (DropDownList)grvCharges.FooterRow.FindControl("ddlSize");
                if (ddlSize.SelectedValue.ToInt() == 0)
                {
                    curtype = "N";
                }
                else
                {
                    curtype = "E";
                }
                dllUs = new EstimateBLL().GetUnitMaster(new SearchCriteria {
                    StringOption1 = companyId, StringOption2 = curtype, SortExpression = "UnitName"
                });
                ViewState["ddlUnitType"] = dllUs;
            }
            else
            {
                dllUs = (DataSet)ViewState["ddlUnitType"];
            }

            //var units = new EstimateBLL().GetUnitMaster(new SearchCriteria { StringOption1 = companyId });
            dllU.DataSource     = dllUs;
            dllU.DataTextField  = "UnitName";
            dllU.DataValueField = "pk_UnitTypeID";
            dllU.DataBind();
            dllU.Items.Insert(0, new ListItem("--Select--", "0"));
        }
예제 #14
0
        protected void grvCharges_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                var     dll = (DropDownList)e.Row.FindControl("ddlCharges");
                DataSet ds  = new DataSet();
                if (ViewState["ddlCharges"] == null)
                {
                    ds = new EstimateBLL().GetCharges((ISearchCriteria)null);
                    ViewState["ddlCharges"] = ds;
                }
                else
                {
                    ds = (DataSet)ViewState["ddlCharges"];
                }
                dll.DataSource     = ds;
                dll.DataTextField  = "ChargeName";
                dll.DataValueField = "ChargeId";
                dll.DataBind();
                dll.Items.Insert(0, new ListItem("--Select--", "0"));

                var     dllC   = (DropDownList)e.Row.FindControl("ddlCurrency");
                DataSet dllCds = new DataSet();
                if (ViewState["ddlCurrency"] == null)
                {
                    dllCds = new EstimateBLL().GetCurrency((ISearchCriteria)null);
                    ViewState["ddlCurrency"] = dllCds;
                }
                else
                {
                    dllCds = (DataSet)ViewState["ddlCurrency"];
                }

                dllC.DataSource     = dllCds;
                dllC.DataTextField  = "CurrencyName";
                dllC.DataValueField = "pk_CurrencyID";
                dllC.DataBind();
                dllC.Items.Insert(0, new ListItem("--Select--", "0"));

                //var dllU = (DropDownList)e.Row.FindControl("ddlUnitType");
                //DataSet dllUs = new DataSet();
                //if (ViewState["ddlUnitType"] == null)
                //{
                //    dllUs = new EstimateBLL().GetUnitMaster(new SearchCriteria { StringOption1 = companyId, StringOption2 = lblShippingMode.Text });
                //    ViewState["ddlUnitType"] = dllUs;
                //}
                //else
                //{
                //    dllUs = (DataSet)ViewState["ddlUnitType"];
                //}

                ////var units = new EstimateBLL().GetUnitMaster(new SearchCriteria { StringOption1 = companyId });
                //dllU.DataSource = dllUs;
                //dllU.DataTextField = "UnitName";
                //dllU.DataValueField = "pk_UnitTypeID";
                //dllU.DataBind();
                //dllU.Items.Insert(0, new ListItem("--Select--", "0"));
            }
            else if (e.Row.RowType == DataControlRowType.DataRow && IsEmptyGrid)
            {
                e.Row.Visible = false;
                IsEmptyGrid   = false;
            }
        }
예제 #15
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;
        }
예제 #16
0
        private CreditorInvoiceCharge GetCharge()
        {
            var     CessAmt  = 0.0;
            var     ACessAmt = 0.0;
            DataSet ds       = new DataSet();

            var txtUnit     = (TextBox)grvInvoice.FooterRow.FindControl("txtUnit");
            var txtRate     = (TextBox)grvInvoice.FooterRow.FindControl("txtRate");
            var txtSTax     = (TextBox)grvInvoice.FooterRow.FindControl("lblStax");
            var txtConvRate = (TextBox)grvInvoice.FooterRow.FindControl("txtConvRate");
            var ddlChargeID = (DropDownList)grvInvoice.FooterRow.FindControl("ddlCharges");

            //var sTax = string.IsNullOrEmpty(txtSTax.Text)?0.0: Convert.ToDouble(txtSTax.Text);
            var unit     = string.IsNullOrEmpty(txtUnit.Text) ? 0.0 : Convert.ToDouble(txtUnit.Text);
            var rate     = string.IsNullOrEmpty(txtRate.Text) ? 0.0 : Convert.ToDouble(txtRate.Text);
            var convRate = string.IsNullOrEmpty(txtConvRate.Text) ? 0.0 : Convert.ToDouble(txtConvRate.Text);

            int ChargeID = ddlChargeID.SelectedValue.ToInt();
            var total    = 0.0;
            var gross    = 0.0;
            var gtotal   = 0.0;

            try
            {
                total = unit * rate;
            }
            catch
            {
                total = 0;
            }
            try
            {
                gross = total * convRate;
            }
            catch
            {
                gross = 0;
            }

            var stx = 0.0;

            try
            {
                //stx = (gross * sTax) / 100;
                //CessAmt = ViewState["CessPer"].ToDouble() * (sTax * gross / 100) / 100;
                //ACessAmt = ViewState["ACessPer"].ToDouble() * (sTax * gross / 100) / 100;
                //stx = sTax;

                ds = new EstimateBLL().GetServiceTax(lblJobDate.Text.ToDateTime(), (unit * rate * convRate).ToDecimal(), ChargeID);
                if (ds.Tables[1].Rows[0]["ServiceTax"].ToInt() == 1)
                {
                    txtSTax.Text = (ds.Tables[0].Rows[0]["stax"].ToDecimal() + ds.Tables[0].Rows[0]["CessAmt"].ToDecimal() + ds.Tables[0].Rows[0]["AddCess"].ToDecimal()).ToString("#######0.00");
                    stx          = Convert.ToDouble(txtSTax.Text);
                }
                else
                {
                    txtSTax.Text = "0";
                    stx          = 0;
                }
            }
            catch { }

            try
            {
                gtotal = gross + stx; // + CessAmt + ACessAmt;
            }
            catch
            {
                gross = 0;
            }
            var ddlCharges  = (DropDownList)grvInvoice.FooterRow.FindControl("ddlCharges");
            var ddlCurrency = (DropDownList)grvInvoice.FooterRow.FindControl("ddlCurrency");
            var ddlSize     = (DropDownList)grvInvoice.FooterRow.FindControl("ddlSize");
            var ddlUnitType = (DropDownList)grvInvoice.FooterRow.FindControl("ddlUnitType");

            CreditorInvoiceCharge charge = new CreditorInvoiceCharge();

            charge.ChargeId   = Convert.ToInt32(ddlCharges.SelectedValue);
            charge.CurrencyId = Convert.ToInt32(ddlCurrency.SelectedValue);
            charge.Currency   = ddlCurrency.SelectedItem.Text;

            charge.ChargeName = ddlCharges.SelectedItem.Text;
            charge.ConvRate   = convRate;
            charge.Unit       = unit;
            charge.UnitType   = ddlUnitType.SelectedItem.Text;
            charge.UnitTypeID = ddlUnitType.SelectedValue.ToInt();
            charge.CntrSize   = ddlSize.SelectedValue;


            charge.Total = total;
            charge.Gross = gross;
            //charge.STaxPercentage = sTax;

            charge.STax      = stx;
            charge.STaxCess  = CessAmt;
            charge.STaxACess = ACessAmt;

            charge.GTotal = gtotal;
            charge.Rate   = rate;
            return(charge);
        }
예제 #17
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;
        }
예제 #18
0
        private void CalculateAndAssign()
        {
            DataSet ds      = new DataSet();
            var     txtUnit = (TextBox)grvCharges.FooterRow.FindControl("txtUnit");
            var     txtRate = (TextBox)grvCharges.FooterRow.FindControl("txtRate");
            var     txtROE  = (TextBox)grvCharges.FooterRow.FindControl("txtROE");
            //var spINR = (Label)grvCharges.FooterRow.FindControl("lblINR");
            var spINR       = (TextBox)grvCharges.FooterRow.FindControl("lblINR");
            var spSTAX      = (TextBox)grvCharges.FooterRow.FindControl("lblStax");
            var ddlChargeID = (DropDownList)grvCharges.FooterRow.FindControl("ddlCharges");

            var unit     = 0.0;
            var rate     = 0.0;
            var roe      = 0.0;
            var stax     = 0.0;
            int ChargeID = ddlChargeID.SelectedValue.ToInt();

            try
            {
                unit = Convert.ToDouble(txtUnit.Text);
            }
            catch
            {
                unit = 0;
            }
            try
            {
                rate = Convert.ToDouble(txtRate.Text);
            }
            catch
            {
                rate = 0;
            }
            try
            {
                roe = Convert.ToDouble(txtROE.Text);
            }
            catch
            {
                roe = 0;
            }
            try
            {
                ds = new EstimateBLL().GetServiceTax(lblJobDate.Text.ToDateTime(), (unit * rate * roe).ToDecimal(), ChargeID);
                if (ds.Tables[1].Rows[0]["ServiceTax"].ToInt() == 1)
                {
                    spSTAX.Text = (ds.Tables[0].Rows[0]["stax"].ToDecimal() + ds.Tables[0].Rows[0]["CessAmt"].ToDecimal() + ds.Tables[0].Rows[0]["AddCess"].ToDecimal()).ToString("#######0.00");
                    stax        = Convert.ToDouble(spSTAX.Text);
                }
                else
                {
                    spSTAX.Text = "0";
                    stax        = 0;
                }
                //stax = Convert.ToDouble(txtROE.Text);
            }
            catch
            {
                stax = 0;
            }

            if (spINR != null)
            {
                spINR.Text = ((unit * rate * roe) + stax).ToString("#######0.00");
            }
        }