Exemplo n.º 1
0
    //void GetDepot()
    //{

    //    distobj = new DistributionCenters(ComObj);
    //    string ord = "Districtid='23" + distid  + "' order by DepotName";
    //    DataSet ds = distobj.select(ord);

    //    ddlgodown.DataSource = ds.Tables[0];
    //    ddlgodown.DataTextField = "DepotName";
    //    ddlgodown.DataValueField = "DepotId";
    //    ddlgodown.DataBind();
    //    ddlgodown.Items.Insert(0, "--Select--");


    //}
    void GetAllDepot()
    {
        distobj = new DistributionCenters(ComObj);
        string  ordall = "Select DepotName,DepotId from dbo.tbl_MetaData_DEPOT Order by DepotName";
        DataSet ds     = distobj.selectAny(ordall);

        ddlissuecenter.DataSource     = ds.Tables[0];
        ddlissuecenter.DataTextField  = "DepotName";
        ddlissuecenter.DataValueField = "DepotId";
        ddlissuecenter.DataBind();
        ddlissuecenter.Items.Insert(0, "--Select--");
    }
Exemplo n.º 2
0
    void GetDCNameAll()
    {
        distobj = new DistributionCenters(ComObj);
        string  ord = "Select DepotName,DepotID from dbo.tbl_MetaData_DEPOT order by DepotName";
        DataSet ds  = distobj.selectAny(ord);

        ddlissue.DataSource     = ds.Tables[0];
        ddlissue.DataTextField  = "DepotName";
        ddlissue.DataValueField = "DepotID";
        ddlissue.DataBind();
        ddlissue.Items.Insert(0, "--Select--");
        // ddDistId.Items.Insert(0, "--चुनिये--");
    }
Exemplo n.º 3
0
    void GetDCName()
    {
        //ddlissue.Items.Clear();
        distobj = new DistributionCenters(ComObj);
        string  ord = "Select * from tbl_MetaData_Depot  order by DepotName";
        DataSet ds  = distobj.selectAny(ord);

        ddlissueCenter.DataSource     = ds.Tables[0];
        ddlissueCenter.DataTextField  = "DepotName";
        ddlissueCenter.DataValueField = "DepotID";
        ddlissueCenter.DataBind();
        // ddDistId.Items.Insert(0, "--चुनिये--");
    }
Exemplo n.º 4
0
    void GetDCNameAll()
    {
        ddlissuename.Items.Clear();
        distobj = new DistributionCenters(ComObj);
        string getg = "Select * from tbl_MetaData_DEPOT order by DepotName";
        //string ord = "Districtid='23" + ddldestdistrict.SelectedValue + "' order by DepotName";
        DataSet ds = distobj.selectAny(getg);

        ddlissuename.DataSource     = ds.Tables[0];
        ddlissuename.DataTextField  = "DepotName";
        ddlissuename.DataValueField = "DepotId";

        ddlissuename.DataBind();
        ddlissuename.Items.Insert(0, "--Select--");

        // ddDistId.Items.Insert(0, "--चुनिये--");
    }
Exemplo n.º 5
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (CheckNull(txtbalqty.Text) == 0)
        {
            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('You have insufficient balance to transfer......'); </script> ");
        }
        else
        {
            if (ddlissue.SelectedValue == ddlissued.SelectedValue && ddlscheme.SelectedValue == ddlschemetrs.SelectedValue && ddlsarrival.SelectedValue == ddlarrivalsource.SelectedValue)
            {
                Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Source and Destination Information Should not be same......'); </script> ");
            }
            else
            {
                string mstate = "23";
                string mcomid = ddlcomdty.SelectedValue;

                string   mscheme  = ddlscheme.SelectedValue;
                string   mdscheme = ddlschemetrs.SelectedValue;
                string   msdist   = ddldistrict.SelectedValue;
                string   msissue  = ddlissue.SelectedValue;
                string   mddist   = ddldistrictd.SelectedValue;
                string   mdissue  = ddlissued.SelectedValue;
                string   issueid  = ddlissue.SelectedValue;
                string   fromsrs  = ddlsarrival.SelectedValue;
                string   tosrs    = ddlarrivalsource.SelectedValue;
                int      mbagst   = CheckNullInt(txtbags.Text);
                string   mgdn     = ddlgodown.SelectedValue;
                string   ddate    = "";
                string   udate    = "";
                int      openqty  = 0;
                int      openbag  = 0;
                int      mmonth   = int.Parse(DateTime.Today.Month.ToString());
                int      myear    = int.Parse(DateTime.Today.Year.ToString());
                float    qty      = CheckNull(txtqty.Text);
                string   ip       = Request.ServerVariables["REMOTE_ADDR"].ToString();
                string   stdate   = getDate_MDY(tx_stdate.Text);
                string   cdate    = DateTime.Today.Date.ToString();
                DateTime std      = DateTime.Parse(getDate_MDY(tx_stdate.Text));
                string   opid     = Session["OperatorId"].ToString();
                string   stm      = std.Month.ToString();
                string   sty      = std.Year.ToString();
                if (ddlcomdty.SelectedItem.Text == "--Select--" || ddlscheme.SelectedItem.Text == "--Select--" || ddlschemetrs.SelectedItem.Text == "--Select--" || ddlarrivalsource.SelectedItem.Text == "--Select--" || ddlsarrival.SelectedItem.Text == "--Select--")
                {
                    Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please  Select Commodity/Scheme/Source of Arrival......'); </script> ");
                }
                else
                {
                    string qrey = "insert into dbo.State_Scheme_Transfer(State_Id,District_Id,Depotid,Commodity_Id,S_Scheme_Id,D_District,D_Depot,D_Scheme_Id,Quantity,Month,Year,CreatedDate,UpdatedDate,DeletedDate,IP_Address,Bags,From_Source,To_Source,Godown,ST_Date,OperatorID) values('" + mstate + "','" + distid + "','" + sid + "','" + mcomid + "','" + mscheme + "','" + mddist + "','" + sid + "','" + mdscheme + "'," + qty + "," + stm + "," + sty + ",getdate(),'" + udate + "','" + ddate + "','" + ip + "'," + mbagst + ",'" + fromsrs + "','" + tosrs + "','" + mgdn + "','" + stdate + "','" + opid + "')";
                    cmd.CommandText = qrey;
                    cmd.Connection  = con;
                    con.Open();
                    //SqlTransaction trns;
                    //trns = con.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
                    //cmd.Transaction = trns;
                    try
                    {
                        if (qty == 0)
                        {
                            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Quantity Should not be 0 ......'); </script> ");
                        }
                        else
                        {
                            //if (ddlscheme.SelectedValue == ddlschemetrs.SelectedValue)
                            //{
                            //    Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Source and Destination Scheme Should not be Same ......'); </script> ");
                            //}
                            //else
                            //{

                            cmd.ExecuteNonQuery();
                            con.Close();

                            string qrystock = "select Sum(Quantity) as Qty from dbo.State_Scheme_Transfer where Commodity_Id='" + mcomid + "'and S_Scheme_Id='" + mscheme + "' and District_Id='" + distid + "'and Depotid='" + issueid + "' and Month=" + stm + "and Year=" + sty;
                            mobj = new MoveChallan(ComObj);
                            DataSet dspro = mobj.selectAny(qrystock);
                            if (dspro.Tables[0].Rows.Count == 0)
                            {
                            }
                            else
                            {
                                DataRow drop = dspro.Tables[0].Rows[0];

                                float mrothersch = CheckNull(drop["Qty"].ToString());


                                string qryinsopen = "select * from dbo.tbl_Stock_Registor where Commodity_Id ='" + mcomid + "' and Scheme_Id='" + mscheme + "' and DistrictId ='" + distid + "'and DepotID='" + sid + "'and Month=" + stm + "and Year=" + sty;
                                mobj = new MoveChallan(ComObj);
                                DataSet dsopen = mobj.selectAny(qryinsopen);

                                if (dsopen.Tables[0].Rows.Count == 0)
                                {
                                    string chkopenss = "Select Round(convert(decimal(18,5),Sum(Current_Balance)),5)  as Current_Balance   from dbo.issue_opening_balance where District_Id='" + distid + "'and Depotid='" + sid + "'and Commodity_Id='" + mcomid + "'and Scheme_Id ='" + mscheme + "'";
                                    mobj = new MoveChallan(ComObj);
                                    DataSet dsqry = mobj.selectAny(chkopenss);
                                    if (dsqry == null)
                                    {
                                    }

                                    else
                                    {
                                        DataRow drss    = dsqry.Tables[0].Rows[0];
                                        decimal sropen  = CheckNullDec(drss["Current_Balance"].ToString());
                                        string  qryinsr = "insert into dbo.tbl_Stock_Registor(DistrictId,DepotID,Commodity_ID,Scheme_ID,Opening_Balance,Recieved_Procure,Recieved_Otherg,Recieved_FCI,Received_OtherSch,Recieved_Other_Src,Received_RailHead,Received_CMR,Received_Levy,Sale_Do,Sale_otherg,Transfer_OtherSch,Month,Year,Remarks) Values('" + distid + "','" + sid + "','" + mcomid + "','" + mscheme + "'," + sropen + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + CheckNull(txtqty.Text) + "," + stm + "," + sty + ",'')";
                                        cmd.CommandText = qryinsr;
                                        con.Open();
                                        cmd.ExecuteNonQuery();
                                        con.Close();
                                    }
                                }
                                else
                                {
                                    string qryinsU = "update dbo.tbl_Stock_Registor set Transfer_OtherSch=" + mrothersch + " where Commodity_Id ='" + mcomid + "'and  Scheme_Id ='" + mscheme + "' and DistrictId='" + distid + "'and DepotID='" + issueid + "'and Month=" + stm + "and Year=" + sty;
                                    cmd.CommandText = qryinsU;
                                    con.Open();
                                    cmd.ExecuteNonQuery();
                                    con.Close();
                                }


                                string qrystockd = "select Sum(Quantity) as Qty from dbo.State_Scheme_Transfer where Commodity_Id='" + mcomid + "'and D_Scheme_Id='" + mdscheme + "' and District_Id='" + distid + "'and Depotid='" + issueid + "' and Month=" + stm + "and Year=" + sty;
                                mobj = new MoveChallan(ComObj);
                                DataSet dsprod = mobj.selectAny(qrystockd);
                                if (dspro.Tables[0].Rows.Count == 0)
                                {
                                }
                                else
                                {
                                    DataRow dropd = dspro.Tables[0].Rows[0];

                                    float  mrotherschd   = CheckNull(drop["Qty"].ToString());
                                    string qryinsopendes = "select * from dbo.tbl_Stock_Registor where Commodity_Id ='" + mcomid + "'and Scheme_ID='" + mdscheme + "' and DistrictId ='" + distid + "'and DepotID='" + sid + "'and Month=" + stm + "and Year=" + sty;
                                    mobj = new MoveChallan(ComObj);
                                    DataSet dsopends = mobj.selectAny(qryinsopendes);

                                    if (dsopends.Tables[0].Rows.Count == 0)
                                    {
                                        string chkopenss = "Select Round(convert(decimal(18,5),Sum(Current_Balance)),5)  as Current_Balance   from dbo.issue_opening_balance where District_Id='" + distid + "'and Depotid='" + sid + "'and Commodity_Id='" + mcomid + "'and Scheme_Id ='" + mdscheme + "'";
                                        mobj = new MoveChallan(ComObj);
                                        DataSet dsqry = mobj.selectAny(chkopenss);
                                        if (dsqry == null)
                                        {
                                        }

                                        else
                                        {
                                            DataRow drss    = dsqry.Tables[0].Rows[0];
                                            decimal sropen  = CheckNullDec(drss["Current_Balance"].ToString());
                                            string  qryinsr = "insert into dbo.tbl_Stock_Registor(DistrictId,DepotID,Commodity_ID,Scheme_ID,Opening_Balance,Recieved_Procure,Recieved_Otherg,Recieved_FCI,Received_OtherSch,Recieved_Other_Src,Received_RailHead,Received_CMR,Received_Levy,Sale_Do,Sale_otherg,Transfer_OtherSch,Month,Year,Remarks) Values('" + distid + "','" + sid + "','" + mcomid + "','" + mdscheme + "'," + sropen + "," + 0 + "," + 0 + "," + 0 + "," + CheckNull(txtqty.Text) + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + stm + "," + sty + ",'')";
                                            cmd.CommandText = qryinsr;
                                            con.Open();
                                            cmd.ExecuteNonQuery();
                                            con.Close();
                                        }
                                    }
                                    else
                                    {
                                        string qryinsUd = "update dbo.tbl_Stock_Registor set Received_OtherSch=" + mrothersch + " where Commodity_Id ='" + mcomid + "' and Scheme_Id='" + mdscheme + "'and DistrictId='" + distid + "'and DepotID='" + issueid + "'and Month=" + stm + "and Year=" + sty;
                                        cmd.CommandText = qryinsUd;
                                        con.Open();
                                        cmd.ExecuteNonQuery();
                                        con.Close();
                                    }
                                }
                            }


                            float  tqty    = CheckNull(txtqty.Text);
                            int    mtbags  = CheckNullInt(txtbags.Text);
                            string msource = ddlsarrival.SelectedValue;
                            string mgodown = ddlgodown.SelectedValue;

                            string uqry = "Update dbo.issue_opening_balance  set Current_Balance=Round(convert(decimal(18,5),Current_Balance),5)-" + tqty + ",Current_Bags=Current_Bags-" + mtbags + " where District_Id='" + distid + "'and Depotid='" + sid + "'and Commodity_Id='" + mcomid + "'and Scheme_Id='" + mscheme + "' and Source ='" + msource + "' and Godown='" + mgodown + "'";
                            cmd.CommandText = uqry;
                            cmd.Connection  = con;
                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                            string mmsource   = ddlarrivalsource.SelectedValue;
                            string chkopenbal = "Select * from dbo.issue_opening_balance where District_Id='" + distid + "'and Depotid='" + sid + "'and Commodity_Id='" + ddlcommodityd.SelectedValue.ToString() + "'and Scheme_Id='" + mdscheme + "' and Godown='" + mgodown + "' and Source='" + mmsource + "'";
                            distobj = new DistributionCenters(ComObj);
                            DataSet dsbal = distobj.selectAny(chkopenbal);
                            if (dsbal == null)
                            {
                            }

                            else
                            {
                                if (dsbal.Tables[0].Rows.Count == 0)
                                {
                                    string qreyins = "insert into dbo.issue_opening_balance(State_Id,District_Id,Depotid,Commodity_Id,Scheme_Id,Category_Id,Godown,Crop_year,Bags,Quantity,Source,Current_Balance,Current_Bags,Month,Year,IP_Address,Stock_Date,CreatedDate,UpdatedDate,DeletedDate) values('" + mstate + "','" + distid + "','" + sid + "','" + ddlcommodityd.SelectedValue.ToString() + "','" + mdscheme + "','','" + mgodown + "',''," + openbag + "," + openqty + ",'" + mmsource + "'," + tqty + "," + mtbags + "," + mmonth + "," + myear + ",'" + ip + "',getdate(),getdate(),'" + udate + "','" + ddate + "'" + ")";
                                    cmd.CommandText = qreyins;
                                    cmd.Connection  = con;
                                    con.Open();
                                    cmd.ExecuteNonQuery();
                                    con.Close();
                                }
                                else
                                {
                                    float tqtyd = CheckNull(txtqty.Text);
                                    int   tbags = CheckNullInt(txtbags.Text);

                                    string uqryd = "Update dbo.issue_opening_balance  set Current_Balance=Round(convert(decimal(18,5),Current_Balance),5)+" + tqtyd + ",Current_Bags=Current_Bags+" + tbags + " where District_Id='" + distid + "'and Depotid='" + sid + "'and Commodity_Id='" + ddlcommodityd.SelectedValue.ToString() + "'and Scheme_Id='" + mdscheme + "' and Godown='" + mgodown + "' and Source='" + mmsource + "'";
                                    cmd.CommandText = uqryd;
                                    cmd.Connection  = con;
                                    con.Open();
                                    cmd.ExecuteNonQuery();
                                    con.Close();
                                }
                            }



                            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Data Transfer Successfully ......'); </script> ");
                            txtbalqty.ReadOnly = false;
                            //txtbalqty.Text = uqty.ToString();
                            //txtbalqtyd.ReadOnly = false;
                            //txtbalqtyd.Text = uqtyd.ToString();



                            btnsubmit.Enabled = false;
                        }
                        //trns.Commit();
                    }
                    catch (Exception ex)
                    {
                        //trns.Rollback();
                        Label1.Visible = true;
                        Label1.Text    = ex.Message;
                    }
                    finally
                    {
                        con.Close();
                        ComObj.CloseConnection();
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
    void UpdateBalance()
    {
        string comdtyid = lblcomdty.Text;
        string schemeid = lblsch.Text;
        string source   = "07";
        string gdwn     = ddlgodown.SelectedValue;
        string mstate   = "23";
        int    openbag  = 0;
        int    openqty  = 0;
        int    recdbags = CheckNullInt(txtrecdbaf.Text);
        float  recdqty  = CheckNull(txtrecdqty.Text);
        string ip       = Request.ServerVariables["REMOTE_ADDR"].ToString();
        int    month    = int.Parse(DateTime.Today.Month.ToString());
        int    year     = int.Parse(DateTime.Today.Year.ToString());
        string udate    = "";
        string ddate    = "";


        string qrystock = "select Sum(Recd_Qty) as Qty from dbo.RR_receipt_Depot where Commodity='" + comdtyid + "'and Scheme ='" + schemeid + "' and district_code='" + distid + "'and DepotID='" + sid + "' and Month=" + month + "and Year=" + year;

        mobj = new MoveChallan(ComObj);
        DataSet dspro = mobj.selectAny(qrystock);

        if (dspro.Tables[0].Rows.Count == 0)
        {
        }
        else
        {
            DataRow drop       = dspro.Tables[0].Rows[0];
            float   mrod       = CheckNull(drop["Qty"].ToString());
            string  qryinsopen = "select * from dbo.tbl_Stock_Registor where Commodity_Id ='" + comdtyid + "' and Scheme_ID='" + schemeid + "' and DistrictId ='" + distid + "'and DepotID='" + sid + "'and Month=" + month + "and Year=" + year;
            mobj = new MoveChallan(ComObj);
            DataSet dsopen = mobj.selectAny(qryinsopen);
            if (dsopen.Tables[0].Rows.Count == 0)
            {
                string chkopenss = "Select Round(convert(decimal,Sum(Current_Balance)),5) as Current_Balance   from dbo.issue_opening_balance where District_Id='" + distid + "'and Depotid='" + sid + "'and Commodity_Id='" + comdtyid + "'and Scheme_Id ='" + schemeid + "'";
                mobj = new MoveChallan(ComObj);
                DataSet dsqry = mobj.selectAny(chkopenss);
                if (dsqry == null)
                {
                }

                else
                {
                    DataRow drss    = dsqry.Tables[0].Rows[0];
                    float   sropen  = CheckNull(drss["Current_Balance"].ToString());
                    string  qryinsr = "insert into dbo.tbl_Stock_Registor(DistrictId,DepotID,Commodity_ID,Scheme_ID,Opening_Balance,Recieved_Procure,Recieved_Otherg,Recieved_FCI,Received_OtherSch,Recieved_Other_Src,Received_RailHead,Received_CMR,Received_Levy,Sale_Do,Sale_otherg,Transfer_OtherSch,Month,Year,Remarks) Values('" + distid + "','" + sid + "','" + comdtyid + "','" + schemeid + "'," + sropen + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + CheckNull(txtrecdqty.Text) + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + 0 + "," + month + "," + year + ",'')";
                    cmd.CommandText = qryinsr;
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
            else
            {
                string qryinsU = "update dbo.tbl_Stock_Registor set Received_RailHead=" + mrod + " where Commodity_Id ='" + comdtyid + "' and Scheme_ID='" + schemeid + "'and DistrictId='" + distid + "'and DepotID='" + sid + "'and Month=" + month + "and Year=" + year;
                cmd.CommandText = qryinsU;
                cmd.ExecuteNonQuery();
                con.Close();
            }
        }



        string chkopenbal = "Select * from dbo.issue_opening_balance where District_Id='" + distid + "'and Depotid='" + sid + "'and Commodity_Id='" + comdtyid + "'and Scheme_Id='" + schemeid + "' and Godown='" + gdwn + "' and Source='" + source + "'";

        //mobj = new MoveChallan(ComObj);

        distobj = new DistributionCenters(ComObj);
        DataSet dsbal = distobj.selectAny(chkopenbal);

        if (dsbal == null)
        {
        }

        else
        {
            if (dsbal.Tables[0].Rows.Count == 0)
            {
                string pdate   = getDate_MDY("01/04/2011");
                string qreyins = "insert into dbo.issue_opening_balance(State_Id,District_Id,Depotid,Commodity_Id,Scheme_Id,Category_Id,Godown,Crop_year,Bags,Quantity,Source,Current_Balance,Current_Bags,Month,Year,IP_Address,Stock_Date,CreatedDate,UpdatedDate,DeletedDate) values('" + mstate + "','" + distid + "','" + sid + "','" + comdtyid + "','" + schemeid + "','','" + gdwn + "',''," + openbag + "," + openqty + ",'" + source + "'," + recdqty + "," + recdbags + "," + month + "," + year + ",'" + ip + "','" + pdate + "',getdate(),'" + udate + "','" + ddate + "'" + ")";
                cmd.CommandText = qreyins;
                cmd.Connection  = con;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                string qreygdnU = "update dbo.Current_Godown_Position set Current_Capacity=Current_Capacity-" + recdqty + ",Current_Bags=Current_Bags+" + recdbags + ",Current_Balance=Current_Balance+" + recdqty + " where District_Id='" + distid + "' and Depotid='" + sid + "' and Godown='" + gdwn + "'";
                cmd.CommandText = qreygdnU;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }
            else
            {
                string mugdn = ddlgodown.SelectedValue;
                string query = "Update dbo.issue_opening_balance set Current_Balance=Round(convert(decimal,Current_Balance),5)+" + recdqty + ",Current_Bags=Current_Bags+" + recdbags + " where District_Id='" + distid + "'and Depotid='" + sid + "'and Commodity_Id='" + comdtyid + "'and Scheme_Id='" + schemeid + "'and Source='" + source + "' and Godown='" + gdwn + "'";
                cmd.CommandText = query;
                cmd.Connection  = con;

                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();

                    string qreygdnU = "update dbo.Current_Godown_Position set Current_Capacity=Current_Capacity-" + recdqty + ",Current_Bags=Current_Bags+" + recdbags + ",Current_Balance=Current_Balance+" + recdqty + " where District_Id='" + distid + "' and Depotid='" + sid + "' and Godown='" + gdwn + "'";
                    cmd.CommandText = qreygdnU;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                catch (Exception ex)
                {
                    Label1.Text = ex.Message;
                }
                finally
                {
                    con.Close();
                }
            }
        }
    }