public ICollection <Package> PackagesInCenter(int centerID)
        {
            // Reload the distribution center in case the supplied center is not associated with the current context
            var center = DistributionCenters.Find(centerID);

            var packages = from e in center.Packages
                           select e;

            return(packages.ToList());
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        ComObj  = new Common(ConfigurationManager.AppSettings["ConnectionString"].ToString());
        distobj = new DistributionCenters(ComObj);

        if (!IsPostBack)
        {
            //fillgrid();

            GetDist();
        }
    }
    void GetDepot()
    {
        distobj = new DistributionCenters(ComObj);
        string  ord = "Districtid='23" + distid + "' order by DepotName";
        DataSet ds  = distobj.select(ord);

        ddlissue.DataSource     = ds.Tables[0];
        ddlissue.DataTextField  = "DepotName";
        ddlissue.DataValueField = "DepotId";
        ddlissue.DataBind();
        ddlissue.Items.Insert(0, "--Select--");
    }
    //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--");
    }
Beispiel #5
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, "--चुनिये--");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ComObj  = new Common(ConfigurationManager.AppSettings["ConnectionString"].ToString());
        distobj = new DistributionCenters(ComObj);

        if (!IsPostBack)
        {
            GetCommodity();

            bn_del.Visible = false;
            GetDist();
        }
    }
Beispiel #7
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, "--चुनिये--");
    }
Beispiel #8
0
    void GetDCName()
    {
        distobj = new DistributionCenters(ComObj);
        string  ord = "Districtid='23" + ddldistrict.SelectedValue.ToString() + "' order by DepotName";
        DataSet ds  = distobj.select(ord);

        ddlissue.DataSource     = ds.Tables[0];
        ddlissue.DataTextField  = "DepotName";
        ddlissue.DataValueField = "DepotID";
        ddlissue.DataBind();
        ddlissue.Items.Insert(0, "--Select--");
        // ddDistId.Items.Insert(0, "--चुनिये--");
    }
Beispiel #9
0
    void GetPCName()
    {
        string distcode = ddldistrict.SelectedValue;

        distobj = new DistributionCenters(ComObj);
        string  ord = "DistrictId='23" + ddldistrict.SelectedValue.ToString() + "' order by PcId";
        DataSet ds  = distobj.selectPC(ord);

        ddlprocname.DataSource     = ds.Tables[0];
        ddlprocname.DataTextField  = "PurchaseCenterName";
        ddlprocname.DataValueField = "PcId";
        ddlprocname.DataBind();
        ddlprocname.Items.Insert(0, "--Select--");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["issue_id"] != null)
        {
            sid = Session["issue_id"].ToString();
            did = Session["dist_id"].ToString();

            txtqty.Attributes.Add("onkeypress", "return CheckIsNumeric(this)");
            txtnobags.Attributes.Add("onkeypress", "return CheckIsNumeric(this)");
            txtwcmno.Attributes.Add("onkeypress", "return CheckIsNumeric(this)");
            txtmoisture.Attributes.Add("onkeypress", "return CheckIsNumeric(this)");


            txtmoisture.Style["TEXT-ALIGN"] = TextAlign.Right.ToString();
            txtchallan.Style["TEXT-ALIGN"]  = TextAlign.Right.ToString();
            txtqty.Style["TEXT-ALIGN"]      = TextAlign.Right.ToString();
            txtnobags.Style["TEXT-ALIGN"]   = TextAlign.Right.ToString();
            txtwcmno.Style["TEXT-ALIGN"]    = TextAlign.Right.ToString();



            btnadd.Attributes.Add("onclick", "window.open('GunnyBagsDetails.aspx',null,'left=300, top=10, height=400, width=580, status=n o, resizable= no, scrollbars= no, toolbar= no,location= no, menubar= no');");
            ComObjWlC = new Common(ConfigurationManager.AppSettings["ConnectionWlc"].ToString());
            ComObj    = new Common(ConfigurationManager.AppSettings["ConnectionString"].ToString());


            distobj = new DistributionCenters(ComObj);

            if (!IsPostBack)
            {
                Transport();
                GetScheme();
                GetGunny();
                GetCommodity();
                GetCategory();
                GetDist();
                GetDCName();
                GetRecdCategory();
                GetSource();
                //GetFCIdist();
                GetDepositorType();
                GetVehicleType();
            }
        }
        else
        {
            Response.Redirect("~/MainLogin.aspx");
        }
    }
Beispiel #11
0
 public void GetDCName()
 {
     try
     {
         distobj = new DistributionCenters(ComObj);
         string  ord = "Districtid='23" + ddldistrict.SelectedValue.ToString() + "' order by DepotName";
         DataSet ds  = distobj.select(ord);
         ddlissuecenter.DataSource     = ds.Tables[0];
         ddlissuecenter.DataTextField  = "DepotName";
         ddlissuecenter.DataValueField = "DepotId";
         ddlissuecenter.DataBind();
         ddlissuecenter.Items.Insert(0, "--Select--");
     }
     catch (Exception)
     {
     }
 }
Beispiel #12
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, "--चुनिये--");
    }
    void GetIssCName()
    {
        ddl_IC.Items.Clear();
        distobj = new DistributionCenters(ComObj);
        string  ord = "Districtid='23" + ddl_dist.SelectedValue.ToString() + "' order by DepotName";
        DataSet ds  = distobj.select(ord);

        if (ds == null)
        {
        }
        else
        {
            ddl_IC.DataSource     = ds.Tables[0];
            ddl_IC.DataTextField  = "DepotName";
            ddl_IC.DataValueField = "DepotId";
            ddl_IC.DataBind();
            ddl_IC.Items.Insert(0, "--Select--");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["issue_id"] != null)
        {
            sid = Session["issue_id"].ToString();
            did = Session["dist_id"].ToString();



            ComObj  = new Common(ConfigurationManager.AppSettings["ConnectionString"].ToString());
            distobj = new DistributionCenters(ComObj);

            if (!IsPostBack)
            {
                fillgrid();
                GetSource();
            }
        }
        else
        {
            Response.Redirect("~/MainLogin.aspx");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["dist_id"] != null)
        {
            distid  = Session["dist_id"].ToString();
            version = Session["hindi"].ToString();

            txtroqty.Attributes.Add("onkeypress", "return CheckIsNumeric(event,this)");
            txtrate.Attributes.Add("onkeypress", "return CheckIsNumeric(event,this)");
            txtamount.Attributes.Add("onkeypress", "return CheckIsNumeric(event,this)");
            txtchqamt.Attributes.Add("onkeypress", "return CheckIsNumeric(event,this)");



            txtrodate.Attributes.Add("onkeypress", "return CheckCalDate(this)");
            txtrovalidity.Attributes.Add("onkeypress", "return CheckCalDate(this)");
            txtddate.Attributes.Add("onkeypress", "return CheckCalDate(this)");

            txtroqty.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtroqty.Attributes.Add("onchange", "return chksqltxt(this),calcAmount();");

            txtrodate.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtrodate.Attributes.Add("onchange", "return chksqltxt(this)");

            txtrovalidity.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtrovalidity.Attributes.Add("onchange", "return chksqltxt(this)");

            txtddate.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtddate.Attributes.Add("onchange", "return chksqltxt(this)");

            txtrono.Attributes.Add("onkeypress", "return checksqlkey_gen(event,this)");
            txtrono.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtrono.Attributes.Add("onchange", "return chksqltxt(this)");

            txtrate.Attributes.Add("onkeypress", "return checksqlkey_gen(event,this)");
            txtrate.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtrate.Attributes.Add("onchange", "return chksqltxt(this)");

            txtckeckno.Attributes.Add("onkeypress", "return checksqlkey_gen(event,this)");
            txtckeckno.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtckeckno.Attributes.Add("onchange", "return chksqltxt(this)");

            txtchqamt.Attributes.Add("onkeypress", "return checksqlkey_gen(event,this)");
            txtchqamt.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtchqamt.Attributes.Add("onchange", "return chksqltxt(this)");
            txtchqamt.Attributes.Add("onkeypress", "return CheckIsNumeric(event,this)");

            txtremark.Attributes.Add("onkeypress", "return checksqlkey_gen(event,this)");
            txtremark.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtremark.Attributes.Add("onchange", "return chksqltxt(this)");


            txtrono.Style["TEXT-ALIGN"]    = TextAlign.Right.ToString();
            txtroqty.Style["TEXT-ALIGN"]   = TextAlign.Right.ToString();
            txtrate.Style["TEXT-ALIGN"]    = TextAlign.Right.ToString();
            txtamount.Style["TEXT-ALIGN"]  = TextAlign.Right.ToString();
            txtckeckno.Style["TEXT-ALIGN"] = TextAlign.Right.ToString();
            txtchqamt.Style["TEXT-ALIGN"]  = TextAlign.Right.ToString();
            txtalotqty.Style["TEXT-ALIGN"] = TextAlign.Right.ToString();

            //string dbname = "Warehouse";



            ComObj = new Common(ConfigurationManager.AppSettings["ConnectionString"].ToString());


            //if (Session["dc_id"] != null)
            //{

            //}

            distobj = new DistributionCenters(ComObj);
            chk     = new chksql();
            ArrayList ctrllist = new ArrayList();
            ctrllist.Add(txtrono.Text);
            ctrllist.Add(txtrate.Text);
            ctrllist.Add(txtckeckno.Text);
            ctrllist.Add(txtchqamt.Text);
            ctrllist.Add(txtremark.Text);

            if (chk == null)
            {
            }
            else
            {
                bool chkstr = chk.chksql_server(ctrllist);
                if (chkstr == true)
                {
                    Page.Server.Transfer(HttpContext.Current.Request.Path);
                }
            }


            if (!IsPostBack)
            {
                txtddate.Text      = DateTime.Today.Date.ToString("dd-MM-yyyy");
                txtrovalidity.Text = DateTime.Today.Date.ToString("dd-MM-yyyy");
                txtrodate.Text     = DateTime.Today.Date.ToString("dd-MM-yyyy");

                GetDist();
                GetCommodity();
                GetScheme();
                GetName();
                GetBank();
                ddlallot_year.Items.Add((int.Parse(DateTime.Today.Year.ToString()) - 1).ToString());
                ddlallot_year.Items.Add(DateTime.Today.Year.ToString());
                ddlallot_year.SelectedIndex = 1;
                ddlalotmm.SelectedIndex     = DateTime.Today.Month - 1;
                if (version == "H")
                {
                    lblCommodity.Text        = Resources.LocalizedText.lblCommodity;
                    lblScheme.Text           = Resources.LocalizedText.lblScheme;
                    lblQuantity.Text         = Resources.LocalizedText.lblQuantity;
                    lblReleaseOrder.Text     = Resources.LocalizedText.lblDetailsofRO;
                    btnsave.Text             = Resources.LocalizedText.btnsave;
                    btnclose.Text            = Resources.LocalizedText.btnclose;
                    lblmonth.Text            = Resources.LocalizedText.lblmonth;
                    lblyear.Text             = Resources.LocalizedText.lblyear;
                    lblRateQuintal.Text      = Resources.LocalizedText.lblRateQuintal;
                    lblPaymentMode.Text      = Resources.LocalizedText.lblPaymentMode;
                    lblddchekno.Text         = Resources.LocalizedText.lblddchekno;
                    lblddchekdate.Text       = Resources.LocalizedText.lblddchekdate;
                    lblBankName.Text         = Resources.LocalizedText.lblBankName;
                    lblamount.Text           = Resources.LocalizedText.lblamount;
                    lblamountdd.Text         = Resources.LocalizedText.lblamountdd;
                    lblforDist.Text          = Resources.LocalizedText.lblforDist;
                    lblReleaseOrderDate.Text = Resources.LocalizedText.lblReleaseOrderDate;
                    lbldovalidity.Text       = Resources.LocalizedText.lbldovalidity;
                    lblRemark.Text           = Resources.LocalizedText.lblRemark;
                    lblReleaseOrderDate.Text = Resources.LocalizedText.lblReleaseOrderDate;
                    lblqty.Text     = Resources.LocalizedText.lblqty;
                    lbl_balqty.Text = Resources.LocalizedText.lbl_balqty;
                }
            }
        }
        else
        {
            Response.Redirect("~/MainLogin.aspx");
        }
    }
Beispiel #16
0
        public DistributionCenter GetDistributionCenter(int centerID)
        {
            var center = DistributionCenters.SingleOrDefault(DistributionCenter => DistributionCenter.DistributionCenterID == centerID);

            return(center);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["st_id"] != null)
        {
            txtqty.Attributes.Add("onkeypress", "return CheckIsNumeric(event,this)");


            txtqty.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtqty.Attributes.Add("onchange", "return chksqltxt(this)");


            txtorderno.Attributes.Add("onkeypress", "return CheckIsNumeric(event,this)");


            txtdate.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtdate.Attributes.Add("onchange", "return chksqltxt(this)");

            txtqty.Style["TEXT-ALIGN"]  = TextAlign.Right.ToString();
            txtrate.Style["TEXT-ALIGN"] = TextAlign.Right.ToString();



            ComObj = new Common(ConfigurationManager.AppSettings["ConnectionString"].ToString());



            distobj = new DistributionCenters(ComObj);
            chk     = new chksql();
            ArrayList ctrllist = new ArrayList();

            ctrllist.Add(txtqty.Text);
            ctrllist.Add(txtorderno.Text);

            ctrllist.Add(txtdate.Text);

            if (chk == null)
            {
            }
            else
            {
                bool chkstr = chk.chksql_server(ctrllist);
                if (chkstr == true)
                {
                    Page.Server.Transfer(HttpContext.Current.Request.Path);
                }
            }


            if (!IsPostBack)
            {
                GetDCName();
                //GetZone();
                //GetDist();
                Getsupplier();
                fillgrid();
            }
        }
        else
        {
            Response.Redirect("~/MainLogin.aspx");
        }
    }
    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();
                    }
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["dist_id"] != null)
        {
            sid = Session["dist_id"].ToString();
            //string dbname = "Warehouse";
            txtqty.Attributes.Add("onkeypress", "return CheckIsNumeric(this)");
            txtmobile.Attributes.Add("onkeypress", "return CheckIsNumeric(this)");
            txtrate.Attributes.Add("onkeypress", "return CheckIsNumeric(this)");

            txtqty.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtqty.Attributes.Add("onchange", "return chksqltxt(this)");

            txtmobile.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtmobile.Attributes.Add("onchange", "return chksqltxt(this)");

            txtrate.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txtrate.Attributes.Add("onchange", "return chksqltxt(this)");

            txttname.Attributes.Add("onkeypress", "return checksqlkey_gen(event,this)");
            txttname.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txttname.Attributes.Add("onchange", "return chksqltxt(this)");

            txttadd.Attributes.Add("onkeypress", "return checksqlkey_gen(event,this)");
            txttadd.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            txttadd.Attributes.Add("onchange", "return chksqltxt(this)");

            DaintyDate1.Attributes.Add("onkeypress", "return CheckCalDate(this)");
            DaintyDate1.Attributes.Add("onkeydown", "return checksqlkey_special(event,this);");
            DaintyDate1.Attributes.Add("onchange", "return chksqltxt(this)");


            txtmobile.Style["TEXT-ALIGN"] = TextAlign.Right.ToString();
            txtqty.Style["TEXT-ALIGN"]    = TextAlign.Right.ToString();
            txtrate.Style["TEXT-ALIGN"]   = TextAlign.Right.ToString();

            ComObj = new Common(ConfigurationManager.AppSettings["ConnectionString"].ToString());


            distobj = new DistributionCenters(ComObj);
            chk     = new chksql();
            ArrayList ctrllist = new ArrayList();
            ctrllist.Add(txtqty.Text);
            ctrllist.Add(txtmobile.Text);
            ctrllist.Add(txtrate.Text);
            ctrllist.Add(txttname.Text);
            ctrllist.Add(txttadd.Text);
            ctrllist.Add(DaintyDate1.Text);
            if (chk == null)
            {
            }
            else
            {
                bool chkstr = chk.chksql_server(ctrllist);
                if (chkstr == true)
                {
                    Page.Server.Transfer(HttpContext.Current.Request.Path);
                }
            }


            if (Page.IsPostBack == false)
            {
                Fillgrid();
                GetTransportType();
                GetDistance();
                get_block();
                lbl_block.Visible = false;
                ddlBlock.Visible  = false;
            }
        }
        else
        {
            Response.Redirect("~/MainLogin.aspx");
        }
    }
    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();
                }
            }
        }
    }