Esempio n. 1
0
    protected void GetRate()
    {
        DObj = new Districts(ComObj);
        //string getcat = "select Block_cat from pds.block_master where District_code ='" + distid + "' and block_code='" + ddl_block.SelectedValue +"'";
        //DataSet dscat = DObj.selectAny(getcat);
        //if (dscat.Tables[0].Rows.Count == 0)
        //{

        //}
        //else
        //{
        //    DataRow drcat = dscat.Tables[0].Rows[0];
        //    cat = drcat["Block_cat"].ToString();

        //}
        if (ddl_rate_type.SelectedItem.Value == "U")
        {
            string qry = "Select Uraban_rate  from dbo.SCSC_IssueRate where Scheme_ID='" + ddl_scheme.SelectedValue + "'and Commodity_ID='" + ddl_commodity.SelectedValue + "'and District_code='" + distid + "'";
            DObj = new Districts(ComObj);
            DataSet ds = DObj.selectAny(qry);
            if (ds.Tables[0].Rows.Count == 0)
            {
                Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Rate is not available for selected commodity....'); </script> ");

                tx_rate_qt.ReadOnly = false;
                tx_rate_qt.Focus();
                tx_rate_qt.BackColor = System.Drawing.Color.White;
            }
            else
            {
                DataRow dr = ds.Tables[0].Rows[0];
                tx_rate_qt.Text     = dr["Uraban_rate"].ToString();
                tx_rate_qt.ReadOnly = true;
            }
        }
        else
        {
            string qry = "Select Rural_rate  from dbo.SCSC_IssueRate  where Scheme_ID='" + ddl_scheme.SelectedValue + "'and Commodity_ID='" + ddl_commodity.SelectedValue + "'";
            DObj = new Districts(ComObj);
            DataSet ds = DObj.selectAny(qry);
            if (ds.Tables[0].Rows.Count == 0)
            {
                Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Rate is not available for selected commodity....'); </script> ");

                tx_rate_qt.ReadOnly = false;
                tx_rate_qt.Focus();
                tx_rate_qt.BackColor = System.Drawing.Color.White;
            }
            else
            {
                DataRow dr = ds.Tables[0].Rows[0];
                tx_rate_qt.Text     = dr["Rural_rate"].ToString();
                tx_rate_qt.ReadOnly = true;
            }
        }
    }
Esempio n. 2
0
    protected void GetRate()
    {
        //string todates = DateTime.Today.ToShortDateString();
        string todaydate = DateTime.Today.ToString("MM/dd/yyyy");

        DObj = new Districts(ComObj);
        if (ddl_commodity.SelectedItem.Text == "Select" || ddl_scheme.SelectedItem.Text == "Select")
        {
            Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Please select Commodity/Scheme...');</script>");
        }
        else if (ddl_rate_type.SelectedItem.Value == "U")
        {
            string qry = "Select Uraban_rate  from dbo.SCSC_IssueRate where Scheme_ID='" + ddl_scheme.SelectedValue + "'and Commodity_ID='" + ddl_commodity.SelectedValue + "' and District_code='" + distid + "' and Effective_From<='" + todaydate + "' order by Effective_From desc";
            DObj = new Districts(ComObj);
            DataSet ds = DObj.selectAny(qry);
            if (ds.Tables[0].Rows.Count == 0)
            {
                // Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Rate is not available for selected commodity....'); </script> ");
                tx_rate_qt.ReadOnly = false;
                tx_rate_qt.Focus();
                tx_rate_qt.BackColor = System.Drawing.Color.White;
                tx_rate_qt.Text      = "0";
            }
            else
            {
                DataRow dr = ds.Tables[0].Rows[0];
                tx_rate_qt.Text     = dr["Uraban_rate"].ToString();
                tx_rate_qt.ReadOnly = true;
            }
        }
        else
        {
            string qry = "Select Rural_rate  from dbo.SCSC_IssueRate  where Scheme_ID='" + ddl_scheme.SelectedValue + "'and Commodity_ID='" + ddl_commodity.SelectedValue + "' and District_code='" + distid + "' and Effective_From<='" + todaydate + "' order by Effective_From desc";
            DObj = new Districts(ComObj);
            DataSet ds = DObj.selectAny(qry);
            if (ds.Tables[0].Rows.Count == 0)
            {
                //Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Rate is not available for selected commodity....'); </script> ");
                tx_rate_qt.ReadOnly = false;
                tx_rate_qt.Focus();
                tx_rate_qt.BackColor = System.Drawing.Color.White;
                tx_rate_qt.Text      = "0";
            }
            else
            {
                DataRow dr = ds.Tables[0].Rows[0];
                tx_rate_qt.Text     = dr["Rural_rate"].ToString();
                tx_rate_qt.ReadOnly = true;
            }
        }
    }
Esempio n. 3
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        string qryc = "SELECT * FROM tbl_MetaData_Purchase_Center where DistrictId='" + ddldistoff.SelectedValue.ToString() + "' and PurchaseCenterName='" + txtCentreName.Text + "'";

        DObj = new Districts(ComObj);
        DataSet ds = DObj.selectAny(qryc);

        if (ds == null)
        {
        }
        else
        {
            if (ds.Tables[0].Rows.Count == 0)
            {
                string qry = "INSERT INTO tbl_MetaData_Purchase_Center(PcId,PCCode,CommodityId,DistrictId,RegionId,StateId,CropYearId,MarketingSeason,PurchaseCenterName,DateOfIssue,Address,Phone,PC_CategoryID,PCType,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate,DeletedBy ,DeletedDate,NodalOff,Block,Remark,Status,Master_PCID)VALUES('" + txtpcid.Text + "','','" + ddlcomdty.SelectedValue.ToString() + "','23" + ddldistoff.SelectedValue + "','2300','23','" + ddlseason.SelectedValue.ToString() + "','" + ddlcropyear.SelectedItem.Text.ToString() + "','" + txtCentreName.Text + "','','" + txtAddress.Text + "','" + txtPhone.Text + "','1','','',getdate(),'','','','','" + txtNodalOff.Text + "','" + txtBlock.Text + "','" + txtRemarks.Text + "','4','" + txtpcid.Text + "')";
                cmd.Connection  = con;
                cmd.CommandText = qry;

                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                    //cmd.Connection = con1;
                    //cmd.CommandText = qry;
                    //con1.Open();
                    //cmd.ExecuteNonQuery();
                    //con1.Close();
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Inserted Successfully.....'); </script> ");
                    btnsubmit.Enabled = false;
                }
                catch (Exception ex)
                {
                    Label1.Visible = true;
                    Label1.Text    = ex.Message;
                }
                finally
                {
                    con.Close();
                }
            }
            else
            {
                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Purchase Centre Already Exist.....'); </script> ");
            }
        }
    }
Esempio n. 4
0
    void GetBalanceQty()
    {
        string commid   = lblcmdty.Text;
        string schemeid = lblsch.Text;
        int    month    = int.Parse(ddlalotmm.SelectedValue);
        int    year     = int.Parse(ddlallot_year.SelectedValue);
        string qryGB    = "Select Sum(RO_qty) as RO_qty from dbo.RO_of_FCI where Scheme='" + schemeid + "'and Commodity='" + commid + "' and Distt_Id='" + distid + "' and Allot_month=" + month + "and Allot_year=" + year;

        DObj = new Districts(ComObj);
        DataSet dsGB = DObj.selectAny(qryGB);

        if (dsGB == null)
        {
        }
        else
        {
            if (dsGB.Tables[0].Rows.Count == 0)
            {
                float mbqty = CheckNull(txtalotqty.Text) - CheckNull(txtroqty.Text);
                txtbalance.Text     = "0";
                txtbalance.ReadOnly = true;
                //txtbalance.BackColor = System.Drawing.Color.Wheat;
            }
            else
            {
                DataRow drGB     = dsGB.Tables[0].Rows[0];
                string  mbalance = System.Math.Round(CheckNull(drGB["RO_qty"].ToString()), 5).ToString();
                if (mbalance == "0")
                {
                    txtbalance.Text = txtalotqty.Text;
                }
                else
                {
                    float mrobal  = CheckNull(drGB["RO_qty"].ToString());
                    float mroalot = CheckNull(txtalotqty.Text);
                    float macbal  = mroalot - mrobal;

                    //txtbalance.Text = System.Math.Round(CheckNull(drGB["RO_qty"].ToString()), 5).ToString();
                    txtbalance.Text     = macbal.ToString();
                    txtbalance.ReadOnly = true;
                    // txtbalance.BackColor = System.Drawing.Color.Wheat;
                }
            }
        }
    }
Esempio n. 5
0
    private void GetDistrict()
    {
        Dobj = new Districts(ComObj);

        string qrySelect = "SELECT * FROM DistrictMaster order by DistrictName";

        DataSet ds = Dobj.selectAny(qrySelect);

        if (ds == null)
        {
        }
        else
        {
            //for first District DropdownList
            ddl_District.DataSource     = ds.Tables[0];
            ddl_District.DataValueField = "DistrictCode";
            ddl_District.DataTextField  = "DistrictName";
            ddl_District.DataBind();
            ddl_District.Items.Insert(0, "All");

            //for sencond District DropdownList
            ddl_District_Fetch.DataSource     = ds.Tables[0];
            ddl_District_Fetch.DataValueField = "DistrictCode";
            ddl_District_Fetch.DataTextField  = "DistrictName";
            ddl_District_Fetch.DataBind();
            ddl_District_Fetch.Items.Insert(0, "--Select--");

            //for sencond District DropdownList
            ddl_District_Selected.DataSource     = ds.Tables[0];
            ddl_District_Selected.DataValueField = "DistrictCode";
            ddl_District_Selected.DataTextField  = "DistrictName";
            ddl_District_Selected.DataBind();
            ddl_District_Selected.Items.Insert(0, "--Select--");

            //for fourth District DropdownList
            ddl_AddNewDistrict.DataSource     = ds.Tables[0];
            ddl_AddNewDistrict.DataValueField = "DistrictCode";
            ddl_AddNewDistrict.DataTextField  = "DistrictName";
            ddl_AddNewDistrict.DataBind();
            ddl_AddNewDistrict.Items.Insert(0, "--Select--");
        }
    }
Esempio n. 6
0
    protected void ddldistoff_SelectedIndexChanged(object sender, EventArgs e)
    {
        string qry = "SELECT Max(PcId) as PcId  FROM tbl_MetaData_Purchase_Center";

        DObj = new Districts(ComObj);
        DataSet ds = DObj.selectAny(qry);

        if (ds == null)
        {
        }
        else

        {
            DataRow dr = ds.Tables[0].Rows[0];
            txtpcid.Text = dr["PcId"].ToString();
            Int64 pcid = Int64.Parse(dr["PcId"].ToString());
            pcid         = pcid + 1;
            txtpcid.Text = pcid.ToString();
        }
    }
    private void getDistrcts()
    {
        Dobj = new Districts(ComObj);

        string qrySelect = "SELECT * FROM DistrictMaster order by DistrictName";

        DataSet ds = Dobj.selectAny(qrySelect);

        if (ds == null)
        {
        }
        else
        {
            DDL_Dist.DataSource     = ds.Tables[0];
            DDL_Dist.DataValueField = "DistrictCode";
            DDL_Dist.DataTextField  = "DistrictName";
            DDL_Dist.DataBind();
            DDL_Dist.Items.Insert(0, "--Select--");
        }
    }
Esempio n. 8
0
    void GetRate()
    {
        string qry = "Select Rate from dbo.SCSC_MSP_rate where Commodity_ID='" + ddlcomdty.SelectedValue + "'and Purchase_From='03'and District_code='" + rodist + "'";

        DObj = new Districts(ComObj);
        DataSet ds = DObj.selectAny(qry);

        if (ds.Tables[0].Rows.Count == 0)
        {
            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('There is no Rate available for selected commodity....'); </script> ");
            txtroqty.ReadOnly = false;
        }
        else
        {
            DataRow dr = ds.Tables[0].Rows[0];
            txtrate.Text     = CheckNull(dr["Rate"].ToString()).ToString();
            txtrate.ReadOnly = true;
            // txtrate.BackColor = System.Drawing.Color.Wheat;
        }
    }
Esempio n. 9
0
    void GetRate()
    {
        string mcomdty   = ddlcomdty.SelectedValue;
        string mscheme   = ddlscheme.SelectedValue;
        string todaydate = DateTime.Today.ToString("MM/dd/yyyy");
        string qry       = "Select Rate from dbo.SCSC_MSP_rate where Commodity_ID='" + mcomdty + "'and Purchase_From='03' and Scheme_ID='" + mscheme + "' and District_code='" + ddldistrict.SelectedValue + "' and Effective_From<='" + todaydate + "' order by Effective_From desc";

        DObj = new Districts(ComObj);
        DataSet ds = DObj.selectAny(qry);

        if (ds == null)
        {
            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('There is no Rate available for selected commodity....'); </script> ");
            txtroqty.ReadOnly       = false;
            txtrate.Text            = "0";
            ddlscheme.SelectedIndex = 0;
            ddlcomdty.SelectedIndex = 0;
            txtrate.Focus();
        }
        else
        {
            if (ds.Tables[0].Rows.Count == 0)
            {
                Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('There is no Rate available for selected commodity....'); </script> ");
                txtroqty.ReadOnly = false;
                txtrate.Text      = "0";
                txtrate.Focus();
            }
            else
            {
                DataRow dr = ds.Tables[0].Rows[0];

                txtrate.Text     = CheckNull(dr["Rate"].ToString()).ToString();
                txtrate.ReadOnly = true;
                // txtrate.BackColor = System.Drawing.Color.Wheat;
                txtroqty.Focus();
            }
        }
    }
Esempio n. 10
0
    protected void GetRate()
    {
        string qry = "Select Rate from dbo.SCSC_MSP_rate where Scheme_ID='" + ddl_scheme.SelectedValue + "'and Commodity_ID='" + ddl_commodity.SelectedValue + "'";

        DObj = new Districts(ComObj);
        DataSet ds = DObj.selectAny(qry);

        if (ds.Tables[0].Rows.Count == 0)
        {
            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('There is no Rate available for selected commodity....'); </script> ");

            tx_rate_qt.ReadOnly = false;
            tx_rate_qt.Focus();
        }
        else
        {
            DataRow dr = ds.Tables[0].Rows[0];
            tx_rate_qt.Text      = dr["Rate"].ToString();
            tx_rate_qt.ReadOnly  = true;
            tx_rate_qt.BackColor = System.Drawing.Color.Wheat;
            tx_rate_qt.Focus();
        }
    }
Esempio n. 11
0
    protected void ddl_scheme_SelectedIndexChanged(object sender, EventArgs e)
    {
        //if (ddl_scheme.SelectedItem.Text == "Select" || ddl_commodity.SelectedItem.Text == "Select" )
        //{
        //    Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Please select Commodity/Scheme...');</script>");
        //}
        //else
        //{
        //    tx_do_no.Focus();
        //    GetRate();
        //    get_ComdtyBal();
        //}

        string sctype    = ddl_scheme.SelectedItem.Text;
        int    malot     = int.Parse(ddl_allot_month.SelectedValue.ToString());
        int    malotyear = int.Parse(ddd_allot_year.SelectedValue.ToString());
        string commodty  = ddl_commodity.SelectedValue;
        string mscheme   = ddl_scheme.SelectedValue;

        if (sctype == "APL" || sctype == "BPL" || sctype == "AAY")
        {
            txtcomdty_bal.Text = "";

            if (ddl_scheme.SelectedItem.Text == "Non Scheme" || ddl_scheme.SelectedItem.Text == "--Select--" || ddl_commodity.SelectedItem.Text == "--Select--")
            {
                Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Please select Commodity/Scheme...');</script>");
            }
            else
            {
                string comm   = ddl_commodity.SelectedItem.Text;
                string scheme = ddl_scheme.SelectedItem.Text;
                int    amonth = int.Parse(ddl_allot_month.SelectedItem.Value);
                int    ayear  = int.Parse(ddd_allot_year.SelectedItem.Value);

                string commodity = "";
                if (scheme.ToLower() == "apl")
                {
                    if (comm.ToLower().Contains("wheat"))
                    {
                        commodity = "wheat_apl_alloc";
                    }
                    if (comm.ToLower().Contains("rice"))
                    {
                        commodity = "rice_apl_alloc";
                    }
                    if (comm.ToLower().Contains("sugar"))
                    {
                        commodity = "sugar_alloc";
                    }
                }
                if (scheme.ToLower() == "bpl")
                {
                    if (comm.ToLower().Contains("wheat"))
                    {
                        commodity = "wheat_bpl_alloc";
                    }
                    if (comm.ToLower().Contains("rice"))
                    {
                        commodity = "rice_bpl_alloc";
                    }
                    if (comm.ToLower().Contains("sugar"))
                    {
                        commodity = "sugar_alloc";
                    }
                }
                if (scheme.ToLower() == "aay")
                {
                    if (comm.ToLower().Contains("wheat"))
                    {
                        commodity = "wheat_aay_alloc";
                    }
                    if (comm.ToLower().Contains("rice"))
                    {
                        commodity = "rice_aay_alloc";
                    }
                    if (comm.ToLower().Contains("sugar"))
                    {
                        commodity = "sugar_alloc";
                    }
                }
                if (commodity != "")
                {
                    cmd.CommandText = "select  " + commodity + "   from pds.state_alloc where district_code='" + distid + "' and month='" + malot + "' and Year='" + malotyear + "'";
                    cmd.Connection  = con_opdms;
                    con_opdms.Open();
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        if (dr[commodity].ToString() == "")
                        {
                            txtcomdty_bal.Text = "0";
                        }
                        else
                        {
                            txtcomdty_bal.Text = System.Math.Round(decimal.Parse(dr[commodity].ToString()), 2).ToString();
                        }
                    }
                    dr.Close();
                    con_opdms.Close();
                }
                if (txtcomdty_bal.Text == "")
                {
                    txtcomdty_bal.Text = "0";
                    Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('There is no Allotment for Selected Commodity...');</script>");
                }
                GetRate();
                GetRoBalance();
                GetBalanceQty();
            }
            txtcomdty_bal.ReadOnly  = true;
            txtcomdty_bal.BackColor = System.Drawing.Color.Wheat;
        }
        else
        {
            DObj = new Districts(ComObj);
            string  malloc = "select alloc_qty from dbo.dist_mpscsc_alloc where district_code='" + distid + "' and alloc_month=" + malot + " and alloc_year=" + malotyear + " and commodity_id='" + commodty + "' and scheme_id='" + mscheme + "'";
            DataSet dsGB   = DObj.selectAny(malloc);
            if (dsGB == null)
            {
            }
            else
            {
                if (dsGB.Tables[0].Rows.Count == 0)
                {
                    Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('There is no Allotment for Selected Commodity...');</script>");
                    decimal mbqty = CheckNull(txtcomdty_bal.Text) - CheckNull(tx_qty.Text);
                    txtbalqty.Text          = mbqty.ToString();
                    txtcomdty_bal.Text      = "0";
                    txtbalqty.ReadOnly      = true;
                    txtbalqty.BackColor     = System.Drawing.Color.Wheat;
                    txtcomdty_bal.ReadOnly  = true;
                    txtcomdty_bal.BackColor = System.Drawing.Color.Wheat;
                }
                else
                {
                    DataRow drGB = dsGB.Tables[0].Rows[0];
                    txtcomdty_bal.Text      = System.Math.Round(CheckNull(drGB["alloc_qty"].ToString()), 5).ToString();
                    txtcomdty_bal.ReadOnly  = true;
                    txtcomdty_bal.BackColor = System.Drawing.Color.Wheat;
                }
            }
            GetBalanceQty();
            GetRate();
        }
    }
Esempio n. 12
0
    void GetRoBalance()
    {
        string comodity = "";

        if (ddl_commodity.SelectedItem.Text.ToLower().Contains("wheat"))
        {
            comodity = "wheat";
        }

        if (ddl_commodity.SelectedItem.Text.ToLower().Contains("rice"))
        {
            comodity = "rice";
        }

        if (ddl_commodity.SelectedItem.Text.ToLower().Contains("sugar"))
        {
            comodity = "sugar";
        }

        string comdty = "";
        string qrycom = "Select Commodity_ID from dbo.tbl_MetaData_STORAGE_COMMODITY where lower(Commodity_Name) like'%" + comodity + "%'";

        cmd.CommandText = qrycom;
        cmd.Connection  = con;
        con.Open();
        dr = cmd.ExecuteReader();

        while (dr.Read())
        {
            comdty = comdty + dr["Commodity_ID"].ToString();
            comdty = comdty + ",";
        }
        con.Close();
        dr.Close();
        int ind;

        ind    = comdty.LastIndexOf(",");
        comdty = comdty.Remove(ind, 1);

        string commid   = ddl_commodity.SelectedValue;;
        string schemeid = ddl_scheme.SelectedValue;
        int    month    = int.Parse(ddl_allot_month.SelectedValue);
        int    year     = int.Parse(ddd_allot_year.SelectedValue);


        string qryGB = "Select Round(convert(decimal,Sum(RO_qty)),5) as RO_qty from dbo.RO_of_FCI group by Distt_Id,Commodity,Allot_month,Allot_year,scheme having (Commodity in(" + comdty + ")) and (Distt_Id='" + distid + "') and (Allot_month=" + month + ")and (Allot_year=" + year + ") and (Scheme='" + schemeid + "')";

        DObj = new Districts(ComObj);
        DataSet dsGB = DObj.selectAny(qryGB);

        if (dsGB == null)
        {
        }
        else
        {
            if (dsGB.Tables[0].Rows.Count == 0)
            {
                decimal mbqty = CheckNull(txtcomdty_bal.Text);
                txtrobalqty.Text      = "0";
                txtrobalqty.ReadOnly  = true;
                txtrobalqty.BackColor = System.Drawing.Color.Wheat;
            }
            else
            {
                DataRow drGB = dsGB.Tables[0].Rows[0];

                decimal mrobal = CheckNull(drGB["RO_qty"].ToString());
                txtrobalqty.Text = mrobal.ToString();
            }
        }
    }
Esempio n. 13
0
    void GetBalanceQty()
    {
        string comodity = "";

        if (ddl_commodity.SelectedItem.Text.ToLower().Contains("wheat"))
        {
            comodity = "wheat";
        }

        if (ddl_commodity.SelectedItem.Text.ToLower().Contains("rice"))
        {
            comodity = "rice";
        }

        if (ddl_commodity.SelectedItem.Text.ToLower().Contains("sugar"))
        {
            comodity = "sugar";
        }

        string comdty = "";
        string qrycom = "Select Commodity_ID from dbo.tbl_MetaData_STORAGE_COMMODITY where lower(Commodity_Name) like'%" + comodity + "%'";

        cmd.CommandText = qrycom;
        cmd.Connection  = con;
        con.Open();
        dr = cmd.ExecuteReader();

        while (dr.Read())
        {
            comdty = comdty + dr["Commodity_ID"].ToString();
            comdty = comdty + ",";
        }
        con.Close();
        dr.Close();
        int ind;

        ind    = comdty.LastIndexOf(",");
        comdty = comdty.Remove(ind, 1);

        string commid   = ddl_commodity.SelectedValue;;
        string schemeid = ddl_scheme.SelectedValue;
        int    month    = int.Parse(ddl_allot_month.SelectedValue);
        int    year     = int.Parse(ddd_allot_year.SelectedValue);


        string qryGB = "Select Round(convert(decimal,Sum(quantity)),5) as RO_qty from dbo.delivery_order_mpscsc group by district_code,commodity_id,allotment_month,allotment_year,scheme_id,issue_type having (commodity_id in(" + comdty + ")) and (district_code='" + distid + "') and (allotment_month=" + month + ")and (allotment_year=" + year + ") and (scheme_id='" + schemeid + "') and (issue_type='FCI')";

        DObj = new Districts(ComObj);
        DataSet dsGB = DObj.selectAny(qryGB);

        if (dsGB == null)
        {
        }
        else
        {
            if (dsGB.Tables[0].Rows.Count == 0)
            {
                decimal mbqty  = CheckNull(txtcomdty_bal.Text);
                decimal mdoqty = CheckNull(txtrobalqty.Text);

                txtbalqty.Text      = (mbqty - mdoqty).ToString();
                txtbalqty.ReadOnly  = true;
                txtbalqty.BackColor = System.Drawing.Color.Wheat;
            }
            else
            {
                DataRow drGB     = dsGB.Tables[0].Rows[0];
                string  mbalance = System.Math.Round(CheckNull(drGB["RO_qty"].ToString()), 5).ToString();
                if (mbalance == "0")
                {
                    txtbalqty.Text = txtcomdty_bal.Text;
                }
                else
                {
                    decimal mrobal  = CheckNull(drGB["RO_qty"].ToString());
                    decimal mroalot = CheckNull(txtcomdty_bal.Text);
                    decimal mdoqty  = CheckNull(txtrobalqty.Text);
                    decimal macbal  = mroalot - mrobal - mdoqty;

                    //txtbalqty.Text = System.Math.Round(CheckNull(drGB["RO_qty"].ToString()), 5).ToString();
                    txtbalqty.Text      = macbal.ToString();
                    txtbalqty.ReadOnly  = true;
                    txtbalqty.BackColor = System.Drawing.Color.Wheat;
                }
            }
        }
    }
Esempio n. 14
0
    protected void btnsave_Click(object sender, EventArgs e)
    {
        if (txtchqamt.Text == "" || txtckeckno.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please Enter Payment Details....'); </script> ");
        }
        else
        {
            string mronoc = txtrono.Text;
            mobj2 = new MoveChallan(ComObj);
            string qryrochk = "select *  from dbo.RO_of_FCI where Distt_Id='" + distid + "'and RO_No='" + mronoc + "'";

            DataSet dsrochk = mobj2.selectAny(qryrochk);

            if (dsrochk.Tables[0].Rows.Count == 0)
            {
                //DataRow drro = dsro.Tables[0].Rows[0];

                if (ddlcomdty.SelectedItem.Text == "--Select--" || ddlscheme.SelectedItem.Text == "--Select--")
                {
                    Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please Select The Commodity /Scheme/BankName....'); </script> ");
                }
                else
                {
                    DateTime fdate = new DateTime();
                    DateTime tdate = new DateTime();

                    string fromdate = getDate_MDY(txtrodate.Text);
                    string todate   = getDate_MDY(txtrovalidity.Text);

                    fdate = Convert.ToDateTime(fromdate);
                    tdate = Convert.ToDateTime(todate);

                    string validity = get_days(fdate, tdate);
                    if (int.Parse(validity) > 25)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Validity Should not be more than 25 days'); </script> ");
                    }
                    else
                    {
                        if (Page.IsValid)
                        {
                            decimal mroqty = CheckNull(txtroqty.Text);
                            if (mroqty == 0)
                            {
                                Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please Enter Quantity....'); </script> ");
                                txtroqty.Focus();
                            }

                            else
                            {
                                string mdistid = distid;
                                string mrono   = txtrono.Text;
                                string mrodate = getDate_MDY(txtrodate.Text);
                                string mvdate  = getDate_MDY(txtrovalidity.Text);

                                string  mrodist = ddldistrict.SelectedValue;
                                string  mcomdty = ddlcomdty.SelectedValue;
                                string  mscheme = ddlscheme.SelectedValue;
                                decimal mrate   = CheckNull(txtrate.Text);
                                decimal mamt    = CheckNull(txtamount.Text);
                                string  mallotm = ddlalotmm.SelectedValue;
                                string  myear   = DateTime.Today.Year.ToString();
                                string  mddno   = txtckeckno.Text;
                                string  mdddate = getDate_MDY(txtddate.Text);
                                decimal mddamt  = CheckNull(txtchqamt.Text);
                                string  mremark = txtremark.Text;
                                string  mislift = "N";
                                //string mcrdate = DateTime.Today.Date.ToString();

                                //string mcrtdate = getDate_MDY(mcrdate);
                                string  mudate = "";
                                string  mddate = "";
                                decimal mbqty  = decimal.Parse(txtroqty.Text);

                                decimal mallotqty  = CheckNull(txtalotqty.Text);
                                decimal mbalqty    = CheckNull(txtbalance.Text);
                                decimal mrobalance = mbalqty - CheckNull(txtroqty.Text);
                                int     maltmonth  = int.Parse(ddlalotmm.SelectedValue);
                                int     maltyear   = int.Parse(ddlallot_year.SelectedValue);
                                string  mbank      = ddlbankname.SelectedValue;
                                string  iex        = "N";
                                string  pmode      = ddlpaymenttype.SelectedValue;


                                string ip      = Request.ServerVariables["REMOTE_ADDR"].ToString();
                                string opid    = Session["OperatorIDDM"].ToString();
                                string state   = Session["State_Id"].ToString();
                                string notrans = "N";


                                string qryInsert = "insert into dbo.RO_of_FCI(State_Id,Distt_Id,RO_No,RO_date,RO_qty,RO_Validity,RO_district,Commodity,Scheme,Rate,Amount,Allot_month,Allot_year,DD_chk_no,DD_chk_date,DD_chk_Amount,Bank_ID,Remarks,IsLifted,Created_date,updated_date,deleted_date,Balance_Qty,IsExpire,IP_Address,Payment_Mode,OperatorID,NoTransaction)values('" + state + "','" + mdistid + "','" + mrono + "','" + mrodate + "'," + mroqty + ",'" + mvdate + "','" + mrodist + "','" + mcomdty + "','" + mscheme + "'," + mrate + "," + mamt + ",'" + mallotm + "','" + myear + "','" + mddno + "','" + mdddate + "'," + mddamt + ",'" + mbank + "','" + mremark + "','" + mislift + "',getdate(),'" + mudate + "','" + mddate + "'," + mbqty + ",'" + iex + "','" + ip + "','" + pmode + "','" + opid + "','" + notrans + "')";

                                cmd.CommandText = qryInsert;
                                cmd.Connection  = con;
                                con.Open();
                                SqlTransaction trns;
                                trns            = con.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
                                cmd.Transaction = trns;
                                try
                                {
                                    if (mbqty > mbalqty)
                                    {
                                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('RO Quantity Should not be greater than Balance Qty....'); </script> ");
                                        txtroqty.Focus();
                                    }
                                    else
                                    {
                                        int count = cmd.ExecuteNonQuery();
                                        if (count == 1)
                                        {
                                            string   trans    = "Insert";
                                            DateTime date     = DateTime.Now;
                                            string   qryTrans = "insert into dbo.tbl_ROFCI_Transuction(State_Id,Distt_Id,RO_No,RO_date,RO_qty,RO_Validity,RO_district,Commodity,Scheme,Rate,Amount,Allot_month,Allot_year,DD_chk_no,DD_chk_date,DD_chk_Amount,Bank_ID,Remarks,Operation,Trans_Date,IP_Address,User_ID,OperatorID)values('" + state + "','" + mdistid + "','" + mrono + "','" + mrodate + "'," + mroqty + ",'" + mvdate + "','" + mrodist + "','" + mcomdty + "','" + mscheme + "'," + mrate + "," + mamt + ",'" + mallotm + "','" + myear + "','" + mddno + "','" + mdddate + "'," + mddamt + ",'" + mbank + "','" + mremark + "','" + trans + "',getdate(),'" + ip + "','" + distid + "','" + opid + "')";
                                            cmd.CommandText = qryTrans;
                                            cmd.Transaction = trns;
                                            cmd.ExecuteNonQuery();

                                            int     month = int.Parse(ddlalotmm.SelectedValue);
                                            int     year  = int.Parse(ddlallot_year.SelectedValue);
                                            decimal mlift = 0;
                                            string  qryGD = "Select Balance_Qty,Allotment_Qty from dbo.District_Alloc where Scheme_ID='" + mscheme + "'and Commodity_ID='" + mcomdty + "' and district_code='" + distid + "' and Month=" + month + "and Year=" + year;

                                            DObj = new Districts(ComObj);
                                            DataSet dsGD = DObj.selectAny(qryGD);
                                            if (dsGD.Tables[0].Rows.Count == 0)
                                            {
                                                string qrydalloc = "insert into dbo.District_Alloc(State_Id,district_code,Month,Year,Commodity_ID,Scheme_ID,Allotment_Qty,Balance_Qty,Lifted_Qty,OperatorID)values('" + state + "','" + distid + "'," + mallotm + "," + maltyear + ",'" + mcomdty + "','" + mscheme + "'," + mallotqty + "," + mrobalance + "," + mlift + ",'" + opid + "')";
                                                cmd.CommandText = qrydalloc;
                                                cmd.Transaction = trns;
                                                cmd.ExecuteNonQuery();
                                            }
                                            else
                                            {
                                                string qrydallocU = "Update dbo.District_Alloc set Balance_Qty =" + mrobalance + " where Scheme_ID='" + mscheme + "'and Commodity_ID='" + mcomdty + "' and district_code='" + distid + "'and Month=" + month + "and Year=" + year;
                                                cmd.Connection  = con;
                                                cmd.CommandText = qrydallocU;
                                                cmd.Transaction = trns;
                                                cmd.ExecuteNonQuery();
                                            }
                                        }
                                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully...'); </script> ");

                                        btnsave.Enabled = false;
                                    }

                                    trns.Commit();
                                }
                                catch (Exception ex)
                                {
                                    trns.Rollback();
                                    Label1.Visible = true;
                                    Label1.Text    = ex.Message;
                                }
                                finally
                                {
                                    con.Close();
                                    ComObj.CloseConnection();
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Release Order Number Already Exist....'); </script> ");
            }
        }
    }
Esempio n. 15
0
    void GetAllotment()
    {
        string sctype    = lblsch.Text;
        int    malot     = int.Parse(ddlalotmm.SelectedValue.ToString());
        int    malotyear = int.Parse(ddlallot_year.SelectedValue.ToString());
        string commodty  = ddlcomdty.SelectedValue;
        string mscheme   = ddlscheme.SelectedValue;

        if (sctype == "1" || sctype == "2" || sctype == "3")
        {
            txtalotqty.Text = "";

            if (ddlscheme.SelectedItem.Text == "Non Scheme" || ddlscheme.SelectedItem.Text == "--Select--" || ddlcomdty.SelectedItem.Text == "--Select--")
            {
                Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Please select Commodity/Scheme...');</script>");
            }
            else
            {
                //GetRate();
                string comm   = ddlcomdty.SelectedItem.Text;
                string scheme = ddlscheme.SelectedItem.Text;
                int    amonth = int.Parse(ddlalotmm.SelectedItem.Value);
                int    ayear  = int.Parse(DateTime.Today.Year.ToString());

                string commodity = "";
                if (scheme.ToLower() == "apl")
                {
                    if (comm.ToLower().Contains("wheat"))
                    {
                        commodity = "wheat_apl_alloc";
                    }
                    if (comm.ToLower().Contains("rice"))
                    {
                        commodity = "rice_apl_alloc";
                    }
                    if (comm.ToLower().Contains("sugar"))
                    {
                        commodity = "sugar_alloc";
                    }
                }
                if (scheme.ToLower() == "bpl")
                {
                    if (comm.ToLower().Contains("wheat"))
                    {
                        commodity = "wheat_bpl_alloc";
                    }
                    if (comm.ToLower().Contains("rice"))
                    {
                        commodity = "rice_bpl_alloc";
                    }
                    if (comm.ToLower().Contains("sugar"))
                    {
                        commodity = "sugar_alloc";
                    }
                }
                if (scheme.ToLower() == "aay")
                {
                    if (comm.ToLower().Contains("wheat"))
                    {
                        commodity = "wheat_aay_alloc";
                    }
                    if (comm.ToLower().Contains("rice"))
                    {
                        commodity = "rice_aay_alloc";
                    }
                    if (comm.ToLower().Contains("sugar"))
                    {
                        commodity = "sugar_alloc";
                    }
                }
                if (commodity != "")
                {
                    cmd.CommandText = "select  " + commodity + "   from pds.state_alloc where district_code='" + rodist + "' and month='" + amonth + "' and Year='" + ayear + "'";
                    cmd.Connection  = con_opdms;
                    con_opdms.Open();
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        if (dr[commodity].ToString() == "")
                        {
                            txtalotqty.Text = "0";
                        }
                        else
                        {
                            txtalotqty.Text = System.Math.Round(float.Parse(dr[commodity].ToString()), 2).ToString();
                        }
                    }
                    dr.Close();
                    con_opdms.Close();
                }
                if (txtalotqty.Text == "")
                {
                    txtalotqty.Text = "0";
                    Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('There is no Allotment for Selected Commodity...');</script>");
                }

                GetBalanceQty();
            }
            txtalotqty.ReadOnly = true;
            // txtalotqty.BackColor = System.Drawing.Color.Wheat;
        }
        else
        {
            DObj = new Districts(ComObj);
            string  malloc = "select alloc_qty from dbo.dist_mpscsc_alloc where district_code='" + rodist + "' and alloc_month=" + malot + " and alloc_year=" + malotyear + " and commodity_id='" + commodty + "' and scheme_id='" + mscheme + "'";
            DataSet dsGB   = DObj.selectAny(malloc);
            if (dsGB == null)
            {
            }
            else
            {
                if (dsGB.Tables[0].Rows.Count == 0)
                {
                    Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('There is no Allotment for Selected Commodity...');</script>");
                    float mbqty = CheckNull(txtalotqty.Text) - CheckNull(txtroqty.Text);
                    txtbalance.Text     = mbqty.ToString();
                    txtalotqty.Text     = "0";
                    txtbalance.ReadOnly = true;
                    // txtbalance.BackColor = System.Drawing.Color.Wheat;
                    txtalotqty.ReadOnly = true;
                    // txtalotqty.BackColor = System.Drawing.Color.Wheat;
                }
                else
                {
                    DataRow drGB = dsGB.Tables[0].Rows[0];
                    txtalotqty.Text     = System.Math.Round(CheckNull(drGB["alloc_qty"].ToString()), 5).ToString();
                    txtalotqty.ReadOnly = true;
                    // txtalotqty.BackColor = System.Drawing.Color.Wheat;
                }
            }
            GetBalanceQty();
        }
    }