예제 #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        using (con = new SqlConnection(strcon))
        {
            try
            {
                ClientIP objClientIP = new ClientIP();
                string   GetIp       = (objClientIP.GETIP());

                string browser   = Request.Browser.Browser.ToString();
                string version   = Request.Browser.Version.ToString();
                string useragent = browser + version;

                if (ViewState["Present"].ToString() == 1.ToString())
                {
                    Update = "Update officers_list set DM_Name=N'" + txtDMName.Text + "',DM_MailId='" + txtDMMail.Text + "',DM_Mobile='0" + txtDMMobile.Text + "',DM_IP_Address='" + GetIp.ToString() + "',DM_Current_DateTime=GETDATE(),DM_User_Agent='" + useragent + "',RM_Mobile='" + txtDMMobile2.Text + "',PanNo='" + txtPanNo.Text + "',TinNo='" + txtTinNo.Text + "' where District_code='" + ddlDist.SelectedValue.ToString() + "'";
                }
                else
                {
                    Update = "Insert Into officers_list (DM_Name,DM_MailId,DM_Mobile,DM_IP_Address,DM_Current_DateTime,DM_User_Agent,District_code,District,RM_Mobile,PanNo,TinNo) values(N'" + txtDMName.Text + "','" + txtDMMail.Text + "','0" + txtDMMobile.Text + "','" + GetIp.ToString() + "',GETDATE(),'" + useragent + "',N'" + ddlDist.SelectedValue.ToString() + "','" + ddlDist.SelectedItem.ToString() + "','" + txtDMMobile2.Text + "','" + txtPanNo.Text + "','" + txtTinNo.Text + "')";
                }

                con.Open();
                cmd = new SqlCommand(Update, con);
                int count = cmd.ExecuteNonQuery();

                if (count > 0)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Save Successfully...'); </script> ");
                }
                else
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                }
            }
            catch (Exception ex)
            {
                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
            }

            finally
            {
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }
    }
예제 #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        using (con = new SqlConnection(strcon))
        {
            try
            {
                ClientIP objClientIP = new ClientIP();
                string   GetIp       = (objClientIP.GETIP());

                if (ViewState["Present"].ToString() == 1.ToString())
                {
                    Update = string.Format("Update officers_list set DMO_Name=N'{0}',DMO_MailId='{1}',DMO_Mobile={2},DMO_IP='{3}',DMO_CreatedDate={4} where District_code='" + ddlDist.SelectedValue.ToString() + "' ", txtDMName.Text, txtDMMail.Text, "0" + txtDMMobile.Text, GetIp.ToString(), "GETDATE()");
                }
                else
                {
                    Update = string.Format("Insert Into officers_list (DMO_Name,DMO_MailId,DMO_Mobile,DMO_IP,DMO_CreatedDate,District_code,District) values(N'{0}','{1}',{2},'{3}',{4},'{5}','{6}',N'{7}')", txtDMName.Text, txtDMMail.Text, "0" + txtDMMobile.Text, GetIp.ToString(), "GETDATE()", ddlDist.SelectedValue.ToString(), ddlDist.SelectedItem.ToString());
                }

                con.Open();
                cmd = new SqlCommand(Update, con);
                int count = cmd.ExecuteNonQuery();

                if (count > 0)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Save Successfully...'); </script> ");
                }
                else
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                }
            }
            catch (Exception ex)
            {
                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
            }

            finally
            {
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }
    }
예제 #3
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (ddlAgtmtNumber.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Agreement Number'); </script> ");
            return;
        }
        else if (hdfAgrmtData.Value == "1")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('इस Agreement No. के विरुद्ध धान जारी किया जा चूका हैं, इसलिए इसे Delete नहीं किया जा सकता|'); </script> ");
            return;
        }
        else
        {
            if (txtYear.Text != "")
            {
                if (Session["update"].ToString() == ViewState["update"].ToString())
                {
                    using (con = new SqlConnection(strcon))
                    {
                        try
                        {
                            ClientIP objClientIP = new ClientIP();
                            string   GetIp       = (objClientIP.GETIP());

                            con.Open();

                            string instr = "";

                            instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";

                            instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                            cmd = new SqlCommand(instr, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                btnDelete.Enabled = false;

                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Miller Agreement Is Deleted Successfully'); </script> ");
                                txtYear.Text       = "";
                                ddlFrmDist.Enabled = ddlMillName.Enabled = ddlAgtmtNumber.Enabled = false;
                                Session["update"]  = Server.UrlEncode(System.DateTime.Now.ToString());
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Deletion Not Allow'); </script> ");
                            }
                        }
                        catch (Exception ex)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                        }

                        finally
                        {
                            if (con.State != ConnectionState.Closed)
                            {
                                con.Close();
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
            }
        }
    }
예제 #4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (ddl_distancefrom.SelectedIndex == 0)
        {
            Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Select Distance from...');</script>");
            return;
        }
        if (ddl_relatedDistrict.SelectedIndex == 0)
        {
            btnSave.Enabled = true;
            Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Select District Name.....');</script>");
            return;
        }
        if (ddl_distancefrom.SelectedValue.ToString() != "12")
        {
            if (ddlissuecenter.SelectedIndex == 0)
            {
                btnSave.Enabled = true;
                Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Select Issue Center Name......');</script>");
                return;
            }
        }
        if (ddl_distancefrom.SelectedValue.ToString() != "12")
        {
            if (ddl_Godown.SelectedIndex == 0)
            {
                btnSave.Enabled = true;
                Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Select Godown......');</script>");
                return;
            }
        }
        if (txt_distance.Text == "" || txt_distance.Text == "0")
        {
            btnSave.Enabled = true;
            Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Enter distance......');</script>");
            return;
        }
        string pc_id = "";

        if (ddl_distancefrom.SelectedValue.ToString() != "12")
        {
            pc_id = ddl_PCeneter.SelectedValue.ToString();
        }
        else
        {
            pc_id = ddl_relatedDistrict.SelectedValue.ToString();
        }
        con.Close();
        string dist = distid;

        string Issue = ddlissuecenter.SelectedValue;

        ClientIP objClientIP = new ClientIP();
        string   IP          = objClientIP.GETIP();

        string user = Session["OperatorIDDM"].ToString();

        if (ddl_distancefrom.SelectedValue == "11") //From Paddy Mill To Godown
        {
            if (ddl_PCeneter.SelectedIndex == 0)
            {
                Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Please Select Mill Name...');</script>");
                return;
            }
            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                string         Check = "Select * From Distance_Master_Godown where DistrictId='" + ddl_relatedDistrict.SelectedValue.ToString() + "' and PCCodeOrRailheadcode='" + ddl_PCeneter.SelectedValue.ToString() + "' and IssueCenter='" + ddlissuecenter.SelectedValue.ToString() + "' and Godown_id='" + ddl_Godown.SelectedValue.ToString() + "' and Distance_For='" + ddl_distancefrom.SelectedValue.ToString() + "'";
                SqlDataAdapter da    = new SqlDataAdapter(Check, con);
                DataSet        ds    = new DataSet();
                da.Fill(ds);

                if (ds.Tables[0].Rows.Count == 0)
                {
                    try
                    {
                        string     insqry = "Insert into Distance_Master_Godown (DistrictId ,PCCodeOrRailheadcode ,IssueCenter ,Godown_id,distance,Distance_For,CreatedDate,IP_Address) values ('" + ddl_relatedDistrict.SelectedValue.ToString() + "','" + ddl_PCeneter.SelectedValue.ToString() + "','" + ddlissuecenter.SelectedValue.ToString() + "', '" + ddl_Godown.SelectedValue.ToString() + "','" + txt_distance.Text + "','" + ddl_distancefrom.SelectedValue.ToString() + "',getdate(),'" + IP + "')";
                        SqlCommand cmdins = new SqlCommand(insqry, con);
                        int        count  = cmdins.ExecuteNonQuery();

                        if (count > 0)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Sucessfully....'); </script> ");
                            btnSave.Enabled = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        btnSave.Enabled = false;
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
                else
                {
                    try
                    {
                        string     insqry = "Update Distance_Master_Godown set distance= '" + txt_distance.Text + "' where DistrictId='" + ddl_relatedDistrict.SelectedValue.ToString() + "' and PCCodeOrRailheadcode='" + ddl_PCeneter.SelectedValue.ToString() + "' and IssueCenter='" + ddlissuecenter.SelectedValue.ToString() + "' and Godown_id='" + ddl_Godown.SelectedValue.ToString() + "' and Distance_For='" + ddl_distancefrom.SelectedValue.ToString() + "'";
                        SqlCommand cmdins = new SqlCommand(insqry, con);
                        int        count  = cmdins.ExecuteNonQuery();

                        if (count > 0)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Updated Sucessfully....'); </script> ");
                            //btnSave.Enabled = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        //btnSave.Enabled = false;
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //btnSave.Enabled = false;
                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
            }

            finally
            {
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }
        else
        {
            if (btnSave.Text == "Save")
            {
                string mystr = "";
                if (ddl_distancefrom.SelectedValue.ToString() == "PC")
                {
                    mystr = "SELECT *FROM [Distance_Master_Godown] where [PCCodeOrRailheadcode]='" + ddl_PCeneter.SelectedValue.ToString() + "' and Godown_id='" + ddl_Godown.SelectedValue.ToString() + "' ";
                }
                else if (ddl_distancefrom.SelectedValue.ToString() == "12")
                {
                    mystr = "SELECT *FROM [Distance_Master_Godown] where [DistrictId]='" + Session["dist_id"].ToString() + "' and PCCodeOrRailheadcode='" + ddl_relatedDistrict.SelectedValue.ToString() + "' and transport_mode='" + ddl_transportmode.SelectedValue.ToString() + "' ";
                }
                else
                {
                    mystr = "SELECT *FROM [Distance_Master_Godown] where [PCCodeOrRailheadcode]='" + ddl_PCeneter.SelectedValue.ToString() + "' and IssueCenter='" + ddlissuecenter.SelectedValue.ToString() + "' ";
                }
                con.Open();
                SqlCommand    cmdwhr = new SqlCommand(mystr, con);
                SqlDataReader sqldr  = cmdwhr.ExecuteReader();
                sqldr.Read();

                if (sqldr.HasRows)
                {
                    Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Distance already save kindly Update it from the list......');</script>");
                    return;
                }
                con.Close();

                // string distance = gr.Cells[3].Text;

                string     insqry = "Insert into Distance_Master_Godown (transport_mode,DistrictId ,PCCodeOrRailheadcode ,IssueCenter ,Godown_id,distance,Distance_For,CreatedDate,IP_Address) values ('" + ddl_transportmode.SelectedValue.ToString() + "','" + Session["dist_id"].ToString() + "','" + pc_id + "','" + ddlissuecenter.SelectedValue.ToString() + "', '" + ddl_Godown.SelectedValue.ToString() + "','" + txt_distance.Text + "','" + ddl_distancefrom.SelectedValue.ToString() + "',getdate(),'" + IP + "')";
                SqlCommand cmdins = new SqlCommand(insqry, con);


                //string upsqry = "Update  dbo.TO_for_Purchesecenter set distance_pc_godown='" + txt_distance.Text + "'  where pc_id='" + ddl_PCeneter.SelectedValue.ToString() + "'and Godownid='" + ddl_Godown.SelectedValue.ToString() + "'";
                //SqlCommand cmdups = new SqlCommand(upsqry, con);
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                try
                {
                    int x = cmdins.ExecuteNonQuery();
                    //int z = cmdups.ExecuteNonQuery();
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Sucessfuly...'); </script> ");
                    //btnSave.Enabled = false;

                    //Response.Redirect("~/District/PCenterto_godown_distance.aspx");
                }

                catch
                {
                    btnSave.Enabled = true;
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Problem Arise, pls try again...'); </script> ");
                }



                finally
                {
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            else
            {
                try
                {
                    string insertdistance = "";

                    if (ddl_distancefrom.SelectedValue.ToString() == "2")
                    {
                        insertdistance = "Update Distance_Master_Godown set distance= '" + txt_distance.Text + "' where PCCodeOrRailheadcode='" + ddl_PCeneter.SelectedValue.ToString() + "' and IssueCenter='" + ddlissuecenter.SelectedValue.ToString() + "'";
                    }
                    else if (ddl_distancefrom.SelectedValue.ToString() == "12")
                    {
                        insertdistance = "Update Distance_Master_Godown set distance= '" + txt_distance.Text + "' where PCCodeOrRailheadcode='" + ddl_relatedDistrict.SelectedValue.ToString() + "' and DistrictId='" + Session["dist_id"].ToString() + "' and transport_mode='" + ddl_transportmode.SelectedValue.ToString() + "'";
                    }
                    else
                    {
                        insertdistance = "Update Distance_Master_Godown set distance= '" + txt_distance.Text + "' where PCCodeOrRailheadcode='" + ddl_PCeneter.SelectedValue.ToString() + "' and Godown_id='" + ddl_Godown.SelectedValue.ToString() + "'";
                    }
                    SqlCommand cmdins = new SqlCommand(insertdistance, con);

                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    int x = cmdins.ExecuteNonQuery();
                    con.Close();

                    string     qry  = "Update  dbo.TO_for_Purchesecenter set distance_pc_godown='" + txt_distance.Text + "'  where pc_id='" + ddl_PCeneter.SelectedValue.ToString() + "'and Godownid='" + ddl_Godown.SelectedValue.ToString() + "' ";
                    SqlCommand cmsd = new SqlCommand(qry, con);
                    con.Open();
                    int y = cmsd.ExecuteNonQuery();


                    try
                    {
                        //con.Open();
                        cmsd.ExecuteNonQuery();
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Updated successfully...'); </script> ");
                        btnSave.Enabled = false;
                    }
                    catch (Exception ex)
                    {
                        //Label1.Visible = true;
                        //Label1.Text = ex.Message;
                    }
                    finally
                    {
                        con.Close();
                        //ComObj.CloseConnection();
                    }


                    fillgrid();
                    //Panel1.Visible = false;
                }
                catch
                {
                }
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        DataTable dt = adddetails();

        if (dt.Rows.Count <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please Add At least One Godown'); </script> ");
            return;
        }
        else if (ddlGodown.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please Select At least One Godown'); </script> ");
            return;
        }
        else
        {
            if (hdfYear.Value != "")
            {
                ClientIP objClientIP = new ClientIP();
                string   GetIp       = (objClientIP.GETIP());

                if (Session["update"].ToString() == ViewState["update"].ToString())
                {
                    using (con = new SqlConnection(strcon))
                    {
                        try
                        {
                            con.Open();

                            string  ChechMax     = "";
                            decimal MaxMappingNo = 0;
                            ChechMax = "Select Max(Mapping_No) As MaxMap From PM_DistToGodown Where FrmDistrict='" + ddlFrmDist.SelectedValue.ToString() + "' and ToDistrict='" + ddlToDist.SelectedValue.ToString() + "' ";
                            da       = new SqlDataAdapter(ChechMax, con);
                            ds       = new DataSet();
                            da.Fill(ds);

                            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                string Data = "";
                                Data = ds.Tables[0].Rows[0]["MaxMap"].ToString();
                                if (Data == "")
                                {
                                    MaxMappingNo = decimal.Parse(ddlFrmDist.SelectedValue.ToString() + ddlToDist.SelectedValue.ToString() + "100000");
                                }
                                else
                                {
                                    string wid        = Data.Substring(Data.Length - 6);
                                    Int64  wid_ID_new = Convert.ToInt64(wid);
                                    wid_ID_new = wid_ID_new + 1;
                                    string combine = wid_ID_new.ToString();
                                    MaxMappingNo = decimal.Parse(ddlFrmDist.SelectedValue.ToString() + ddlToDist.SelectedValue.ToString() + combine);
                                }
                            }

                            if (MaxMappingNo != 0)
                            {
                                string instr = "";

                                instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";

                                if (dt != null)
                                {
                                    for (int i = 0; i < dt.Rows.Count; i++)
                                    {
                                        if (i == 0)
                                        {
                                        }
                                        else
                                        {
                                            MaxMappingNo = MaxMappingNo + 1;
                                        }

                                        instr += "Insert Into PM_DistToGodown(FrmDistrict,ToDistrict,Mapping_No,CropYear,IssueCenter,Branch,Godown_id,CreatedDate,IP_Address) Values('" + ddlFrmDist.SelectedValue.ToString() + "','" + ddlToDist.SelectedValue.ToString() + "','" + MaxMappingNo + "','" + hdfYear.Value + "','" + dt.Rows[i]["ICVal"] + "','" + dt.Rows[i]["BranchVal"] + "','" + dt.Rows[i]["GodownVal"] + "',GETDATE(),'" + GetIp + "');";
                                    }
                                }

                                instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                                cmd = new SqlCommand(instr, con);
                                int count = cmd.ExecuteNonQuery();

                                if (count > 0)
                                {
                                    btnSubmit.Enabled  = btnAdd.Enabled = false;
                                    ddlFrmDist.Enabled = ddlToDist.Enabled = ddlIssueCentre.Enabled = ddlBranch.Enabled = ddlGodown.Enabled = false;
                                    hdfYear.Value      = "";
                                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully'); </script> ");
                                    Session["ICGBQ"]  = null;
                                    Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                                }
                                else
                                {
                                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                                }
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Changes Not Allow'); </script> ");
                            }
                        }
                        catch (Exception ex)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                        }

                        finally
                        {
                            if (con.State != ConnectionState.Closed)
                            {
                                con.Close();
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
            }
            else
            {
                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Click On New Button'); </script> ");
                return;
            }
        }
    }
예제 #6
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (ddlDONo.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select CMR DO Number'); </script> ");
            return;
        }
        else if (hdfAcpt.Value == "Y")
        {
            btnDelete.Enabled = false;
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('इस DEPOSIT ORDER के विरुद्ध चावल जमा किया जा चूका है, इसलिए आप इसे Delete नहीं कर सकते|'); </script> ");
            return;
        }
        else if (hdfReject.Value == "Y")
        {
            btnDelete.Enabled = false;
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('इस DEPOSIT ORDER के विरुद्ध चावल को रिजेक्ट किया जा चूका है, इसलिए आप इसे Delete नहीं कर सकते|'); </script> ");
            return;
        }
        else
        {
            if (ddlCropyear.SelectedValue.ToString() != "")
            {
                if (Session["update"].ToString() == ViewState["update"].ToString())
                {
                    using (con = new SqlConnection(strcon))
                    {
                        try
                        {
                            ClientIP objClientIP = new ClientIP();
                            string   GetIp       = (objClientIP.GETIP());

                            ConvertServerDate ServerDate      = new ConvertServerDate();
                            string            ConvertFromDate = ServerDate.getDate_MDY(txtDODate.Text);
                            string            ConvertToDate   = ServerDate.getDate_MDY(txtDOLastDate.Text);

                            con.Open();

                            string instr = "";

                            instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";

                            instr += "Insert Into PaddyMilling_DO_Log_2017(DO_Number,Mill_Code,Agreement_ID,District,CropYear,From_Date,To_Date,Milling_Type,Alloted_CommonDhan,Alloted_GradeADhan,R_Arva,R_Ushna,Issue_Centre,IP_Address,Current_DateTime,User_Agent,Check_DO,DispatchDhan_IC,Return_CommonRice,Return_GradeARice,Return_TotalRice,LotOnlyNumber,Rejected,DhanLot,Branch_Code,Godown_Code,LotNumber,Rem_Alloted_CommonDhan,Rem_Alloted_GradeADhan,Rem_DhanLot,LotNo,DeletedDate,DeletedIP,Operation) select DO_Number,Mill_Code,Agreement_ID,District,CropYear,From_Date,To_Date,Milling_Type,Alloted_CommonDhan,Alloted_GradeADhan,R_Arva,R_Ushna,Issue_Centre,IP_Address,Current_DateTime,User_Agent,Check_DO,DispatchDhan_IC,Return_CommonRice,Return_GradeARice,Return_TotalRice,LotOnlyNumber,Rejected,DhanLot,Branch_Code,Godown_Code,LotNumber,Rem_Alloted_CommonDhan,Rem_Alloted_GradeADhan,Rem_DhanLot,LotNo,GETDATE(),'" + GetIp + "','U' From PaddyMilling_DO_2017 where Mill_Code='" + ddlMillName.SelectedValue.ToString() + "' and Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' and CropYear='" + ddlCropyear.SelectedValue.ToString() + "' and DhanLot='" + hdfLotNo.Value + "' and Check_DO='" + hdfDONo.Value + "'; ";
                            instr += "Update PaddyMilling_DO_2017 Set DispatchDhan_IC='N' where Mill_Code='" + ddlMillName.SelectedValue.ToString() + "' and Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' and CropYear='" + ddlCropyear.SelectedValue.ToString() + "' and DhanLot='" + hdfLotNo.Value + "' and Check_DO='" + hdfDONo.Value + "'; ";

                            instr += "Insert Into CMR_DepositOrder_Log(CMR_DO,CMR_RecdDist,Paddy_AgrmtDist,CropYear,Mill_ID,Agreement_ID,Lot_No,DO_No,IssueCenter,Branch,Godown_id,CMR_DODate,CreatedDate,IP_Address,IsAccepted,IsRejected,DeletedDate,DeletedIP,Operation) Select CMR_DO,CMR_RecdDist,Paddy_AgrmtDist,CropYear,Mill_ID,Agreement_ID,Lot_No,DO_No,IssueCenter,Branch,Godown_id,CMR_DODate,CreatedDate,IP_Address,IsAccepted,IsRejected,GETDATE(),'" + GetIp + "','D' From CMR_DepositOrder where CMR_DO='" + ddlDONo.SelectedItem.ToString() + "' ; ";
                            instr += "Delete From CMR_DepositOrder where CMR_DO='" + ddlDONo.SelectedItem.ToString() + "' ; ";

                            instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                            cmd = new SqlCommand(instr, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                btnDelete.Enabled = false;

                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('CMR Deposit Order Deleted Successfully'); </script> ");
                                //txtYear.Text = "";
                                ddlCropyear.Enabled = false;
                                ddlFrmDist.Enabled  = ddlMillName.Enabled = ddlAgtmtNumber.Enabled = ddlDONo.Enabled = false;
                                Session["update"]   = Server.UrlEncode(System.DateTime.Now.ToString());
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Deletion Not Allow'); </script> ");
                            }
                        }
                        catch (Exception ex)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                        }

                        finally
                        {
                            if (con.State != ConnectionState.Closed)
                            {
                                con.Close();
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
            }
        }
    }
    protected void btnRecptSubmit_Click1(object sender, EventArgs e)
    {
        ClientIP objClientIP = new ClientIP();
        string   GetIp       = (objClientIP.GETIP());

        if (txtYear.Text != "")
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        con.Open();

                        string instr = "";

                        string ChechMax = "", DCDate = "", MaxMappingNo = "";
                        //decimal MaxMappingNo = 0;
                        //ChechMax = "Select Max(Mapping_No) As MaxMap From PaddyMapping_Godown Where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' and Mill_ID='" + ddlMillName.SelectedValue.ToString() + "' and CropYear='" + txtYear.Text + "' ";
                        //da = new SqlDataAdapter(ChechMax, con);
                        //ds = new DataSet();
                        //da.Fill(ds);

                        //if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                        //{
                        //    MaxMappingNo = decimal.Parse(ds.Tables[0].Rows[0]["MaxMap"].ToString());
                        //}

                        ChechMax = "select CONVERT(varchar(10),YEAR(GETDATE()))+CONVERT(varchar(10),MONTH(GETDATE()))+CONVERT(varchar(10),DAY(GETDATE()))+CONVERT(varchar(10),DATENAME(HH,GETDATE()))+CONVERT(varchar(10),DATENAME(MI,GETDATE()))+CONVERT(varchar(10),DATENAME(SS,GETDATE()))+CONVERT(varchar(10),DATENAME(MS,GETDATE())) As DCDate";
                        da       = new SqlDataAdapter(ChechMax, con);
                        ds       = new DataSet();
                        da.Fill(ds);

                        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                        {
                            DCDate       = ds.Tables[0].Rows[0]["DCDate"].ToString();
                            MaxMappingNo = DCDate.Substring(2);
                        }

                        if (MaxMappingNo != "")
                        {
                            instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";

                            if (chkGodam.Checked == true)
                            {
                                for (int i = 0; i < GridView2.Rows.Count; i++)
                                {
                                    string RemPaddy        = GridView2.Rows[i].Cells[4].Text;
                                    string RemAllotedPaddy = GridView2.Rows[i].Cells[3].Text;
                                    string MappingNo       = GridView2.Rows[i].Cells[6].Text;
                                    instr += "Update PaddyMapping_Godown Set Alloted_CommonPaddy='" + RemAllotedPaddy + "', Rem_CommonPaddy='" + RemPaddy + "' where Mapping_No='" + MappingNo + "' ;";
                                }
                            }
                            else
                            {
                                for (int i = 0; i < GridView2.Rows.Count; i++)
                                {
                                    string RemPaddy        = GridView2.Rows[i].Cells[4].Text;
                                    string RemAllotedPaddy = GridView2.Rows[i].Cells[3].Text;
                                    string MappingNo       = GridView2.Rows[i].Cells[6].Text;
                                    instr += "Update PaddyMapping_Godown Set Alloted_CommonPaddy='" + RemAllotedPaddy + "', Rem_CommonPaddy='" + RemPaddy + "' where Mapping_No='" + MappingNo + "' ;";
                                }

                                DataTable dt = adddetails();
                                if (dt != null)
                                {
                                    for (int i = 0; i < dt.Rows.Count; i++)
                                    {
                                        string Mapping_No = MaxMappingNo + (i + 1);
                                        instr += "Insert into PaddyMapping_Godown(District,CropYear,Mill_ID,Agreement_ID,Mapping_No,IssueCenter,Godown_id,Alloted_CommonPaddy,Alloted_GradePaddy,Rem_CommonPaddy,Rem_GradePaddy,CreatedDate,IP_Address) values('" + dt.Rows[i]["DistCode"] + "','" + txtYear.Text + "','" + ddlMillName.SelectedValue.ToString() + "','" + ddlAgtmtNumber.SelectedValue.ToString() + "','" + Mapping_No + "','" + dt.Rows[i]["ICVal"] + "','" + dt.Rows[i]["GodownVal"] + "','" + dt.Rows[i]["QuantityQtls"] + "','0','" + dt.Rows[i]["QuantityQtls"] + "','0',GETDATE(),'" + GetIp + "');";
                                    }
                                }
                            }

                            instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                            cmd = new SqlCommand(instr, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                btnRecptSubmit.Enabled = btnAdd.Enabled = false;
                                Session["ICGBQ"]       = null;
                                ddlIssueCentre.Items.Clear();
                                ddlBranch.Items.Clear();
                                ddlGodown.Items.Clear();

                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Updated Successfully'); </script> ");
                                txtYear.Text      = "";
                                Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                            }
                        }
                        else
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Updation Not Allow'); </script> ");
                        }
                    }
                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
예제 #8
0
    protected void btnAccept_Click(object sender, EventArgs e)
    {
        if (ddlMobileNo.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Mobile Number For OTP'); </script> ");
            return;
        }
        else
        {
            if (txtDispMode.Text != "" && txtCommodity.Text != "")
            {
                ClientIP objClientIP = new ClientIP();
                string   GetIp       = (objClientIP.GETIP());

                if (Session["update"].ToString() == ViewState["update"].ToString())
                {
                    using (con = new SqlConnection(strcon))
                    {
                        try
                        {
                            con.Open();

                            string instr = "", smsToDist = "", smsToDistCode = "", smsToDist1 = "", smsToDistCode1 = "", strSMS1 = "", SMSToRackDist1 = "";

                            for (int i = 0; i < GridView1.Rows.Count; i++)
                            {
                                smsToDist     += ((smsToDist == "") ? "" : " , ") + "'" + GridView1.Rows[i].Cells[2].Text + "' = '" + GridView1.Rows[i].Cells[5].Text + "'";
                                smsToDistCode += ((smsToDistCode == "") ? "" : ",") + "'" + GridView1.Rows[i].Cells[6].Text + "'";
                            }

                            if (ViewState["hdfModeofDist"].ToString() == "Other")
                            {
                                for (int i = 0; i < GridView2.Rows.Count; i++)
                                {
                                    smsToDist1     += ((smsToDist1 == "") ? "" : ",") + "'" + GridView2.Rows[i].Cells[2].Text + "(" + GridView2.Rows[i].Cells[3].Text + ")'";
                                    smsToDistCode1 += ((smsToDistCode1 == "") ? "" : ",") + "'" + GridView2.Rows[i].Cells[4].Text + "'";
                                    SMSToRackDist1 += ((SMSToRackDist1 == "") ? "" : ",") + "'" + GridView2.Rows[i].Cells[1].Text + " To " + GridView2.Rows[i].Cells[2].Text + "-" + GridView2.Rows[i].Cells[3].Text + "'";
                                }

                                if (txtCommodity.Text == "Gunny")
                                {
                                    strSMS1 = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "'.Please Create TO By[" + SMSToRackDist1 + "]Bales. Please Create Movement Plan By[" + smsToDist1 + "]Bales";
                                }
                                else
                                {
                                    strSMS1 = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "'.Please Create TO By[" + SMSToRackDist1 + "]MT. Please Create Movement Plan By[" + smsToDist1 + "]MT";
                                }
                            }

                            if (ViewState["hdfModeofDist"].ToString() == "Both")
                            {
                                for (int i = 0; i < GridView2.Rows.Count; i++)
                                {
                                    if (GridView2.Rows[i].Cells[1].Text != GridView2.Rows[i].Cells[2].Text)
                                    {
                                        smsToDist1     += ((smsToDist1 == "") ? "" : ",") + "'" + GridView2.Rows[i].Cells[2].Text + "(" + GridView2.Rows[i].Cells[3].Text + ")'";
                                        smsToDistCode1 += ((smsToDistCode1 == "") ? "" : ",") + "'" + GridView2.Rows[i].Cells[4].Text + "'";
                                    }
                                    SMSToRackDist1 += ((SMSToRackDist1 == "") ? "" : ",") + "'" + GridView2.Rows[i].Cells[1].Text + " To " + GridView2.Rows[i].Cells[2].Text + "-" + GridView2.Rows[i].Cells[3].Text + "'";
                                }

                                if (txtCommodity.Text == "Gunny")
                                {
                                    strSMS1 = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "'.Please Create TO By[" + SMSToRackDist1 + "]Bales. Please Create Movement Plan By[" + smsToDist1 + "]Bales";
                                }
                                else
                                {
                                    strSMS1 = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "'.Please Create TO By[" + SMSToRackDist1 + "]MT. Please Create Movement Plan By[" + smsToDist1 + "]MT";
                                }
                            }

                            if (ViewState["hdfModeofDist"].ToString() == "Both" || ViewState["hdfModeofDist"].ToString() == "Other")
                            {
                                instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                        "Update StateMovementOrder Set IsAccepted='Y', AcceptedIP='" + GetIp + "',AcceptedDate=GETDATE(),Accepted_EmpID='" + hdfEmpID.Value + "',Accepted_MobileNo='" + hdfMobileNo.Value + "',Accepted_OTP='" + hdfOTP.Value + "' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "';";

                                instr += "Update StateSubMovementOrder Set IsAccepted='Y' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "';";

                                instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                            }
                            else
                            {
                                instr = "Update StateMovementOrder Set IsAccepted='Y', AcceptedIP='" + GetIp + "',AcceptedDate=GETDATE(),Accepted_EmpID='" + hdfEmpID.Value + "',Accepted_MobileNo='" + hdfMobileNo.Value + "',Accepted_OTP='" + hdfOTP.Value + "' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "'";
                            }

                            cmd = new SqlCommand(instr, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                btnAccept.Enabled       = btnReject.Enabled = ddlMvmtNo.Enabled = btnPrint.Enabled = false;
                                ChkOTP.Disabled         = true;
                                Session["MovmtOrderNo"] = ddlMvmtNo.SelectedItem.ToString();

                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Movement Order Is Accepted'); </script> ");

                                Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());

                                string strSMS = "";
                                //Code For SMS

                                if (txtCommodity.Text == "Gunny")
                                {
                                    if (ViewState["hdfModeofDist"].ToString() == "Other")
                                    {
                                        strSMS = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "' For '" + txtCommodity.Text + "', '" + txtGunnyType.Text + "', '" + txtDispMode.Text + "' From '" + ViewState["hdfFromDist"].ToString() + "' To (" + smsToDist + ")Bales With End Date'" + ViewState["hdfEndDate"].ToString() + "'. Please Send All Commodity To Other District.";
                                    }
                                    else if (ViewState["hdfModeofDist"].ToString() == "Both")
                                    {
                                        strSMS = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "' For '" + txtCommodity.Text + "', '" + txtGunnyType.Text + "', '" + txtDispMode.Text + "' From '" + ViewState["hdfFromDist"].ToString() + "' To (" + smsToDist + ")Bales With End Date'" + ViewState["hdfEndDate"].ToString() + "'. Please Send Commodity To Other District & Own District";
                                    }
                                    else
                                    {
                                        strSMS = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "' For '" + txtCommodity.Text + "', '" + txtGunnyType.Text + "', '" + txtDispMode.Text + "' From '" + ViewState["hdfFromDist"].ToString() + "' To (" + smsToDist + ")Bales With End Date'" + ViewState["hdfEndDate"].ToString() + "'";
                                    }
                                }
                                else
                                {
                                    if (ViewState["hdfModeofDist"].ToString() == "Other")
                                    {
                                        strSMS = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "' For '" + txtCommodity.Text + "', '" + txtDispMode.Text + "' From '" + ViewState["hdfFromDist"].ToString() + "' To (" + smsToDist + ")MT With End Date'" + ViewState["hdfEndDate"].ToString() + "'. Please Send All Commodity To Other District.";
                                    }
                                    else if (ViewState["hdfModeofDist"].ToString() == "Both")
                                    {
                                        strSMS = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "' For '" + txtCommodity.Text + "', '" + txtDispMode.Text + "' From '" + ViewState["hdfFromDist"].ToString() + "' To (" + smsToDist + ")MT With End Date'" + ViewState["hdfEndDate"].ToString() + "'. Please Send Commodity To Other District & Own District";
                                    }
                                    else
                                    {
                                        strSMS = "Movement Order Issued On '" + txtMODate.Text + "' with MO Number='" + ddlMvmtNo.SelectedItem.ToString() + "' For '" + txtCommodity.Text + "', '" + txtDispMode.Text + "' From '" + ViewState["hdfFromDist"].ToString() + "' To (" + smsToDist + ")MT With End Date'" + ViewState["hdfEndDate"].ToString() + "'";
                                    }
                                }

                                SMS Message = new SMS();

                                smsToDistCode += ",'" + ViewState["hdfFromDistCode"].ToString() + "'";
                                string FindDistContactNo = "select DM_Mobile,RM_Mobile,District_code From officers_list where District_code in (" + smsToDistCode + ")";
                                da = new SqlDataAdapter(FindDistContactNo, con);
                                ds = new DataSet();
                                da.Fill(ds);
                                string CheckDuplicate = "", GMPDS = hdfMobileNo.Value, SharmaSir = "9479374277";

                                if (ds != null)
                                {
                                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                                    {
                                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                                        {
                                            string UpdateSMS     = "";
                                            string checkLength   = ds.Tables[0].Rows[i]["DM_Mobile"].ToString();
                                            string checkLengthRM = ds.Tables[0].Rows[i]["RM_Mobile"].ToString();
                                            string DistCode      = ds.Tables[0].Rows[i]["District_code"].ToString();

                                            if (i == 0)
                                            {
                                                Message.SendSMS(GMPDS, strSMS);
                                                Thread.Sleep(1000);
                                                Message.SendSMS(SharmaSir, strSMS);
                                            }
                                            if (checkLength.Length == 10)
                                            {
                                                Message.SendSMS(checkLength, strSMS);
                                                if (ViewState["hdfFromDistCode"].ToString() == DistCode)
                                                {
                                                    UpdateSMS = "Update StateMovementOrder Set FrmDist_SMS='Y' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "' and FrmDist='" + ViewState["hdfFromDistCode"].ToString() + "';";
                                                }
                                                else
                                                {
                                                    UpdateSMS += "Update StateMovementOrder Set ToDist_SMS='Y' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "' and ToDist='" + DistCode + "' and FrmDist='" + ViewState["hdfFromDistCode"].ToString() + "';";
                                                }

                                                cmd = new SqlCommand(UpdateSMS, con);
                                                cmd.ExecuteNonQuery();

                                                //Thread.Sleep(1000);
                                            }
                                            if (checkLengthRM.Length == 10)
                                            {
                                                if (checkLength != checkLengthRM)
                                                {
                                                    if (checkLengthRM != CheckDuplicate)
                                                    {
                                                        Message.SendSMS(checkLengthRM, strSMS);
                                                        CheckDuplicate = checkLengthRM;
                                                        Thread.Sleep(1000);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                if (ViewState["hdfModeofDist"].ToString() == "Other" || ViewState["hdfModeofDist"].ToString() == "Both")
                                {
                                    SMS Message1 = new SMS();
                                    if (ds != null)
                                    {
                                        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                                        {
                                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                                            {
                                                string UpdateSMS = "", GMPDS1 = hdfMobileNo.Value, SharmaSir1 = "9479374277";
                                                string checkLength = ds.Tables[0].Rows[i]["DM_Mobile"].ToString();
                                                string DistCode    = ds.Tables[0].Rows[i]["District_code"].ToString();

                                                if (i == 0)
                                                {
                                                    Message1.SendSMS(GMPDS1, strSMS1);
                                                    Thread.Sleep(1000);
                                                    Message1.SendSMS(SharmaSir1, strSMS1);
                                                }
                                                if (DistCode != ViewState["hdfFromDistCode"].ToString())
                                                {
                                                    if (checkLength.Length == 10)
                                                    {
                                                        Message1.SendSMS(checkLength, strSMS1);

                                                        UpdateSMS = "Update StateSubMovementOrder Set FrmDist_SMS='Y' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "' and FrmDist='" + ViewState["hdfFromDistCode"].ToString() + "' and ToDist='" + DistCode + "';";
                                                        if (ViewState["hdfModeofDist"].ToString() == "Both")
                                                        {
                                                            UpdateSMS += "Update StateSubMovementOrder Set ToDist_SMS='Y' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "' and FrmDist='" + ViewState["hdfFromDistCode"].ToString() + "' and ToDist='" + DistCode + "' and ToOtherDist='" + DistCode + "';";
                                                        }
                                                        cmd = new SqlCommand(UpdateSMS, con);
                                                        cmd.ExecuteNonQuery();

                                                        //Thread.Sleep(1000);
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    string FindDistContactNo1 = "select DM_Mobile,District_code From officers_list where District_code in (" + smsToDistCode1 + ")";
                                    da1 = new SqlDataAdapter(FindDistContactNo1, con);
                                    ds1 = new DataSet();
                                    da1.Fill(ds1);

                                    if (ds1 != null)
                                    {
                                        if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0)
                                        {
                                            for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                                            {
                                                string checkLength = ds1.Tables[0].Rows[i]["DM_Mobile"].ToString();
                                                string DistCode    = ds1.Tables[0].Rows[i]["District_code"].ToString();

                                                if (checkLength.Length == 10)
                                                {
                                                    string UpdateSMS = "";
                                                    Message1.SendSMS(checkLength, strSMS1);

                                                    UpdateSMS += "Update StateSubMovementOrder Set ToDist_SMS='Y' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "' and FrmDist='" + ViewState["hdfFromDistCode"].ToString() + "' and ToOtherDist='" + DistCode + "';";
                                                    cmd        = new SqlCommand(UpdateSMS, con);
                                                    cmd.ExecuteNonQuery();
                                                    Thread.Sleep(1000);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                            }
                        }
                        catch (Exception ex)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                        }

                        finally
                        {
                            if (con.State != ConnectionState.Closed)
                            {
                                con.Close();
                            }
                            txtDispMode.Text = txtCommodity.Text = "";
                        }
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
            }
            else
            {
                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Enter Commodity & Mode of Dispatch'); </script> ");
            }
        }
    }
    protected void btnRecptSubmit_Click1(object sender, EventArgs e)
    {
        string DistCode = Session["dist_id"].ToString();

        double MillCharges = 0;

        if (txtMillCharges.Text != "")
        {
            MillCharges = double.Parse(txtMillCharges.Text);
        }


        if (GridView1.Rows.Count <= 0 && hdfMappingNo.Value == "" && chkRs.Checked == false)
        {
            btnRecptSubmit.Enabled = false;
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Add At Least One Distance'); </script> ");
            return;
        }
        else if (txtMillCharges.Text.Trim() == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Enter Milling Charges'); </script> ");
            return;
        }
        else if (ddlSector.SelectedIndex <= 0)
        {
            btnRecptSubmit.Enabled = false;
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Sector Name'); </script> ");
            return;
        }
        else if (MillCharges == 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Milling Charges Not Allow To 0'); </script> ");
            return;
        }
        else
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        ClientIP objClientIP = new ClientIP();
                        string   GetIp       = (objClientIP.GETIP());

                        con.Open();

                        string SubDCDate = "", DCDate = "", instr = "";
                        string selectmax = "Select CONVERT(varchar(10),YEAR(GETDATE()))+CONVERT(varchar(10),MONTH(GETDATE()))+CONVERT(varchar(10),DAY(GETDATE()))+CONVERT(varchar(10),DATENAME(HH,GETDATE()))+CONVERT(varchar(10),DATENAME(MI,GETDATE()))+CONVERT(varchar(10),DATENAME(SS,GETDATE()))+CONVERT(varchar(10),DATENAME(MS,GETDATE())) As DCDate";
                        da = new SqlDataAdapter(selectmax, con);
                        ds = new DataSet();
                        da.Fill(ds);

                        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                        {
                            DCDate    = ds.Tables[0].Rows[0]["DCDate"].ToString();
                            SubDCDate = DCDate.Substring(2);
                        }

                        if (SubDCDate != "")
                        {
                            instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";

                            if (hdfMappingNo.Value != "" && chkRs.Checked == false)
                            {
                                instr += "Insert Into PM_Transp_Rs_Log(District,CropYear,Mapping_No,SectorId,Lead_ID,Milling_Rs,Transp_Rs,CreatedDate,IP_Address,DeletedDate,DeletedIP,Operation) select District,CropYear,Mapping_No,SectorId,Lead_ID,Milling_Rs,Transp_Rs,CreatedDate,IP_Address,GETDATE(),'" + GetIp + "','D' From PM_Transp_Rs where Mapping_No IN (" + hdfMappingNo.Value + ") ";
                                instr += "Delete From PM_Transp_Rs where Mapping_No IN (" + hdfMappingNo.Value + ") ";
                            }
                            else if (chkRs.Checked == true && hdfMappingNo.Value == "")
                            {
                                instr += "Insert Into PM_Transp_Rs_Log(District,CropYear,Mapping_No,SectorId,Lead_ID,Milling_Rs,Transp_Rs,CreatedDate,IP_Address,DeletedDate,DeletedIP,Operation) select District,CropYear,Mapping_No,SectorId,Lead_ID,Milling_Rs,Transp_Rs,CreatedDate,IP_Address,GETDATE(),'" + GetIp + "','U' From PM_Transp_Rs where District='" + DistCode + "' and CropYear='" + txtYear.Text + "' and SectorId ='" + ddlSector.SelectedValue.ToString() + "' ";
                                instr += "Update PM_Transp_Rs set Milling_Rs='" + MillCharges + "' where District='" + DistCode + "' and CropYear='" + txtYear.Text + "' and SectorId ='" + ddlSector.SelectedValue.ToString() + "' ";
                            }
                            else
                            {
                                DataTable dt = adddetails();
                                if (dt != null && GridView1.Rows.Count > 0)
                                {
                                    for (int i = 0; i < dt.Rows.Count; i++)
                                    {
                                        string MaxMappingNo = SubDCDate + (i + 1);
                                        instr += "Insert Into PM_Transp_Rs(District,CropYear,Mapping_No,SectorId,Lead_ID,Milling_Rs,Transp_Rs,CreatedDate,IP_Address) values('" + DistCode + "','" + txtYear.Text + "','" + MaxMappingNo + "','" + dt.Rows[i]["SectorID"] + "','" + dt.Rows[i]["LeadID"] + "','" + MillCharges + "','" + dt.Rows[i]["TranspRs"] + "',GETDATE(),'" + GetIp + "') ; ";
                                    }
                                }
                            }
                            instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                        }

                        cmd = new SqlCommand(instr, con);
                        int count = cmd.ExecuteNonQuery();

                        if (count > 0)
                        {
                            btnRecptSubmit.Enabled = false;
                            Session["fdjfhxncdfh"] = null;
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Distance Master Data Saved Successfully'); </script> ");
                            lblmsg.Visible = true;
                            lblmsg.Text    = "Distance Master Data Saved Successfully";
                            ddlSector.Items.Clear();
                            ddlLead.Items.Clear();
                            txtMillCharges.Enabled = txtTranpRs.Enabled = btnAdd.Enabled = false;
                            Session["update"]      = Server.UrlEncode(System.DateTime.Now.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
    protected void bttsubmit_Click(object sender, EventArgs e)
    {
        if (ddlCropYear.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Crop Year'); </script> ");
            return;
        }
        else if (ddlMillName.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Miller name'); </script> ");
            return;
        }
        else if (ddlfdrbank.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select FDR Bank Name'); </script> ");
            return;
        }
        else if (ddlcheckbank.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Cheque Bank Name'); </script> ");
            return;
        }
        else if (txtfdrifsc.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please enter FDR Bank IFSC code'); </script> ");
            txtfdrifsc.Focus();
            return;
        }
        else if (txtcheckifsc.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Cheque Bank IFSC Code'); </script> ");
            txtcheckifsc.Focus();
            return;
        }
        else if (txtfdrDate.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please enter FDR Date'); </script> ");
            return;
        }
        else if (txtCheckDate.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Cheque Date'); </script> ");
            return;
        }
        else if (txtvalueFDR.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please enter value of FDR '); </script> ");
            txtvalueFDR.Focus();
            return;
        }
        else if (txtvalueCheck.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select value Cheque '); </script> ");
            txtvalueCheck.Focus();
            return;
        }
        else if (txtMaturityofFDR.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Maturity Date of FDR '); </script> ");
            return;
        }
        else if (txtBankFDRNumber.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please enter FDR/BankSecurity Number'); </script> ");
            txtBankFDRNumber.Focus();
            return;
        }
        else if (txtChequeNumber.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Cheque Number'); </script> ");
            txtChequeNumber.Focus();
            return;
        }

        else if (txtChequeNumber.Text == txtBankFDRNumber.Text)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('FDR Number and Cheque number can not be same'); </script> ");
            txtBankFDRNumber.Text = "";
            txtChequeNumber.Text  = "";
            txtBankFDRNumber.Focus();

            return;
        }
        else
        {
            string DistCode = Session["dist_id"].ToString();
            using (con = new SqlConnection(strcon))
            {
                try
                {
                    con.Open();

                    ClientIP          objClientIP   = new ClientIP();
                    string            GetIp         = objClientIP.GETIP();
                    ConvertServerDate ServerFDRDate = new ConvertServerDate();
                    string            FdrDATE       = ServerFDRDate.getDate_MDY(txtfdrDate.Text);

                    ConvertServerDate ServerMatFDRDate = new ConvertServerDate();
                    string            MaturityFdrDATE  = ServerMatFDRDate.getDate_MDY(txtMaturityofFDR.Text);

                    ConvertServerDate ServerChequeDate = new ConvertServerDate();
                    string            chequeDate       = ServerChequeDate.getDate_MDY(txtCheckDate.Text);
                    string            qrey             = "select max(FDR_ChequeID) as FDR_ChequeID from PM_FDR_and_Cheque_Master where LEN(FDR_ChequeID)<15 ";
                    da = new SqlDataAdapter(qrey, con);

                    ds = new DataSet();
                    da.Fill(ds);
                    //mobj1 = new MoveChallan(ComObj);
                    //string qrey = "select isnull(max(Inspector_ID),0) as Transporter_ID  from Inspector_Master_02017 where  Distt_ID='" + sid + "' and LEN(Inspector_ID)<8 ";
                    //DataSet ds = new DataSet();
                    // dmax.Fill(ds);
                    // DataTable dt = ds.Tables[""];
                    DataRow dr = ds.Tables[0].Rows[0];
                    //gatepass = dr["Inspector_ID"].ToString();
                    gatepass = ds.Tables[0].Rows[0]["FDR_ChequeID"].ToString();

                    if (gatepass == "")
                    {
                        gatepass = "******" + DistCode + "0";
                    }
                    else
                    {
                        getnum = Convert.ToInt32(gatepass);
                        //getnum = gatepass;
                        getnum   = getnum + 1;
                        gatepass = getnum.ToString();
                    }



                    int     lot_Allowed;
                    decimal cheque, FDR, LOTamt;
                    FDR    = Convert.ToDecimal(txtvalueFDR.Text);
                    cheque = Convert.ToDecimal(txtvalueCheck.Text);
                    LOTamt = Convert.ToDecimal(txtLot.Text);

                    decimal total;
                    total = FDR + cheque;
                    decimal lot    = total / LOTamt;
                    decimal floor1 = Math.Floor(lot);
                    lot_Allowed = Convert.ToInt32(floor1);


                    //ConvertServerDate ServerDate = new ConvertServerDate();
                    string strselect = "insert into PM_FDR_and_Cheque_Master (FDR_ChequeID, CropYear, Miller_Dist, MillerID, One_LotAmount, MinFDR, FDR_BankID, FDR_IFSC, FDR_Date, FDR_Value, FDR_Maturity, Max_Cheque, CHeque_bankID, Cheque_IFSC, Cheque_date, Cheque_Value, Lots_Allowed, CreatedDate, IP, Updated, FDR_OR_BankSecu, FDR_Number, Check_Number, State_Code, SubDist) values('" + gatepass + "', '" + ddlCropYear.SelectedValue.ToString() + "', '" + DistCode + "','" + ddlMillName.SelectedValue.ToString() + "','" + LOTamt + "','" + lblMinFDR.Text + "','" + ddlfdrbank.SelectedValue.ToString() + "','" + txtfdrifsc.Text + "','" + FdrDATE + "','" + txtvalueFDR.Text + "','" + MaturityFdrDATE + "','" + lblCheck.Text + "','" + ddlcheckbank.SelectedValue.ToString() + "','" + txtcheckifsc.Text + "','" + chequeDate + "','" + txtvalueCheck.Text + "','" + lot_Allowed + "',getdate(),'" + GetIp + "','N','" + ddlFDRBankSecurity.SelectedValue.ToString() + "','" + txtBankFDRNumber.Text + "', '" + txtChequeNumber.Text + "', '" + hdfStateCode.Value + "','" + hdfMillDist.Value + "')";
                    //string instr = "";
                    //instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                    //                   "insert into PM_RatioMaster_LOG select * from PM_RatioMaster as RM  where RM.CropYear='" + ddlCropYear.SelectedValue.ToString() + "'  and ParticularMiller!='Y' ; ";

                    //instr += "update PM_RatioMaster set Total='" + txttotal.Text + "', FDR='" + txtfdr.Text + "', Checks='" + txtcheck.Text + "', IP='" + GetIp + "', CreatedDate=getdate(), ParticularMiller='N', Lot_amount='" + txtlot.Text + "',Frm_Date='" + IssuedFromDate + "', To_Date='" + IssuedToDate + "'  where CropYear='" + ddlCropYear.SelectedValue.ToString() + "' and ParticularMiller!='Y'; ";

                    //instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                    cmd = new SqlCommand(strselect, con);
                    int count = cmd.ExecuteNonQuery();

                    if (count > 0)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully for Crop Year  " + ddlCropYear.SelectedValue.ToString() + "'); </script> ");
                        ddlCropYear.Enabled        = false;
                        ddlcheckbank.Enabled       = false;
                        ddlMillName.Enabled        = false;
                        ddlfdrbank.Enabled         = false;
                        ddlFDRBankSecurity.Enabled = false;
                        txtCheckDate.Enabled       = false;
                        txtfdrDate.Enabled         = false;
                        txtfdrifsc.Enabled         = false;
                        txtcheckifsc.Enabled       = false;
                        txtvalueCheck.Enabled      = false;
                        txtvalueFDR.Enabled        = false;
                        txtMaturityofFDR.Enabled   = false;
                        txtChequeNumber.Enabled    = false;
                        txtBankFDRNumber.Enabled   = false;
                        bttsubmit.Enabled          = false;
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                }

                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
    }
    protected void bttsubmit_Click(object sender, EventArgs e)
    {
        //string DistCode = Session["dist_id"].ToString();
        if (ddlCropYear.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Crop Year'); </script> ");
            return;
        }
        else if (ddlMillName.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Miller name'); </script> ");
            return;
        }
        else if (lblMinFDR.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Ratio of FDR is not available'); </script> ");

            return;
        }
        else if (lblCheck.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Ratio of Cheque is not available'); </script> ");

            return;
        }
        // ---------------
        else if (lblTotalFDR.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Total Value of FDR is not available'); </script> ");

            return;
        }
        else if (lblTotalCheque.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Total Value of Cheque is not available'); </script> ");

            return;
        }
        else if (lblBalancecheque.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Balance Value of cheque is not available'); </script> ");

            return;
        }

        else if (ddlcheckbank.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Cheque Bank Name'); </script> ");
            return;
        }

        else if (txtcheckifsc.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Cheque Bank IFSC Code'); </script> ");
            txtcheckifsc.Focus();
            return;
        }

        else if (txtCheckDate.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Cheque Date'); </script> ");
            return;
        }

        else if (txtvalueCheck.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select value Cheque '); </script> ");
            txtvalueCheck.Focus();
            return;
        }


        else if (txtChequeNumber.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please select Cheque Number'); </script> ");
            txtChequeNumber.Focus();
            return;
        }
        else
        {
            string DistCode = Session["dist_id"].ToString();
            using (con = new SqlConnection(strcon))
            {
                try
                {
                    con.Open();

                    ClientIP objClientIP = new ClientIP();
                    string   GetIp       = objClientIP.GETIP();


                    ConvertServerDate ServerChequeDate = new ConvertServerDate();
                    string            chequeDate       = ServerChequeDate.getDate_MDY(txtCheckDate.Text);

                    string qrey = "select max(FDRCheque_ID) as FDRCheque_ID from PM_Add_ChequeAgainstFDR where LEN(FDRCheque_ID)<20 ";
                    da = new SqlDataAdapter(qrey, con);

                    ds = new DataSet();
                    da.Fill(ds);
                    //mobj1 = new MoveChallan(ComObj);
                    //string qrey = "select isnull(max(Inspector_ID),0) as Transporter_ID  from Inspector_Master_02017 where  Distt_ID='" + sid + "' and LEN(Inspector_ID)<8 ";
                    //DataSet ds = new DataSet();
                    // dmax.Fill(ds);
                    // DataTable dt = ds.Tables[""];
                    DataRow dr = ds.Tables[0].Rows[0];
                    //gatepass = dr["Inspector_ID"].ToString();
                    gatepass = ds.Tables[0].Rows[0]["FDRCheque_ID"].ToString();

                    if (gatepass == "")
                    {
                        gatepass = "******";
                    }
                    else
                    {
                        getnum = Convert.ToInt32(gatepass);
                        //getnum = gatepass;
                        getnum   = getnum + 1;
                        gatepass = getnum.ToString();
                    }



                    //ConvertServerDate ServerDate = new ConvertServerDate();
                    string strselect = "insert into PM_Add_ChequeAgainstFDR (FDRCheque_ID, Miller_Dist, Miller_ID, FDR_Ratio ,Cheque_Ratio, Total_FDR, TotaL_Cheque, BalCheque_Qty, SubmitBal,ChequeBank, Cheque_IFSC, Cheque_Number, DateCheque, ChequeValue, CreatedDate, IP, CropYear, State_Code, SubDist) values('" + gatepass + "', '" + DistCode + "','" + ddlMillName.SelectedValue.ToString() + "','" + lblMinFDR.Text + "','" + lblCheck.Text + "','" + lblTotalFDR.Text + "','" + lblTotalCheque.Text + "','" + lblBalancecheque.Text + "','Y','" + ddlcheckbank.SelectedValue.ToString() + "','" + txtcheckifsc.Text + "','" + txtChequeNumber.Text + "','" + chequeDate + "','" + txtvalueCheck.Text + "',getdate(),'" + GetIp + "','" + ddlCropYear.SelectedValue.ToString() + "', '" + hdfStateCode.Value + "','" + hdfMillDist.Value + "')";
                    //string instr = "";
                    //instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                    //                   "insert into PM_RatioMaster_LOG select * from PM_RatioMaster as RM  where RM.CropYear='" + ddlCropYear.SelectedValue.ToString() + "'  and ParticularMiller!='Y' ; ";

                    //instr += "update PM_RatioMaster set Total='" + txttotal.Text + "', FDR='" + txtfdr.Text + "', Checks='" + txtcheck.Text + "', IP='" + GetIp + "', CreatedDate=getdate(), ParticularMiller='N', Lot_amount='" + txtlot.Text + "',Frm_Date='" + IssuedFromDate + "', To_Date='" + IssuedToDate + "'  where CropYear='" + ddlCropYear.SelectedValue.ToString() + "' and ParticularMiller!='Y'; ";

                    //instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                    cmd = new SqlCommand(strselect, con);
                    int count = cmd.ExecuteNonQuery();

                    if (count > 0)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully for Crop Year  " + ddlCropYear.SelectedValue.ToString() + "'); </script> ");
                        ddlCropYear.Enabled     = false;
                        ddlcheckbank.Enabled    = false;
                        ddlMillName.Enabled     = false;
                        ddlcheckbank.Enabled    = false;
                        txtcheckifsc.Enabled    = false;
                        txtChequeNumber.Enabled = false;
                        txtCheckDate.Enabled    = false;
                        txtvalueCheck.Enabled   = false;
                        bttsubmit.Enabled       = false;
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                }

                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
    }
예제 #12
0
    protected void btnRecptSubmit_Click1(object sender, EventArgs e)
    {
        if (ddlAcptNo.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select CMR Acceptance / Rejection Number'); </script> ");
            return;
        }
        else if (txtQty.Text == "" || txtBags.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select All Fields'); </script> ");
            return;
        }
        else if (hdfWHRValue.Value != "0")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('आपने जो नंबर Select किया है, उसके लिए WHR जारी किया जा चूका है, इसलिए आप इसे Delete नहीं कर सकते|'); </script> ");
            return;
        }
        else
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        ClientIP objClientIP = new ClientIP();
                        string   GetIp       = (objClientIP.GETIP());

                        con.Open();

                        string instr = "";

                        {
                            instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                    "Insert Into CMR_QualityInspection_Log(District,issueCentre_code,CropYear,Book_Number,Date,Mill_Name,Milling_Type,DO_Number,Agreement_ID,LotNumber,Acceptance_No,Rejection_No,Truck_No,LD_No,TotaGA,TotaS,TotaRemark,ChoteToteGA,ChoteToteS,ChoteToteRemark,VijatiyeGA,VijatiyeS,VijatiyeRemark,DamageDaaneGA,DamageDaaneS,DamageDaaneRemark,BadrangDaaneGA,BadrangDaaneS,BadrangDaaneRemark,ChaakiDaaneGA,ChaakiDaaneS,ChaakiDaaneRemark,LaalDaaneGA,LaalDaaneS,LaalDaaneRemark,OtherGA,OtherS,OtherRemark,ChokarDaaneGA,ChokarDaaneS,ChokarDaaneRemark,NamiGA,NamiS,NamiRemark,BookOnlyNumber,IP_Address,Current_DateTime,User_Agent,Submited,Rejected,Daane,Accept_CommonRice,Accept_GradeARice,Reject_CommonRice,Reject_GradeARice,Branch_Code,Godown_Code,Bags,BagType,Tags,TagNo,TruckNo1,DeletedDate,DeletedIP,Operation,ToulReceiptNo, Inspector_ID, Agreement_Dist, StackNumber) select District,issueCentre_code,CropYear,Book_Number,Date,Mill_Name,Milling_Type,DO_Number,Agreement_ID,LotNumber,Acceptance_No,Rejection_No,Truck_No,LD_No,TotaGA,TotaS,TotaRemark,ChoteToteGA,ChoteToteS,ChoteToteRemark,VijatiyeGA,VijatiyeS,VijatiyeRemark,DamageDaaneGA,DamageDaaneS,DamageDaaneRemark,BadrangDaaneGA,BadrangDaaneS,BadrangDaaneRemark,ChaakiDaaneGA,ChaakiDaaneS,ChaakiDaaneRemark,LaalDaaneGA,LaalDaaneS,LaalDaaneRemark,OtherGA,OtherS,OtherRemark,ChokarDaaneGA,ChokarDaaneS,ChokarDaaneRemark,NamiGA,NamiS,NamiRemark,BookOnlyNumber,IP_Address,Current_DateTime,User_Agent,Submited,Rejected,Daane,Accept_CommonRice,Accept_GradeARice,Reject_CommonRice,Reject_GradeARice,Branch_Code,Godown_Code,Bags,BagType,Tags,TagNo,TruckNo1,GETDATE(),'" + GetIp + "','D',ToulReceiptNo, Inspector_ID, Agreement_Dist, StackNumber From CMR_QualityInspection where Book_Number='" + ddlAcptNo.SelectedItem.ToString() + "' ; ";

                            instr += "Insert Into PaddyMilling_Agreement_Log select District,Dist_Manager_Name,Mill_Addr_District,Mill_Name,Mill_Operator_Name,Mill_Operator,CropYear,From_Date,To_Date,Common_Dhan,GradeA_Dhan,Total_Dhan,Agreement_ID,IP_Address,Current_DateTime,User_Agent,State,State_Code,DepositMoney,DhanLot,DhanAmount,DhanAmountType,DhanAmountDetails,Agrmt_Date,R_Arva,R_Ushna,Rem_Common_Dhan,Rem_GradeA_Dhan,Rem_Total_Dhan,Rem_DhanLot,Milling_Type,Return_CommonDhan,Return_GradeADhan,Return_TotalDhan,Return_CommonRice,Return_GradeARice,Return_TotalRice,Rejected,IsAccepted,MobileNO,AcceptedIP,AcceptedDate,GETDATE(),'" + GetIp + "','U' From PaddyMilling_Agreement_2017 where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' ; ";

                            instr += "Delete From CMR_QualityInspection where Book_Number='" + ddlAcptNo.SelectedItem.ToString() + "';";


                            if (hdfStatus.Value == "Y")
                            {
                                decimal RecdCMR = decimal.Parse(txtQty.Text);
                                instr += "Insert Into dbo.tbl_Receipt_Details_log select * From dbo.tbl_Receipt_Details where challan_no='" + ddlAcptNo.SelectedItem.ToString() + "' and S_of_arrival='05' ; ";
                                instr += "Delete From tbl_Receipt_Details where challan_no='" + ddlAcptNo.SelectedItem.ToString() + "' and S_of_arrival='05' ;";
                                instr += "Update PaddyMilling_Agreement_2017 set Return_CommonRice= (ISNULL(Return_CommonRice,0)-" + RecdCMR + "), Return_TotalRice= (ISNULL(Return_TotalRice,0)-" + RecdCMR + "),Rem_DhanLot=(Rem_DhanLot-1) where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "'; ";
                                instr += "Update CMR_DepositOrder set IsAccepted='N',IsRejected='N' where CMR_DO='" + hdfCMRDoNo.Value + "';";
                                instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                            }
                            else
                            {
                                instr += "Update PaddyMilling_DO_2017 Set DispatchDhan_IC='Y' where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' and CropYear='" + ddlCropyear.SelectedValue.ToString() + "' and DhanLot='" + hdfLotNo.Value + "' and Check_DO='" + hdfDO_NO.Value + "' ;";
                                instr += "Update PaddyMilling_Agreement_2017 set Rejected= (ISNULL(Rejected,0)-1) where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "'; ";
                                instr += "Update CMR_DepositOrder set IsAccepted='N',IsRejected='N' where CMR_DO='" + hdfCMRDoNo.Value + "';";
                                instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                            }
                        }

                        cmd = new SqlCommand(instr, con);
                        int count = cmd.ExecuteNonQuery();

                        if (count > 0)
                        {
                            btnRecptSubmit.Enabled = false;
                            //txtYear.Text = "";
                            ddlCropyear.Enabled    = false;
                            ddlMillName.Enabled    = false;
                            ddlAgtmtNumber.Enabled = false;
                            ddlAgtmtNumber.Enabled = false;

                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Your Record Is Deleted Successfully'); </script> ");

                            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                        }
                        else
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                        }
                    }
                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
예제 #13
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Session["update"].ToString() == ViewState["update"].ToString())
        {
            using (con = new SqlConnection(strcon))
            {
                try
                {
                    if (ddlEmpCode.SelectedIndex <= 0)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Code of Employee'); </script> ");
                        return;
                    }
                    else
                    {
                        ClientIP objClientIP = new ClientIP();
                        string   GetIp       = (objClientIP.GETIP());

                        string select = "";

                        if (hdfData.Value == "1") //For Update
                        {
                            select  = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";
                            select += "Insert Into PDSMO_EMPContactDetails_Log(Mobile_No,Email,Name,Employee_ID,IP_Address,CreatedDate,UpdatedDate,Updated_IP) Select Mobile_No,Email,Name,Employee_ID,IP_Address,CreatedDate,GETDATE(),'" + GetIp + "' From PDSMO_EMPContactDetails Where Mobile_No='" + hdfMobileNo.Value + "' ;";
                            select += "Update PDSMO_EMPContactDetails Set Email='" + txtDMMail.Text + "',Name='" + txtDMName.Text + "',Employee_ID='" + ddlEmpCode.SelectedItem.ToString() + "',UpdatedDate=GETDATE(),Updated_IP='" + GetIp.ToString() + "' where Mobile_No='" + hdfMobileNo.Value + "' ;";
                            select += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                        }
                        else if (hdfData.Value == "0") //For Insert
                        {
                            select = "Insert Into PDSMO_EMPContactDetails(Mobile_No,Email,Name,Employee_ID,IP_Address,CreatedDate) Values('" + hdfMobileNo.Value + "','" + txtDMMail.Text + "','" + txtDMName.Text + "','" + ddlEmpCode.SelectedItem.ToString() + "','" + GetIp.ToString() + "',GETDATE())";
                        }

                        con.Open();
                        cmd = new SqlCommand(select, con);
                        int count = cmd.ExecuteNonQuery();

                        if (count > 0)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Save Successfully...'); </script> ");
                            txtDMMail.Enabled  = txtDMName.Enabled = false;
                            ddlEmpCode.Enabled = false;
                            btnSave.Enabled    = false;
                            hdfData.Value      = hdfMobileNo.Value = "";

                            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                        }
                        else
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                }

                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
        else
        {
            Response.Redirect(Request.Url.AbsoluteUri);
        }
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (ddlTruckChallan.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Truck Challan No.'); </script> ");
            return;
        }

        else
        {
            ClientIP objClientIP = new ClientIP();
            string   GetIp       = (objClientIP.GETIP());


            using (con = new SqlConnection(strcon))
            {
                try
                {
                    con.Open();



                    string instr = "";

                    instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";

                    instr += "Insert Into CMS_GodownSurveyor_Inspection_Log([GodownSurveyorInsp_ID], [Commodity] ,[TruckChallan], [SocietyDist] , [Society], [CropYear], [DateofDispatch], [TransporterID]      ,[TruckNumber]      ,[Quantity]      ,[Bags]      ,[BagsType]      ,[Status]      ,[BookNumber]      ,[AcceptanceNumber]      ,[RejectionNumber]      ,[ReceivingGodown]      ,[ReceivingBranch]      ,[Sarson]      ,[Sarson_ImpForeignmatt_IncTaramira]      ,[Sarson_Admix_WOT_IncToria]      ,[Sarson_Unripe_ShirvellImmature]      ,[Sarson_DamagedAndWeevilled]      ,[Sarson_SmallAtrophiedSeeds]      ,[Sarson_MoistureContent]      ,[Massor]      ,[Massur_ForeignMatter]      ,[Massur_Admixture]      ,[Massur_DamagedPulses]      ,[Massur_SligDamagedPulses]      ,[Massur_ImmaShrivellPulses]      ,[Massur_weevilledPulses]      ,[Massur_MoistureContent]      ,[Channa]      ,[Gram_ForeignMatter]      ,[Gram_OtherFoodGrains]      ,[Gram_DamagedGrains]      ,[Gram_SligDamagedTouchGrains]       ,[Gram_ImmaShrivAndBroGrains] ,[Gram_AdmixOfOtherVarieties] ,[Gram_WeevilleGrains] ,[Gram_MositureContent]  ,[CreatedDate] ,[IP], Insp_ID, [SurveyorID] ,[SurveyorName], [SurveyorMob], DateOfInsp, DeletedDate, DeletedIP) select [GodownSurveyorInsp_ID], [Commodity] ,[TruckChallan], [SocietyDist] , [Society], [CropYear], [DateofDispatch], [TransporterID]      ,[TruckNumber]      ,[Quantity]      ,[Bags]      ,[BagsType]      ,[Status]      ,[BookNumber]      ,[AcceptanceNumber]      ,[RejectionNumber]      ,[ReceivingGodown]      ,[ReceivingBranch]      ,[Sarson]      ,[Sarson_ImpForeignmatt_IncTaramira]      ,[Sarson_Admix_WOT_IncToria]      ,[Sarson_Unripe_ShirvellImmature]      ,[Sarson_DamagedAndWeevilled]      ,[Sarson_SmallAtrophiedSeeds]      ,[Sarson_MoistureContent]      ,[Massor]      ,[Massur_ForeignMatter]      ,[Massur_Admixture]      ,[Massur_DamagedPulses]      ,[Massur_SligDamagedPulses]      ,[Massur_ImmaShrivellPulses]      ,[Massur_weevilledPulses]      ,[Massur_MoistureContent]      ,[Channa]      ,[Gram_ForeignMatter]      ,[Gram_OtherFoodGrains]      ,[Gram_DamagedGrains]      ,[Gram_SligDamagedTouchGrains]       ,[Gram_ImmaShrivAndBroGrains] ,[Gram_AdmixOfOtherVarieties] ,[Gram_WeevilleGrains] ,[Gram_MositureContent]  ,[CreatedDate] ,[IP], Insp_ID, [SurveyorID] ,[SurveyorName], [SurveyorMob], DateOfInsp, GetDate(),'" + GetIp + "' From CMS_GodownSurveyor_Inspection where TruckChallan='" + ddlTruckChallan.SelectedValue.ToString() + "' ; ";
                    instr += "update IssueToSangrahanaKendra_CSM2018 set GS_Status='0', G_Surveyor='0' where TruckChalanNo='" + ddlTruckChallan.SelectedValue.ToString() + "' ;";
                    instr += "delete from CMS_GodownSurveyor_Inspection  where TruckChallan='" + ddlTruckChallan.SelectedValue.ToString() + "';";


                    instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                    cmd = new SqlCommand(instr, con);
                    int count = cmd.ExecuteNonQuery();

                    if (count > 0)
                    {
                        btnDelete.Enabled       = false;
                        ddlTruckChallan.Enabled = false;
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Deleted Successfully'); </script> ");
                    }
                    else
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Deletion Not Allow'); </script> ");
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                }

                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
    }
예제 #15
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (ddlMoveOrdNo.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Movement order Number'); </script> ");
            return;
        }
        else if (ddlCropYear.SelectedIndex <= 0)
        {
            btnDelete.Enabled = false;
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select CropYear|'); </script> ");
            return;
        }

        else
        {
            using (con = new SqlConnection(strcon))
            {
                try
                {
                    string   DistCode    = Session["dist_id"].ToString();
                    ClientIP objClientIP = new ClientIP();
                    string   GetIp       = (objClientIP.GETIP());


                    con.Open();

                    string instr = "";

                    instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";

                    instr += "insert into RecAgainst_StateMovementOrder_Logs select MoveOrdernum ,SMO ,RMO, FrmDist, ToDist, Commodity ,Quantity, CropYear, ReachDate, MODate, ModeofDispatch, DispatchAgainstMO, ReceivedAgainstMO, CreatedDate, IP, Issue_Center, Branch, Godown, RequiredQuantity, RemQty, SubmitedQty, IssuedQty, SubSMO, ModeofDist, GETDATE(),'" + GetIp + "' from RecAgainst_StateMovementOrder where ModeofDispatch='12' and MoveOrdernum='" + ddlMoveOrdNo.SelectedValue.ToString() + "' and ToDist='" + DistCode + "'";
                    instr += "update StateMovementOrder set RecAgainstHO='N' where ModeofDispatch='12' and MoveOrdernum='" + ddlMoveOrdNo.SelectedValue.ToString() + "' and ToDist='" + DistCode + "'";

                    instr += "Delete From RecAgainst_StateMovementOrder where ModeofDispatch='12' and MoveOrdernum='" + ddlMoveOrdNo.SelectedValue.ToString() + "' and ToDist='" + DistCode + "'";

                    instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                    cmd = new SqlCommand(instr, con);
                    int count = cmd.ExecuteNonQuery();

                    if (count > 0)
                    {
                        btnDelete.Enabled = false;
                    }
                    else
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Deletion Not Allow'); </script> ");
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                }

                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
    }
    protected void btnReject_Click(object sender, EventArgs e)
    {
        string DistID = Session["dist_id"].ToString();

        if (ddlAgrmtNo.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('कृपया अनुबंध का नंबर चुने|'); </script> ");
            return;
        }
        else
        {
            if (txtAgrmtLot.Text != "" && txtSecurityLot.Text != "")
            {
                ClientIP objClientIP = new ClientIP();
                string   GetIp       = (objClientIP.GETIP());

                if (Session["update"].ToString() == ViewState["update"].ToString())
                {
                    using (con = new SqlConnection(strcon))
                    {
                        try
                        {
                            con.Open();

                            string instr = "";

                            instr = "Update PaddyMilling_Agreement_2017 Set IsAccepted='N', AcceptedIP='" + GetIp + "',AcceptedDate=GETDATE() where District='" + DistID + "' and CropYear='" + txtCropYear.Text + "' and Agreement_ID='" + ddlAgrmtNo.SelectedItem.ToString() + "' and Total_Dhan='" + txtTotalDhan.Text + "' and DhanLot='" + txtSecurityLot.Text + "' and DhanAmountDetails='" + txtAgrmtLot.Text + "'";

                            cmd = new SqlCommand(instr, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                btnAccept.Enabled = btnReject.Enabled = ddlAgrmtNo.Enabled = false;
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Milling Agreement Is Rejected'); </script> ");
                                txtAgrmtLot.Text  = txtSecurityLot.Text = "";
                                Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                            }
                        }
                        catch (Exception ex)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                        }

                        finally
                        {
                            if (con.State != ConnectionState.Closed)
                            {
                                con.Close();
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
            }
        }
    }
예제 #17
0
    protected void btnRecptSubmit_Click1(object sender, EventArgs e)
    {
        if (ddlAcptNo.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select CMR Acceptance / Rejection Number'); </script> ");
            return;
        }
        else if (txtQty.Text == "" || txtBags.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select All Fields'); </script> ");
            return;
        }
        else
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        ClientIP objClientIP = new ClientIP();
                        string   GetIp       = (objClientIP.GETIP());

                        decimal RecdCMR = decimal.Parse(txtQty.Text);

                        con.Open();

                        string instr = "";

                        {
                            instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                    "Insert Into ReceiptCMR_FCI_Log(Paddy_AgrmtDist,CMR_RecdDist,CMR_RecdState,Receipt_ID,Receipt_Date,CommonRice,GradeARice,Bags,Truck_No,Truck_No1,CropYear,Mill_ID,Milling_Type,Agreement_ID,Lot_No,DO_No,CreatedDate,IP_Address,IsAccepted,Acceptance_No,WeightCheck_No,WeightCheck_Date,BagType,WHR_No,DeletedDate,DeletedIP,Operation) Select Paddy_AgrmtDist,CMR_RecdDist,CMR_RecdState,Receipt_ID,Receipt_Date,CommonRice,GradeARice,Bags,Truck_No,Truck_No1,CropYear,Mill_ID,Milling_Type,Agreement_ID,Lot_No,DO_No,CreatedDate,IP_Address,IsAccepted,Acceptance_No,WeightCheck_No,WeightCheck_Date,BagType,WHR_No,GETDATE(),'" + GetIp + "','D' From  Receipt_CMR_FCI where Receipt_ID='" + ddlAcptNo.SelectedItem.ToString() + "' ;";

                            instr += "Delete From Receipt_CMR_FCI Where Receipt_ID='" + ddlAcptNo.SelectedItem.ToString() + "' ;";

                            instr += "Update PaddyMilling_DO Set DispatchDhan_IC='N' where Mill_Name='" + ddlMillName.SelectedValue.ToString() + "' and Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' and CropYear='" + txtYear.Text + "' and DhanLot='" + txtLotNo.Text + "' and Check_DO='" + txtDONo.Text + "'; ";

                            instr += "Insert Into PaddyMilling_Agreement_Log select District,Dist_Manager_Name,Mill_Addr_District,Mill_Name,Mill_Operator_Name,Mill_Operator,CropYear,From_Date,To_Date,Common_Dhan,GradeA_Dhan,Total_Dhan,Agreement_ID,IP_Address,Current_DateTime,User_Agent,State,State_Code,DepositMoney,DhanLot,DhanAmount,DhanAmountType,DhanAmountDetails,Agrmt_Date,R_Arva,R_Ushna,Rem_Common_Dhan,Rem_GradeA_Dhan,Rem_Total_Dhan,Rem_DhanLot,Milling_Type,Return_CommonDhan,Return_GradeADhan,Return_TotalDhan,Return_CommonRice,Return_GradeARice,Return_TotalRice,Rejected,IsAccepted,MobileNO,AcceptedIP,AcceptedDate,GETDATE(),'" + GetIp + "','U' From PaddyMilling_Agreement where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' ; ";

                            instr += "Update PaddyMilling_Agreement set Return_CommonRice= (ISNULL(Return_CommonRice,0)-" + RecdCMR + "), Return_TotalRice= (ISNULL(Return_TotalRice,0)-" + RecdCMR + ") where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' ; ";

                            instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                        }

                        cmd = new SqlCommand(instr, con);
                        int count = cmd.ExecuteNonQuery();

                        if (count > 0)
                        {
                            btnRecptSubmit.Enabled = false;
                            txtYear.Text           = "";
                            ddlMillName.Enabled    = ddlAgtmtNumber.Enabled = ddlAcptNo.Enabled = ddlFrmDist.Enabled = false;

                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Your Record Is Deleted Successfully'); </script> ");

                            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                        }
                        else
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                        }
                    }
                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
    protected void btnRecptSubmit_Click(object sender, EventArgs e)
    {
        if (txtCropYear.Text != "" || txtComdty.Text != "")
        {
            double TotalMOQty    = double.Parse(txtTotalQty.Text);
            string strTotalMOQty = TotalMOQty.ToString("0.00");

            if (hdfFooterQtyTotal.Value == strTotalMOQty)
            {
                ClientIP objClientIP = new ClientIP();
                string   GetIp       = (objClientIP.GETIP());

                if (Session["update"].ToString() == ViewState["update"].ToString())
                {
                    using (con = new SqlConnection(strcon))
                    {
                        try
                        {
                            con.Open();

                            string instr = "";

                            instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                    "Update StateMovementOrder Set SMS_frmDist='Y' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "' and FrmDist='" + hdfFrmDist.Value + "' and Commodity='" + hdfComdty.Value + "' and CropYear='" + txtCropYear.Text + "' and ModeofDispatch='13' and SMS_frmDist='N';";

                            DataTable dt = adddetails();
                            if (dt != null)
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    string SubSMO          = ((dt.Rows[i]["SMONumber"].ToString()) + ((60 + i) + 1));
                                    double ConvertMtToQtls = 0;

                                    if (hdfComdty.Value == "25")
                                    {
                                        ConvertMtToQtls = ((double.Parse(dt.Rows[i]["quantity"].ToString())));
                                    }
                                    else
                                    {
                                        ConvertMtToQtls = ((double.Parse(dt.Rows[i]["quantity"].ToString())) * 10);
                                    }

                                    instr += "Insert into StateSubMovementOrder(MoveOrdernum,SMO,SubSMO,FrmDist,ToDist,ModeofDist,ToOtherDist,Commodity,Quantity,CropYear,ReachDate,MOCreatedDate,ModeofDispatch,IsIssued,CreatedDate,IP,IsMvmtPlan,QtyByDist,RemQty,SubmitedQty,IsAccepted) values('" + ddlMvmtNo.SelectedItem.ToString() + "','" + dt.Rows[i]["SMONumber"] + "','" + SubSMO + "','" + hdfHideFrmDist.Value + "','" + dt.Rows[i]["todistval"] + "','" + hdfDistMode.Value + "','" + dt.Rows[i]["toOtherdistval"] + "','" + hdfComdty.Value + "','" + dt.Rows[i]["TotalQty"] + "','" + txtCropYear.Text + "','" + hdfReachDate.Value + "','" + hdfMOCreatedDate.Value + "','13','N',GETDATE(),'" + GetIp + "','N','" + ConvertMtToQtls + "','" + ConvertMtToQtls + "',0,'F');";
                                }
                            }

                            instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                            cmd = new SqlCommand(instr, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                btnRecptSubmit.Enabled  = btnAdd.Enabled = false;
                                btnPrint.Enabled        = true;
                                Session["GridFill"]     = null;
                                Session["MovmtOrderNo"] = ddlMvmtNo.SelectedItem.ToString();

                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully'); </script> ");
                                txtCropYear.Text  = txtComdty.Text = "";
                                Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                            }
                        }
                        catch (Exception ex)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                        }

                        finally
                        {
                            if (con.State != ConnectionState.Closed)
                            {
                                con.Close();
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
            }
            else
            {
                Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Total MO Quantiy Is Not Equal To Total Qty'); </script> ");
            }
        }
    }
    protected void btnRecptSubmit_Click1(object sender, EventArgs e)
    {
        int total = (int.Parse(ddlSecurityLot.SelectedItem.ToString()) + int.Parse(txtAgrmtSecurityLot.Text));

        int securityLot = int.Parse(ddlSecurityLot.SelectedItem.ToString());

        if (ddlSecurityLot.SelectedIndex > 0 && total <= int.Parse(hdfSecurityLot.Value))
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        con.Open();

                        districtid = Session["dist_id"].ToString();

                        ClientIP objClientIP = new ClientIP();
                        string   GetIp       = objClientIP.GETIP();

                        string instr = "";

                        instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                "Update PaddyMilling_Agreement_2017 Set DhanLot=(DhanLot+" + securityLot + ") , Rem_DhanLot=(Rem_DhanLot+" + securityLot + " ) where District='" + districtid + "' and Mill_Name='" + ddlMillName.SelectedValue.ToString() + "' and CropYear='" + txtYear.Text + "' and Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "'; ";

                        instr += "Insert Into PMilling_SecurityLotAmt(District,CropYear,Mill_ID,Agreement_ID,Agrmt_Lot,Additional_DhanLot,CreatedDate,IP_Address) values('" + districtid + "','" + txtYear.Text + "','" + ddlMillName.SelectedValue.ToString() + "','" + ddlAgtmtNumber.SelectedItem.ToString() + "','" + txtAgrmtLot.Text + "','" + securityLot + "',GETDATE(),'" + GetIp + "'); ";

                        instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                        cmd = new SqlCommand(instr, con);
                        int count = cmd.ExecuteNonQuery();

                        if (count > 0)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Your Agreement Security Lot Is Updated Successfully...'); </script> ");
                            btnRecptSubmit.Enabled = false;
                            ddlMillName.Enabled    = ddlAgtmtNumber.Enabled = ddlSecurityLot.Enabled = false;

                            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
    protected void bttdelete_Click(object sender, EventArgs e)
    {
        if (lblacprjt.Text == "Acceptance No.")
        {
            using (con = new SqlConnection(strcon))
            {
                try
                {
                    ClientIP objClientIP = new ClientIP();
                    string   GetIp       = (objClientIP.GETIP());


                    con.Open();

                    string instr = "";

                    instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";


                    instr += "Insert Into PM_Inspection_ByOnemember_log(InspectionID, CropYear, season, D_O_Inspection, Inspector_Name, Designation, mill_phone, District_ID, ICenter_ID, Godown_ID, Stack_ID, TotaS, ChoteToteS, VijatiyeS, DamageDaaneS, BadrangDaaneS, ChaakiDaaneS, LaalDaaneS, NamiS, Status, IP, Created_Date, Stack_Name, Acceptance_NO, Rejection_NO, Bags, lot_No_one, lot_No_two, lot_No_three, lot_No_four, lot_No_five, lot_No_six, Miller_District, Miller_Name, Miller_District_one, Miller_Name_one, Miller_District_two, Miller_Name_two, Miller_District_three, Miller_Name_three,  Miller_District_Four, Miller_Name_Four, MoreThan_OneMiller, Miller_Count, lot_No_seven, lot_No_eight, DeletedIP,DeletedDate) Select InspectionID, CropYear, season, D_O_Inspection, Inspector_Name, Designation, mill_phone, District_ID, ICenter_ID, Godown_ID, Stack_ID, TotaS, ChoteToteS, VijatiyeS, DamageDaaneS, BadrangDaaneS, ChaakiDaaneS, LaalDaaneS, NamiS, Status, IP, Created_Date, Stack_Name, Acceptance_NO, Rejection_NO, Bags, lot_No_one, lot_No_two, lot_No_three, lot_No_four, lot_No_five, lot_No_six, Miller_District, Miller_Name, Miller_District_one, Miller_Name_one, Miller_District_two, Miller_Name_two, Miller_District_three, Miller_Name_three,  Miller_District_Four, Miller_Name_Four, MoreThan_OneMiller, Miller_Count, lot_No_seven, lot_No_eight, '" + GetIp + "', GETDATE() From PM_Inspection_ByOnemember where Acceptance_NO='" + ddlacpt.SelectedValue.ToString() + "' ;";

                    instr += "Delete From PM_Inspection_ByOnemember where Acceptance_NO='" + ddlacpt.SelectedValue.ToString() + "'";

                    instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                    cmd = new SqlCommand(instr, con);
                    int count = cmd.ExecuteNonQuery();

                    if (count > 0)
                    {
                        btnDelete.Enabled = false;

                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert(' Deleted Successfully'); </script> ");

                        btnDelete.Enabled = false;
                        //txtYear.Text = "";
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                }

                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
        else
        {
            using (con = new SqlConnection(strcon))
            {
                try
                {
                    ClientIP objClientIP = new ClientIP();
                    string   GetIp       = (objClientIP.GETIP());


                    con.Open();

                    string instr = "";

                    instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";


                    instr += "Insert Into PM_Inspection_ByOnemember_log(InspectionID, CropYear, season, D_O_Inspection, Inspector_Name, Designation, mill_phone, District_ID, ICenter_ID, Godown_ID, Stack_ID, TotaS, ChoteToteS, VijatiyeS, DamageDaaneS, BadrangDaaneS, ChaakiDaaneS, LaalDaaneS, NamiS, Status, IP, Created_Date, Stack_Name, Acceptance_NO, Rejection_NO, Bags, lot_No_one, lot_No_two, lot_No_three, lot_No_four, lot_No_five, lot_No_six, Miller_District, Miller_Name, Miller_District_one, Miller_Name_one, Miller_District_two, Miller_Name_two, Miller_District_three, Miller_Name_three,  Miller_District_Four, Miller_Name_Four, MoreThan_OneMiller, Miller_Count, lot_No_seven, lot_No_eight, DeletedIP,DeletedDate) Select InspectionID, CropYear, season, D_O_Inspection, Inspector_Name, Designation, mill_phone, District_ID, ICenter_ID, Godown_ID, Stack_ID, TotaS, ChoteToteS, VijatiyeS, DamageDaaneS, BadrangDaaneS, ChaakiDaaneS, LaalDaaneS, NamiS, Status, IP, Created_Date, Stack_Name, Acceptance_NO, Rejection_NO, Bags, lot_No_one, lot_No_two, lot_No_three, lot_No_four, lot_No_five, lot_No_six, Miller_District, Miller_Name, Miller_District_one, Miller_Name_one, Miller_District_two, Miller_Name_two, Miller_District_three, Miller_Name_three,  Miller_District_Four, Miller_Name_Four, MoreThan_OneMiller, Miller_Count, lot_No_seven, lot_No_eight, '" + GetIp + "', GETDATE() From PM_Inspection_ByOnemember where Rejection_NO='" + ddlacpt.SelectedValue.ToString() + "' ;";

                    instr += "Delete From PM_Inspection_ByOnemember where Rejection_NO='" + ddlacpt.SelectedValue.ToString() + "'";

                    instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                    cmd = new SqlCommand(instr, con);
                    int count = cmd.ExecuteNonQuery();

                    if (count > 0)
                    {
                        btnDelete.Enabled = false;

                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert(' Deleted Successfully'); </script> ");


                        //txtYear.Text = "";
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                }

                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
    }
예제 #21
0
    protected void btnReject_Click(object sender, EventArgs e)
    {
        if (ddlMobileNo.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Mobile Number For OTP'); </script> ");
            return;
        }
        else
        {
            if (txtDispMode.Text != "" && txtCommodity.Text != "")
            {
                ClientIP objClientIP = new ClientIP();
                string   GetIp       = (objClientIP.GETIP());

                if (Session["update"].ToString() == ViewState["update"].ToString())
                {
                    using (con = new SqlConnection(strcon))
                    {
                        try
                        {
                            con.Open();

                            string instr = "";

                            instr = "Update StateMovementOrder Set IsAccepted='N', AcceptedIP='" + GetIp + "',AcceptedDate=GETDATE(),Accepted_EmpID='" + hdfEmpID.Value + "',Accepted_MobileNo='" + hdfMobileNo.Value + "',Accepted_OTP='" + hdfOTP.Value + "' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "'";

                            cmd = new SqlCommand(instr, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                btnAccept.Enabled       = btnReject.Enabled = ddlMvmtNo.Enabled = false;
                                ChkOTP.Disabled         = true;
                                btnPrint.Enabled        = true;
                                Session["MovmtOrderNo"] = ddlMvmtNo.SelectedItem.ToString();

                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Movement Order Is Rejected'); </script> ");
                                txtDispMode.Text     = txtCommodity.Text = "";
                                Session["Acpt/Rjct"] = "Reject";
                                Session["update"]    = Server.UrlEncode(System.DateTime.Now.ToString());
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                            }
                        }
                        catch (Exception ex)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                        }

                        finally
                        {
                            if (con.State != ConnectionState.Closed)
                            {
                                con.Close();
                            }
                            txtDispMode.Text = txtCommodity.Text = "";
                        }
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
            }
        }
    }
예제 #22
0
    protected void btnRecptSubmit_Click(object sender, EventArgs e)
    {
        Dist_Id = Session["dist_id"].ToString();

        if (txtBookNo.Text.Trim() != "" && txtFrmPageNo.Text.Trim() != "" && txtUptoPageNo.Text.Trim() != "")
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        con.Open();

                        string select = "Select Book_No From TruckChallan_Book where Book_No='" + txtBookNo.Text.Trim() + "' and District='" + Dist_Id + "'";
                        da = new SqlDataAdapter(select, con);
                        ds = new DataSet();
                        da.Fill(ds);

                        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Book Number Already Available'); </script> ");
                            return;
                        }
                        else
                        {
                            ClientIP objClientIP = new ClientIP();
                            string   GetIp       = (objClientIP.GETIP());

                            string insert = "Insert Into TruckChallan_Book(Book_No,From_Page,Upto_Page,District,CreatedDate,IP,Rem_Page) values('" + txtBookNo.Text.Trim() + "','" + txtFrmPageNo.Text.Trim() + "','" + txtUptoPageNo.Text.Trim() + "','" + Dist_Id + "',GETDATE(),'" + GetIp + "','" + txtUptoPageNo.Text.Trim() + "')";

                            cmd = new SqlCommand(insert, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                btnRecptSubmit.Enabled = false;

                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully'); </script> ");
                                //txtBookNo.Text = txtFrmPageNo.Text = txtUptoPageNo.Text = "";

                                Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
        else
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Enter All Field'); </script> ");
        }
    }
예제 #23
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (ddlDONo.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select DO Number'); </script> ");
            return;
        }

        decimal DOQty = 0, DORemQty = 0;

        for (int i = 0; i < GridView2.Rows.Count; i++)
        {
            DOQty    += decimal.Parse(GridView2.Rows[i].Cells[4].Text);
            DORemQty += decimal.Parse(GridView2.Rows[i].Cells[5].Text);
        }

        if (DOQty != DORemQty)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('इस डिलीवरी आर्डर के विरुद्ध धान जारी किया जा चूका है, इसलिए आप इसे Delete नहीं कर सकते|'); </script> ");
            return;
        }

        ClientIP objClientIP = new ClientIP();
        string   GetIp       = (objClientIP.GETIP());

        ConvertServerDate ServerDate      = new ConvertServerDate();
        string            ConvertFromDate = ServerDate.getDate_MDY(txtDODate.Text);
        string            ConvertToDate   = ServerDate.getDate_MDY(txtDOLastDate.Text);

        if (txtYear.Text != "")
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        con.Open();

                        string instr = "";

                        instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";

                        instr += "Insert Into PaddyMilling_Agreement_Log(District,Dist_Manager_Name,Mill_Addr_District,Mill_Name,Mill_Operator_Name,Mill_Operator,CropYear,From_Date,To_Date,Common_Dhan,GradeA_Dhan,Total_Dhan,Agreement_ID,IP_Address,Current_DateTime,User_Agent,State,State_Code,DepositMoney,DhanLot,DhanAmount,DhanAmountType,DhanAmountDetails,Agrmt_Date,R_Arva,R_Ushna,Rem_Common_Dhan,Rem_GradeA_Dhan,Rem_Total_Dhan,Rem_DhanLot,Milling_Type,Return_CommonDhan,Return_GradeADhan,Return_TotalDhan,Return_CommonRice,Return_GradeARice,Return_TotalRice,Rejected,IsAccepted,MobileNO,AcceptedIP,AcceptedDate,DeletedDate,DeletedIP,Operation) select District,Dist_Manager_Name,Mill_Addr_District,Mill_Name,Mill_Operator_Name,Mill_Operator,CropYear,From_Date,To_Date,Common_Dhan,GradeA_Dhan,Total_Dhan,Agreement_ID,IP_Address,Current_DateTime,User_Agent,State,State_Code,DepositMoney,DhanLot,DhanAmount,DhanAmountType,DhanAmountDetails,Agrmt_Date,R_Arva,R_Ushna,Rem_Common_Dhan,Rem_GradeA_Dhan,Rem_Total_Dhan,Rem_DhanLot,Milling_Type,Return_CommonDhan,Return_GradeADhan,Return_TotalDhan,Return_CommonRice,Return_GradeARice,Return_TotalRice,Rejected,IsAccepted,MobileNO,AcceptedIP,AcceptedDate,GETDATE(),'" + GetIp + "','U' From PaddyMilling_Agreement_2017 where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' ; ";
                        instr += "Insert Into PaddyMilling_DO_Log_2017(DO_Number,Mill_Code,Agreement_ID,District,CropYear,From_Date,To_Date,Milling_Type,Alloted_CommonDhan,Alloted_GradeADhan,R_Arva,R_Ushna,Issue_Centre,IP_Address,Current_DateTime,User_Agent,Check_DO,DispatchDhan_IC,Return_CommonRice,Return_GradeARice,Return_TotalRice,LotOnlyNumber,Rejected,DhanLot,Branch_Code,Godown_Code,LotNumber,Rem_Alloted_CommonDhan,Rem_Alloted_GradeADhan,Rem_DhanLot,LotNo,DeletedDate,DeletedIP,Operation) select DO_Number,Mill_Code,Agreement_ID,District,CropYear,From_Date,To_Date,Milling_Type,Alloted_CommonDhan,Alloted_GradeADhan,R_Arva,R_Ushna,Issue_Centre,IP_Address,Current_DateTime,User_Agent,Check_DO,DispatchDhan_IC,Return_CommonRice,Return_GradeARice,Return_TotalRice,LotOnlyNumber,Rejected,DhanLot,Branch_Code,Godown_Code,LotNumber,Rem_Alloted_CommonDhan,Rem_Alloted_GradeADhan,Rem_DhanLot,LotNo,GETDATE(),'" + GetIp + "','U' From PaddyMilling_DO_2017 where Check_DO='" + ddlDONo.SelectedItem.ToString() + "' ; ";

                        instr += "Update PaddyMilling_Agreement_2017 Set Rem_Common_Dhan=(Rem_Common_Dhan+'" + DORemQty + "') , Rem_Total_Dhan=(Rem_Total_Dhan+'" + DORemQty + "') , Rem_DhanLot=(Rem_DhanLot+1) where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' ;";

                        instr += "Delete PaddyMilling_DO_2017 where Check_DO='" + ddlDONo.SelectedItem.ToString() + "' ; ";

                        for (int i = 0; i < GridView2.Rows.Count; i++)
                        {
                            decimal UPDORemQty = 0;
                            string  IC = "", Godown = "";
                            UPDORemQty = decimal.Parse(GridView2.Rows[i].Cells[5].Text);
                            IC         = GridView2.Rows[i].Cells[6].Text;
                            Godown     = GridView2.Rows[i].Cells[7].Text;

                            instr += "Update PaddyMapping_Godown set Rem_CommonPaddy=(Rem_CommonPaddy+" + UPDORemQty + ") where CropYear='" + txtYear.Text + "' and Mill_ID='" + ddlMillName.SelectedValue.ToString() + "' and Agreement_ID='" + ddlAgtmtNumber.SelectedValue.ToString() + "' and Godown_id='" + Godown + "'; ";
                        }

                        instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                        cmd = new SqlCommand(instr, con);
                        int count = cmd.ExecuteNonQuery();

                        if (count > 0)
                        {
                            btnDelete.Enabled = false;

                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Deleted Successfully'); </script> ");
                            txtYear.Text       = "";
                            ddlFrmDist.Enabled = ddlMillName.Enabled = ddlAgtmtNumber.Enabled = ddlDONo.Enabled = false;
                            Session["update"]  = Server.UrlEncode(System.DateTime.Now.ToString());
                        }
                        else
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Deletion Not Allow'); </script> ");
                        }
                    }
                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
예제 #24
0
    protected void btnRecptSubmit_Click1(object sender, EventArgs e)
    {
        if (ddlCMRDist.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select CMR District'); </script> ");
            return;
        }
        else if (ddlAgtmtNumber.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Agreement Number'); </script> ");
            return;
        }
        else if (hdfMappingData.Value == "1")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('इस Agreement No. के विरुद्ध " + ddlCMRDist.SelectedItem.ToString() + " जिले के लिए आपने Already Mapping कर चुकी हैं|'); </script> ");
            return;
        }
        else
        {
            if (txtYear.Text != "")
            {
                if (Session["update"].ToString() == ViewState["update"].ToString())
                {
                    using (con = new SqlConnection(strcon))
                    {
                        try
                        {
                            con.Open();

                            ClientIP objClientIP = new ClientIP();
                            string   GetIp       = (objClientIP.GETIP());

                            string instr = "";

                            string  ChechMax     = "";
                            decimal MaxMappingNo = 0;
                            ChechMax = "Select Max(Mapping_No) As MaxMap From CMRDO_OtherDistMap Where District='" + ddlFrmDist.SelectedValue.ToString() + "' and CMRDistrict='" + ddlCMRDist.SelectedValue.ToString() + "' ";
                            da       = new SqlDataAdapter(ChechMax, con);
                            ds       = new DataSet();
                            da.Fill(ds);

                            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                string Data = "";
                                Data = ds.Tables[0].Rows[0]["MaxMap"].ToString();
                                if (Data == "")
                                {
                                    MaxMappingNo = decimal.Parse(ddlFrmDist.SelectedValue.ToString() + ddlCMRDist.SelectedValue.ToString() + "100000");
                                }
                                else
                                {
                                    string wid        = Data.Substring(Data.Length - 6);
                                    Int64  wid_ID_new = Convert.ToInt64(wid);
                                    wid_ID_new = wid_ID_new + 1;
                                    string combine = wid_ID_new.ToString();
                                    MaxMappingNo = decimal.Parse(ddlFrmDist.SelectedValue.ToString() + ddlCMRDist.SelectedValue.ToString() + combine);
                                }
                            }

                            if (MaxMappingNo != 0)
                            {
                                instr  = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION ";
                                instr += "Insert Into CMRDO_OtherDistMap(District,CMRDistrict,CropYear,Mill_ID,Agreement_ID,Mapping_No,CreatedDate,IP_Address) Values('" + ddlFrmDist.SelectedValue.ToString() + "','" + ddlCMRDist.SelectedValue.ToString() + "','" + txtYear.Text + "','" + ddlMillName.SelectedValue.ToString() + "','" + ddlAgtmtNumber.SelectedItem.ToString() + "','" + MaxMappingNo + "',GETDATE(),'" + GetIp + "');";
                                instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                                cmd = new SqlCommand(instr, con);
                                int count = cmd.ExecuteNonQuery();

                                if (count > 0)
                                {
                                    btnRecptSubmit.Enabled = false;
                                    ddlFrmDist.Enabled     = ddlMillName.Enabled = ddlAgtmtNumber.Enabled = ddlCMRDist.Enabled = false;
                                    txtYear.Text           = "";
                                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully'); </script> ");
                                    Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                                }
                                else
                                {
                                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                                }
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Changes Not Allow'); </script> ");
                            }
                        }
                        catch (Exception ex)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                        }

                        finally
                        {
                            if (con.State != ConnectionState.Closed)
                            {
                                con.Close();
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
            }
        }
    }
예제 #25
0
    protected void btnRecptSubmit_Click(object sender, EventArgs e)
    {
        if (ddlFrmDist.SelectedIndex > 0)
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        con.Open();

                        string frmdis = ddlFrmDist.SelectedValue;

                        Int16 commodity = Convert.ToInt16(ddlCommodity.SelectedValue);

                        string mode = ddlComdtyMode.SelectedValue;

                        string year_do = "";

                        if (ddlCropYear.SelectedIndex == 0)
                        {
                            year_do = System.DateTime.Now.Date.ToString("yy");
                            year_do = ((int.Parse(year_do)) - 1).ToString();
                        }
                        else if (ddlCropYear.SelectedIndex == 2)
                        {
                            year_do = System.DateTime.Now.Date.ToString("yy");
                            year_do = ((int.Parse(year_do)) + 1).ToString();
                        }
                        else
                        {
                            year_do = System.DateTime.Now.Date.ToString("yy");
                        }

                        string month       = System.DateTime.Now.Date.ToString("MM");
                        string CurrentYear = System.DateTime.Now.Date.ToString("yy");

                        string selectmax = "select max(cast(MoveOrdernum as bigint)) as MoveOrdernum from StateMovementOrder where FrmDist='" + frmdis + "' and CropYear='" + ddlCropYear.SelectedValue.ToString() + "'";
                        cmd = new SqlCommand(selectmax, con);
                        da  = new SqlDataAdapter(cmd);
                        ds  = new DataSet();
                        da.Fill(ds);

                        string whr_ID = ds.Tables[0].Rows[0]["MoveOrdernum"].ToString();

                        if (whr_ID == "")
                        {
                            whr_ID = CurrentYear + year_do + month + frmdis + "100";
                        }
                        else
                        {
                            string wid = whr_ID.Substring(whr_ID.Length - 4);

                            Int64 wid_ID_new = Convert.ToInt64(wid);

                            wid_ID_new = wid_ID_new + 1;

                            string combine = wid_ID_new.ToString();

                            whr_ID = CurrentYear + year_do + month + frmdis + combine;
                        }

                        ClientIP objClientIP = new ClientIP();
                        string   GetIp       = (objClientIP.GETIP());

                        string browser   = Request.Browser.Browser.ToString();
                        string version   = Request.Browser.Version.ToString();
                        string useragent = browser + version;

                        ConvertServerDate ServerDate     = new ConvertServerDate();
                        string            ConvertEndDate = ServerDate.getDate_MDY(txtDate.Text);

                        DateTime EndDate    = DateTime.Parse(ConvertEndDate);
                        string   smsEndDate = EndDate.ToString("dd-MMM-yyyy");

                        string instr = "", smsToDist = "", modeofDist = "";

                        if (mode == "13")
                        {
                            if (rdbSelf.Checked)
                            {
                                modeofDist = "Self";
                            }
                            else if (rdbOther.Checked)
                            {
                                modeofDist = "Other";
                            }
                            else
                            {
                                modeofDist = "Both";
                            }
                        }

                        DataTable dt = adddetails();
                        if (dt != null)
                        {
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                ConvertMtToQtls = 0;
                                string SMO = whr_ID + (i + 1);

                                if (commodity == 25)
                                {
                                    ConvertMtToQtls = ((double.Parse(dt.Rows[i]["quantity"].ToString())));
                                }
                                else
                                {
                                    ConvertMtToQtls = ((double.Parse(dt.Rows[i]["quantity"].ToString())) * 10);
                                }

                                if (mode == "12") //Transfer By Road
                                {
                                    instr += "Insert into StateMovementOrder (MoveOrdernum ,FrmDist,Commodity, CropYear,ReachDate,ModeofDispatch,IsIssued,CreatedDate,IP,SMS_todist,SMS_frmDist,ToDist,Quantity,SMO,RecAgainstHO,DispatchAgainstMO,ReceivedAgainstMO,RemQty,IsAccepted ) Values ('" + whr_ID + "','" + frmdis + "','" + commodity + "','" + ddlCropYear.SelectedValue.ToString() + "','" + ConvertEndDate + "','" + mode + "','N',GETDATE(),'" + GetIp + "','N','N','" + dt.Rows[i]["todistval"] + "','" + ConvertMtToQtls + "','" + SMO + "','N','N','N','" + ConvertMtToQtls + "','F');";
                                }
                                else
                                {
                                    if (commodity == 25)
                                    {
                                        //string strGunnyType = "";

                                        //if (rdbJUTE.Checked)
                                        //{
                                        //    strGunnyType = "JUTE";
                                        //}
                                        //else
                                        //{
                                        //    strGunnyType = "PP";
                                        //}
                                        instr += "Insert into StateMovementOrder (MoveOrdernum ,FrmDist,Commodity, CropYear,ReachDate,ModeofDispatch,IsIssued,CreatedDate,IP,SMS_todist,SMS_frmDist,ToDist,Quantity,SMO,RecAgainstHO,DispatchAgainstMO,ReceivedAgainstMO,RemQty,ModeofDist,IsAccepted,GunnyType) Values ('" + whr_ID + "','" + frmdis + "','" + commodity + "','" + ddlCropYear.SelectedValue.ToString() + "','" + ConvertEndDate + "','" + mode + "','N',GETDATE(),'" + GetIp + "','N','N','" + dt.Rows[i]["todistval"] + "','" + ConvertMtToQtls + "','" + SMO + "','Y','N','N','" + ConvertMtToQtls + "','" + modeofDist + "','F','" + ddlbagstype.SelectedValue.ToString() + "');";
                                    }
                                    else
                                    {
                                        instr += "Insert into StateMovementOrder (MoveOrdernum ,FrmDist,Commodity, CropYear,ReachDate,ModeofDispatch,IsIssued,CreatedDate,IP,SMS_todist,SMS_frmDist,ToDist,Quantity,SMO,RecAgainstHO,DispatchAgainstMO,ReceivedAgainstMO,RemQty,ModeofDist,IsAccepted) Values ('" + whr_ID + "','" + frmdis + "','" + commodity + "','" + ddlCropYear.SelectedValue.ToString() + "','" + ConvertEndDate + "','" + mode + "','N',GETDATE(),'" + GetIp + "','N','N','" + dt.Rows[i]["todistval"] + "','" + ConvertMtToQtls + "','" + SMO + "','Y','N','N','" + ConvertMtToQtls + "','" + modeofDist + "','F');";
                                    }
                                }

                                //Code For SMS
                                //smsToDist += ((smsToDist == "") ? "" : " , ") + "'" + dt.Rows[i]["todisttext"] + "' = '" + dt.Rows[i]["quantity"] + "'";
                                //smsToDistCode += ((smsToDistCode == "") ? "" : ",") + "'" + dt.Rows[i]["todistval"] + "'";
                            }
                        }

                        cmd = new SqlCommand(instr, con);
                        int count = cmd.ExecuteNonQuery();

                        if (count > 0)
                        {
                            btnRecptSubmit.Enabled  = btnAdd.Enabled = false;
                            btnPrint.Enabled        = true;
                            Session["fdjfhxncdfh"]  = null;
                            Session["MovmtOrderNo"] = whr_ID;

                            Label2.Text    = "Your Movement Order Number Is : " + whr_ID;
                            Label2.Visible = true;

                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully & Your Movement Order Number Is : " + whr_ID + "'); </script> ");

                            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());

                            if (mode == "13")
                            {
                                if (modeofDist != "Self")
                                {
                                    btnPrint.Enabled     = false;
                                    LinkbtnSubMO.Visible = true;
                                }
                            }

                            //Code For SMS
                            //cmd1 = new SqlCommand("Select GETDATE()", con);
                            //DateTime CurrentDate = DateTime.Parse((cmd1.ExecuteScalar()).ToString());
                            //string smsCurrentDate = CurrentDate.ToString("dd-MMM-yyyy");

                            //String strSMS = "Movement Order Issued On '" + smsCurrentDate + "' with MO Number='" + whr_ID + "' For '" + ddlCommodity.SelectedItem.ToString() + "', '" + ddlComdtyMode.SelectedItem.ToString() + "' From '" + ddlFrmDist.SelectedItem.ToString() + "' To (" + smsToDist + ")MT With End Date'" + smsEndDate + "'";
                            //SMS Message = new SMS();

                            //smsToDistCode += ",'" + frmdis + "'";
                            //string FindDistContactNo = "select DM_Mobile,RM_Mobile From officers_list where District_code in (" + smsToDistCode + ")";
                            //da = new SqlDataAdapter(FindDistContactNo, con);
                            //ds = new DataSet();
                            //da.Fill(ds);
                            //string CheckDuplicate = "";

                            //if (ds != null)
                            //{
                            //    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            //    {
                            //        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            //        {
                            //            string checkLength = ds.Tables[0].Rows[i]["DM_Mobile"].ToString();
                            //            string checkLengthRM = ds.Tables[0].Rows[i]["RM_Mobile"].ToString();
                            //            if (checkLength.Length == 10)
                            //            {
                            //                Message.SendSMS(checkLength, strSMS);
                            //            }
                            //            if (checkLengthRM.Length == 10)
                            //            {
                            //                if (checkLength != checkLengthRM)
                            //                {
                            //                    if (checkLengthRM != CheckDuplicate)
                            //                    {
                            //                        Message.SendSMS(checkLength, strSMS);
                            //                        CheckDuplicate = checkLengthRM;
                            //                    }
                            //                }
                            //            }
                            //        }
                            //    }
                            //}
                        }
                        else
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                        }
                    }

                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                            ddlFrmDist.SelectedIndex = 0;
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
예제 #26
0
    protected void btnRecptSubmit_Click1(object sender, EventArgs e)
    {
        decimal CheckRecdQty = 0;
        int     CheckBag     = 0;

        if (txtRecdQty.Text != "" && txtBags.Text != "")
        {
            CheckRecdQty = decimal.Parse(txtRecdQty.Text);
            CheckBag     = int.Parse(txtBags.Text);
        }

        if (ddlLotNO.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('मिलर को प्रदायित धान का लॉट नंबर चुने|'); </script> ");
            return;
        }
        else if (txtFromDate.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Acceptance Note Date'); </script> ");
            return;
        }
        else if (txtMemoDate.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Weight Check Memo Date'); </script> ");
            return;
        }
        else if (hdfAllQty.Value == "1")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('मिलर ने इस लॉट नंबर के विरुद्ध पूरा धान नहीँ उठाया है, इसलिए इस लॉट नंबर के विरुद्ध CMR जमा नहीं किया जा सकता|'); </script> ");
            return;
        }
        else if (CheckRecdQty < 269 && hdfAdjustCMRDO.Value == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Receiving Qty की मात्रा अनुमानित मात्रा से कम होने के कारण आप CMR Receive नहीं कर सकते|'); </script> ");
            return;
        }
        else if (CheckBag < 535 && hdfAdjustCMRDO.Value == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Receiving Bags की मात्रा अनुमानित मात्रा से कम होने के कारण आप CMR Receive नहीं कर सकते|'); </script> ");
            return;
        }
        else if (CheckRecdQty >= 273)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Recd. CMR Qty की मात्रा अनुमानित मात्रा से ज्यादा होने के कारण आप CMR Receive नहीं कर सकते|'); </script> ");
            return;
        }
        else if (ddlCMRDist.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Recd. CMR District'); </script> ");
            return;
        }
        else if (txtAcptNo.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Enter Acceptance Note No.'); </script> ");
            return;
        }
        else if (txtWeightMemo.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Enter Weight Check Memo No.'); </script> ");
            return;
        }
        else
        {
            string districtid = Session["dist_id"].ToString();

            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        ClientIP objClientIP = new ClientIP();
                        string   GetIp       = objClientIP.GETIP();

                        ConvertServerDate ServerDate      = new ConvertServerDate();
                        string            ConvertFromDate = ServerDate.getDate_MDY(txtFromDate.Text);
                        string            ConvertMemoDate = ServerDate.getDate_MDY(txtMemoDate.Text);

                        string SubDCDate = "", DCDate = "", instr = "", CMRDO_ID = "", BagType = "";

                        if (rdbNewJute.Checked)
                        {
                            BagType = "9";
                        }
                        else if (rdbOldJute.Checked)
                        {
                            BagType = "10";
                        }
                        else if (rdbOnceJute.Checked)
                        {
                            BagType = "11";
                        }
                        else if (rdbNewPP.Checked)
                        {
                            BagType = "4";
                        }
                        else if (rdbOncePP.Checked)
                        {
                            BagType = "2";
                        }
                        else
                        {
                            BagType = "12";
                        }

                        con.Open();

                        string AcptNo = "Select * from Receipt_CMR_FCI where CMR_RecdState='" + hdfFCIState.Value + "' and  CMR_RecdDist='" + ddlCMRDist.SelectedValue.ToString() + "' and Acceptance_No='" + txtAcptNo.Text + "'";
                        da1 = new SqlDataAdapter(AcptNo, con);
                        ds1 = new DataSet();
                        da1.Fill(ds1);
                        if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Acceptance Note No. Already Exist On Your District...'); </script> ");
                            return;
                        }
                        else
                        {
                            string selectmax = "select CONVERT(varchar(10),YEAR(GETDATE()))+CONVERT(varchar(10),MONTH(GETDATE()))+CONVERT(varchar(10),DAY(GETDATE()))+CONVERT(varchar(10),DATENAME(HH,GETDATE()))+CONVERT(varchar(10),DATENAME(MI,GETDATE()))+CONVERT(varchar(10),DATENAME(SS,GETDATE()))+CONVERT(varchar(10),DATENAME(MS,GETDATE())) As DCDate";
                            da = new SqlDataAdapter(selectmax, con);
                            ds = new DataSet();
                            da.Fill(ds);

                            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                DCDate    = ds.Tables[0].Rows[0]["DCDate"].ToString();
                                SubDCDate = DCDate.Substring(2);
                            }

                            if (SubDCDate != "")
                            {
                                decimal RecdCMR = decimal.Parse(txtRecdQty.Text);

                                CMRDO_ID = "CMRAF" + SubDCDate;
                                instr    = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                           "Update PaddyMilling_DO_2017 Set DispatchDhan_IC='Y' where Mill_Code='" + ddlMillName.SelectedValue.ToString() + "' and Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' and District='" + hdfAgrmtDist.Value + "' and CropYear='" + txtYear.Text + "' and DhanLot='" + ddlLotNO.SelectedValue.ToString() + "' and Check_DO='" + lblDONO.Text + "'; ";

                                instr += "Update PaddyMilling_Agreement_2017 set Return_CommonRice= (ISNULL(Return_CommonRice,0)+" + RecdCMR + "), Return_TotalRice= (ISNULL(Return_TotalRice,0)+" + RecdCMR + ") where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' ; ";

                                instr += "Insert Into Receipt_CMR_FCI(Paddy_AgrmtDist,CMR_RecdDist,CMR_RecdState,Receipt_ID,Receipt_Date,CommonRice,GradeARice,Bags,Truck_No,Truck_No1,CropYear,Mill_ID,Milling_Type,Agreement_ID,Lot_No,DO_No,CreatedDate,IP_Address,IsAccepted,Acceptance_No,WeightCheck_No,WeightCheck_Date,BagType,WHR_No) values('" + hdfAgrmtDist.Value + "','" + ddlCMRDist.SelectedValue.ToString() + "','" + hdfFCIState.Value + "','" + CMRDO_ID + "','" + ConvertFromDate + "','" + RecdCMR + "','0','" + CheckBag + "','" + txtTruckNo.Text + "','" + txtTruckNo0.Text + "','" + txtYear.Text + "','" + ddlMillName.SelectedValue.ToString() + "',N'" + lblMillingType.Text + "','" + ddlAgtmtNumber.SelectedItem.ToString() + "','" + ddlLotNO.SelectedValue.ToString() + "','" + lblDONO.Text + "',GETDATE(),'" + GetIp + "','Y','" + txtAcptNo.Text + "','" + txtWeightMemo.Text + "','" + ConvertMemoDate + "','" + BagType + "','" + txtWhrNo.Text.Trim() + "'); ";

                                instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                            }

                            cmd = new SqlCommand(instr, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                btnPrint.Enabled       = true;
                                btnRecptSubmit.Enabled = false;

                                Label2.Visible = true;
                                Label2.Text    = "Your CMR Receipt Number Is : " + CMRDO_ID;

                                Session["CMRDO_ID"] = CMRDO_ID.ToString();

                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully and Your CMR Receipt Number Is " + CMRDO_ID.ToString() + "'); </script> ");
                                txtYear.Text        = txtDistManager.Text = "";
                                ddlMillName.Enabled = ddlAgtmtNumber.Enabled = ddlLotNO.Enabled = ddlCMRDist.Enabled = false;
                                txtBags.Enabled     = txtRecdQty.Enabled = txtTruckNo.Enabled = txtTruckNo0.Enabled = txtAcptNo.Enabled = txtWeightMemo.Enabled = txtWhrNo.Enabled = false;

                                Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        btnRecptSubmit.Enabled = false;
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
예제 #27
0
    protected void btnRecptSubmit_Click(object sender, EventArgs e)
    {
        if (txtCommodity.Text != "" && txtCropYear.Text != "")
        {
            double SendQty = 0, RecQty = 0;
            int    SendBags = 0, RecBags = 0;

            SendQty = double.Parse(txtSendingQty.Text);
            RecQty  = double.Parse(txtRecdQty.Text);

            SendBags = int.Parse(txtSendingBags.Text);
            RecBags  = int.Parse(txtRecdBags.Text);

            if (SendQty < RecQty)
            {
                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Receiving Qty की मात्रा, Sending Qty की मात्रा से ज्यादा है,कृपया Receiving Qty की मात्रा कम करें|'); </script> ");
                return;
            }
            else if (SendBags < RecBags)
            {
                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Receiving Bags की मात्रा, Sending Bags की मात्रा से ज्यादा है,कृपया Receiving Bags की मात्रा कम करें|'); </script> ");
                return;
            }
            else
            {
                if (Session["update"].ToString() == ViewState["update"].ToString())
                {
                    using (con = new SqlConnection(strcon))
                    {
                        try
                        {
                            con.Open();

                            string Update = "";
                            districtid = Session["dist_id"].ToString();

                            ClientIP objClientIP = new ClientIP();
                            string   GetIp       = (objClientIP.GETIP());

                            ConvertServerDate ServerDate = new ConvertServerDate();
                            string            RecDate    = ServerDate.getDate_MDY(txtRecdDate.Text);
                            string            SendDate   = ServerDate.getDate_MDY(txtSendingDate.Text);

                            Update = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                     "Update QtyReceived_RackDispatchPoint set IsReceived='Y' where Racknumber='" + ddlRackNo.SelectedItem.ToString() + "' and sendingDist='" + hdfSendDist.Value + "' and TruckChallan='" + ddlChallanNo.SelectedItem.ToString() + "' and RecDist='" + districtid + "';";

                            Update += "Insert into Rack_ReceivedPoint(Rack_No,DC_MO,MoveOrdernum,SMO,FrmDist,RecDist,Commodity,CropYear,Send_Qty,Recd_Qty,Rem_Qty,Send_Bags,Recd_Bags,Rem_Bags,Send_Date,Recd_Date,CreatedDate,IP) values('" + ddlRackNo.SelectedItem.ToString() + "','" + ddlChallanNo.SelectedItem.ToString() + "','" + txtMoNO.Text + "','" + hdfSubMO.Value + "','" + hdfSendDist.Value + "','" + districtid + "','" + hdfComdty.Value + "','" + txtCropYear.Text + "','" + SendQty + "','" + RecQty + "','" + RecQty + "','" + SendBags + "','" + RecBags + "','" + RecBags + "','" + SendDate + "','" + RecDate + "',GETDATE(),'" + GetIp + "');";

                            Update += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                            cmd = new SqlCommand(Update, con);
                            int count = cmd.ExecuteNonQuery();

                            if (count > 0)
                            {
                                Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Data Saved Sucessfully ....'); </script> ");
                                btnRecptSubmit.Enabled = false;
                                txtCommodity.Text      = txtCropYear.Text = "";
                                Session["update"]      = Server.UrlEncode(System.DateTime.Now.ToString());
                            }
                            else
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                            }
                        }
                        catch (Exception ex)
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                        }

                        finally
                        {
                            if (con.State != ConnectionState.Closed)
                            {
                                con.Close();
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
            }
        }
        else
        {
            Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please Alloted All Quantity'); </script> ");
        }
    }
예제 #28
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (ddlDC.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('कृपया डिलेवरी चालान क्रमांक चुने |'); </script> ");
            return;
        }
        else if (hdfGatePass.Value == "1")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('आपने जो चालान नंबर Select किया है, उसका GatePass जारी किया जा चूका है, इसलिए आप इसे डिलीट नहीं कर सकते|'); </script> ");
            return;
        }
        else if (txtIssuedQty.Text == "" || txtTCNo.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Issued Qty Or Truck Number Is Not Allow Blank'); </script> ");
            return;
        }
        else
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        string DCddl = "", DCsubstring = "", instr = "", TOQty = "", strCreatedDate = "", strSubCreatedDate = "";
                        DCddl       = ddlDC.SelectedItem.ToString();
                        DCsubstring = DCddl.Substring(0, 4);

                        ClientIP objClientIP = new ClientIP();
                        string   GetIp       = (objClientIP.GETIP());

                        if (hdfChangeGodown.Value == "00")
                        {
                            ActualFrmGodown = hdfFrmGodown.Value;
                        }
                        else
                        {
                            ActualFrmGodown = hdfChangeGodown.Value;
                        }

                        strCreatedDate    = ddlDC.SelectedValue.ToString();
                        strSubCreatedDate = strCreatedDate.Substring(0, 16);

                        con.Open();

                        if (DCsubstring == "MORD") //By Road
                        {
                            if (hdfIsRecd.Value == "Y")
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('प्राप्तकर्ता जिले द्वारा कमोडिटी प्राप्त कर ली गयी है, इसलिए आप इस डिलेवरी चालान को डिलीट नहीं कर सकते |'); </script> ");
                                return;
                            }
                            else
                            {
                                instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                        "Insert Into TO_AgainstHO_MO_Trans_Log(MoveOrdernum,SMO,TO_No,STO_No,Transporter_ID,FrmDist,ToDist,Commodity,Quantity,CropYear,ReachDate,MODate,TOEndDate,ModeofDispatch,IsIssued,CreatedDate,IP,Issue_Center,Branch,Godown,RequiredQuantity,RemQty,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,Month,Year,IsSend,State_Id,OperatorID,Scheme_Id,DispatchID,STrans_ID,To_MultiDist,SubSMO,ModeofDist,DeletedDate,DeletedIP,Operation) select MoveOrdernum,SMO,TO_No,STO_No,Transporter_ID,FrmDist,ToDist,Commodity,Quantity,CropYear,ReachDate,MODate,TOEndDate,ModeofDispatch,IsIssued,CreatedDate,IP,Issue_Center,Branch,Godown,RequiredQuantity,RemQty,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,Month,Year,IsSend,State_Id,OperatorID,Scheme_Id,DispatchID,STrans_ID,To_MultiDist,SubSMO,ModeofDist,GETDATE(),'" + GetIp + "','U' From TO_AgainstHO_MO where STO_No='" + hdfSTO_No.Value + "' and MoveOrdernum='" + txtMONo.Text + "' and ModeofDispatch='12'; ";

                                instr += "Update TO_AgainstHO_MO Set RemQty=(RemQty+" + txtIssuedQty.Text + ") where STO_No='" + hdfSTO_No.Value + "' and MoveOrdernum='" + txtMONo.Text + "' and ModeofDispatch='12'; ";

                                instr += "Update RecAgainst_StateMovementOrder set IssuedQty=(IssuedQty+ " + txtIssuedQty.Text + ") where MoveOrdernum='" + txtMONo.Text + "' and SMO='" + hdfSMO.Value + "' and ModeofDispatch='12' and Godown='" + hdfToGodown.Value + "'; ";

                                instr += "Insert Into DeliveryChallan_MO_Trans_Logs(MoveOrdernum,SMO,TO_No,STO_No,DC_No,Transporter_ID,FrmDist,ToDist,Commodity,CropYear,TOEndDate,ModeofDispatch,IsReceived,DC_MO,CreatedDate,IP,OperatorID,Issue_Center,Default_Branch,Default_Godown,Change_Branch,Change_Godown,Issued_Qty,Issued_Date,Issued_Bags,Bags_Type,Truck_No,Stock_Issued_From,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,STrans_ID,Recd_Qty,Recd_Bags,Recd_Date,RecIC,RecBranch,RecGodown,RSDRecd_Qty,RSDRecd_Bags,RSDRecd_Date,RSDCreatedDate,RRDRecd_Qty,RRDRecd_Bags,RRDRecd_Date,RRDCreated,Distance,Consinment_No,Book_No,Page_No,SubSMO,RMO,DeletedDate,DeletedIP,Operation) select MoveOrdernum,SMO,TO_No,STO_No,DC_No,Transporter_ID,FrmDist,ToDist,Commodity,CropYear,TOEndDate,ModeofDispatch,IsReceived,DC_MO,CreatedDate,IP,OperatorID,Issue_Center,Default_Branch,Default_Godown,Change_Branch,Change_Godown,Issued_Qty,Issued_Date,Issued_Bags,Bags_Type,Truck_No,Stock_Issued_From,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,STrans_ID,Recd_Qty,Recd_Bags,Recd_Date,RecIC,RecBranch,RecGodown,RSDRecd_Qty,RSDRecd_Bags,RSDRecd_Date,RSDCreatedDate,RRDRecd_Qty,RRDRecd_Bags,RRDRecd_Date,RRDCreated,Distance,Consinment_No,Book_No,Page_No,SubSMO,RMO,GETDATE(),'" + GetIp + "','D' From DeliveryChallan_MO where STO_No='" + hdfSTO_No.Value + "' and DC_MO='" + ddlDC.SelectedItem.ToString() + "' and CreatedDate='" + ddlDC.SelectedValue.ToString() + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and ModeofDispatch='12' and Issue_Center='" + hdfFrmIC.Value + "' and Issued_Qty='" + txtIssuedQty.Text + "' and Truck_No='" + txtTCNo.Text + "' and RecIC='" + hdfToIC.Value + "' and IsReceived='N'; ";

                                //instr += "Delete From DeliveryChallan_MO where STO_No='" + hdfSTO_No.Value + "' and DC_MO='" + ddlDC.SelectedItem.ToString() + "' and CreatedDate='" + ddlDC.SelectedValue.ToString() + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and ModeofDispatch='12' and Issue_Center='" + hdfFrmIC.Value + "' and Issued_Qty='" + txtIssuedQty.Text + "' and Truck_No='" + txtTCNo.Text + "' and RecIC='" + hdfToIC.Value + "' and IsReceived='N'; ";

                                instr += "Delete From DeliveryChallan_MO where STO_No='" + hdfSTO_No.Value + "' and DC_MO='" + ddlDC.SelectedItem.ToString() + "' and CreatedDate='" + ddlDC.SelectedValue.ToString() + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and ModeofDispatch='12' and Issue_Center='" + hdfFrmIC.Value + "' and Truck_No='" + txtTCNo.Text + "' and IsReceived='N'; ";

                                instr += "insert into dbo.SCSC_Truck_challan_Trans_Log(State_Id,Dist_ID,Depot_Id,Challan_Date,Dispatch_Godown,Sendto_District,Commodity,Scheme,Bags,Qty_send,Challan_No,Truck_no,Transporter,Dispatch_Time,Remarks,Dispatch_id,Month,Year,Source,TO_Number,Sendto_IC,Operation,Updated_Date,IP_Address) Select State_Id,Dist_ID,Depot_Id,Challan_Date,Dispatch_Godown,Sendto_District,Commodity,Scheme,Bags,Qty_send,Challan_No,Truck_no,Transporter,Dispatch_Time,Remarks,Dispatch_id,Month,Year,Source,TO_Number,Sendto_IC,'D',GETDATE(),'" + GetIp + "' From SCSC_Truck_challan where Challan_No='" + ddlDC.SelectedItem.ToString() + "' and Dist_ID='" + hdfFrmDist.Value + "' and Sendto_District='" + hdfToDist.Value + "' and Truck_no='" + txtTCNo.Text + "' and Bags='" + hdfIssued_Bags.Value + "'; ";

                                instr += "Delete From SCSC_Truck_challan where Challan_No='" + ddlDC.SelectedItem.ToString() + "' and Dist_ID='" + hdfFrmDist.Value + "' and Sendto_District='" + hdfToDist.Value + "' and Truck_no='" + txtTCNo.Text + "' and Bags='" + hdfIssued_Bags.Value + "'; ";

                                instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                            }
                        }
                        else if (DCsubstring == "MORK") //By Rail Rack
                        {
                            if (hdfIsRecd.Value == "Y")
                            {
                                Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('रेल हेड पर कमोडिटी प्राप्त कर ली गयी है, इसलिए आप इस डिलेवरी चालान को डिलीट नहीं कर सकते |'); </script> ");
                                return;
                            }
                            else
                            {
                                instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                        "Insert Into TO_AgainstHO_MO_Trans_Log(MoveOrdernum,SMO,TO_No,STO_No,Transporter_ID,FrmDist,ToDist,Commodity,Quantity,CropYear,ReachDate,MODate,TOEndDate,ModeofDispatch,IsIssued,CreatedDate,IP,Issue_Center,Branch,Godown,RequiredQuantity,RemQty,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,Month,Year,IsSend,State_Id,OperatorID,Scheme_Id,DispatchID,STrans_ID,To_MultiDist,SubSMO,ModeofDist,DeletedDate,DeletedIP,Operation) select MoveOrdernum,SMO,TO_No,STO_No,Transporter_ID,FrmDist,ToDist,Commodity,Quantity,CropYear,ReachDate,MODate,TOEndDate,ModeofDispatch,IsIssued,CreatedDate,IP,Issue_Center,Branch,Godown,RequiredQuantity,RemQty,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,Month,Year,IsSend,State_Id,OperatorID,Scheme_Id,DispatchID,STrans_ID,To_MultiDist,SubSMO,ModeofDist,GETDATE(),'" + GetIp + "','U' From TO_AgainstHO_MO where STO_No='" + hdfSTO_No.Value + "' and MoveOrdernum='" + txtMONo.Text + "' and ModeofDispatch='13' ;";

                                instr += "Update TO_AgainstHO_MO Set RemQty=(RemQty+" + txtIssuedQty.Text + ") where STO_No='" + hdfSTO_No.Value + "' and MoveOrdernum='" + txtMONo.Text + "'and ModeofDispatch='13' ;";

                                instr += "Insert Into DeliveryChallan_MO_Trans_Logs(MoveOrdernum,SMO,TO_No,STO_No,DC_No,Transporter_ID,FrmDist,ToDist,Commodity,CropYear,TOEndDate,ModeofDispatch,IsReceived,DC_MO,CreatedDate,IP,OperatorID,Issue_Center,Default_Branch,Default_Godown,Change_Branch,Change_Godown,Issued_Qty,Issued_Date,Issued_Bags,Bags_Type,Truck_No,Stock_Issued_From,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,STrans_ID,Recd_Qty,Recd_Bags,Recd_Date,RecIC,RecBranch,RecGodown,RSDRecd_Qty,RSDRecd_Bags,RSDRecd_Date,RSDCreatedDate,RRDRecd_Qty,RRDRecd_Bags,RRDRecd_Date,RRDCreated,Distance,Consinment_No,Book_No,Page_No,SubSMO,RMO,DeletedDate,DeletedIP,Operation) select MoveOrdernum,SMO,TO_No,STO_No,DC_No,Transporter_ID,FrmDist,ToDist,Commodity,CropYear,TOEndDate,ModeofDispatch,IsReceived,DC_MO,CreatedDate,IP,OperatorID,Issue_Center,Default_Branch,Default_Godown,Change_Branch,Change_Godown,Issued_Qty,Issued_Date,Issued_Bags,Bags_Type,Truck_No,Stock_Issued_From,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,STrans_ID,Recd_Qty,Recd_Bags,Recd_Date,RecIC,RecBranch,RecGodown,RSDRecd_Qty,RSDRecd_Bags,RSDRecd_Date,RSDCreatedDate,RRDRecd_Qty,RRDRecd_Bags,RRDRecd_Date,RRDCreated,Distance,Consinment_No,Book_No,Page_No,SubSMO,RMO,GETDATE(),'" + GetIp + "','D' From DeliveryChallan_MO where STO_No='" + hdfSTO_No.Value + "' and DC_MO='" + ddlDC.SelectedItem.ToString() + "' and CreatedDate='" + ddlDC.SelectedValue.ToString() + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and ModeofDispatch='13' and Issue_Center='" + hdfFrmIC.Value + "' and Issued_Qty='" + txtIssuedQty.Text + "' and Truck_No='" + txtTCNo.Text + "' and FrmRailHaid='" + hdfFrmRailHead.Value + "' and ToRailHaid='" + hdfToRailHead.Value + "' and Rack_No='" + txtRackNo.Text + "' and IsReceived='N'; ";

                                instr += "Delete From DeliveryChallan_MO where STO_No='" + hdfSTO_No.Value + "' and DC_MO='" + ddlDC.SelectedItem.ToString() + "' and CreatedDate='" + ddlDC.SelectedValue.ToString() + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and ModeofDispatch='13' and Issue_Center='" + hdfFrmIC.Value + "' and Truck_No='" + txtTCNo.Text + "' and FrmRailHaid='" + hdfFrmRailHead.Value + "' and ToRailHaid='" + hdfToRailHead.Value + "' and IsReceived='N'; ";

                                instr += "Insert Into SCSC_RailHead_TC_Log Select * From SCSC_RailHead_TC where Depot_Id='" + hdfFrmIC.Value + "' and Challan_Date='" + hdfIssued_Date.Value + "' and Dispatch_Godown='" + ActualFrmGodown + "' and Commodity='" + hdfCommodityVal.Value + "' and Rack_NO='" + txtRackNo.Text + "' and Bags='" + hdfIssued_Bags.Value + "' and Challan_No='" + ddlDC.SelectedItem.ToString() + "' and Truck_no='" + txtTCNo.Text + "' and Dist_ID='" + hdfFrmDist.Value + "' and Sendto_District='" + hdfToDist.Value + "';";

                                instr += "Delete From SCSC_RailHead_TC where Depot_Id='" + hdfFrmIC.Value + "' and Challan_Date='" + hdfIssued_Date.Value + "' and Commodity='" + hdfCommodityVal.Value + "' and Rack_NO='" + txtRackNo.Text + "' and Bags='" + hdfIssued_Bags.Value + "' and Challan_No='" + ddlDC.SelectedItem.ToString() + "' and Truck_no='" + txtTCNo.Text + "' and Dist_ID='" + hdfFrmDist.Value + "' and Sendto_District='" + hdfToDist.Value + "';";

                                instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                            }
                        }
                        else
                        {
                            return;
                        }

                        cmd = new SqlCommand(instr, con);
                        int count = cmd.ExecuteNonQuery();

                        if (count > 0)
                        {
                            btnDelete.Enabled = false;

                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('डिलेवरी चालान सफलता पूर्वक डिलीट हो चूका है|'); </script> ");
                            txtIssuedQty.Text = "";

                            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                        }
                        else
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                        }
                    }
                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
예제 #29
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (ddlPageNo.SelectedIndex <= 0)
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('कृपया Page Number चुने |'); </script> ");
            return;
        }
        else if (txtIssuedQty.Text == "" || txtTCNo.Text == "")
        {
            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Issued Qty Or Truck Number Is Not Allow Blank'); </script> ");
            return;
        }
        else
        {
            if (Session["update"].ToString() == ViewState["update"].ToString())
            {
                using (con = new SqlConnection(strcon))
                {
                    try
                    {
                        string instr = "";

                        ClientIP objClientIP = new ClientIP();
                        string   GetIp       = (objClientIP.GETIP());

                        con.Open();

                        if (hdfIsRecd.Value == "Y")
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('प्राप्तकर्ता जिले द्वारा कमोडिटी प्राप्त कर ली गयी है, इसलिए आप इस डिलेवरी चालान को डिलीट नहीं कर सकते |'); </script> ");
                            return;
                        }
                        else
                        {
                            instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                                    "Update TruckChallan_Book set Rem_Page=Rem_Page+1 where Book_No='" + ddlBookNo.SelectedItem.ToString() + "' and District='" + hdfFrmDist.Value + "';";

                            instr += "Update RackReceived set Rem_Qty=(Rem_Qty+'" + txtIssuedQty.Text + "'),Rem_Bags=(Rem_Bags+'" + hdfIssued_Bags.Value + "') where Consinment_No='" + txtConsNo.Text + "';";

                            if (hdfRMO.Value != "0")
                            {
                                instr += "Update RecAgainst_StateMovementOrder set IssuedQty=(IssuedQty+ " + txtIssuedQty.Text + ") where RMO='" + hdfRMO.Value + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and Godown='" + hdfToGodown.Value + "' and ModeofDispatch='13' ; ";
                            }

                            instr += "Insert Into TO_AgainstHO_MO_Trans_Log(MoveOrdernum,SMO,TO_No,STO_No,Transporter_ID,FrmDist,ToDist,Commodity,Quantity,CropYear,ReachDate,MODate,TOEndDate,ModeofDispatch,IsIssued,CreatedDate,IP,Issue_Center,Branch,Godown,RequiredQuantity,RemQty,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,Month,Year,IsSend,State_Id,OperatorID,Scheme_Id,DispatchID,STrans_ID,To_MultiDist,SubSMO,ModeofDist,DeletedDate,DeletedIP,Operation) select MoveOrdernum,SMO,TO_No,STO_No,Transporter_ID,FrmDist,ToDist,Commodity,Quantity,CropYear,ReachDate,MODate,TOEndDate,ModeofDispatch,IsIssued,CreatedDate,IP,Issue_Center,Branch,Godown,RequiredQuantity,RemQty,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,Month,Year,IsSend,State_Id,OperatorID,Scheme_Id,DispatchID,STrans_ID,To_MultiDist,SubSMO,ModeofDist,GETDATE(),'" + GetIp + "','U' From TO_AgainstHO_MO where STO_No='" + hdfSTO_No.Value + "' and MoveOrdernum='" + txtMONo.Text + "' and ModeofDispatch='13'; ";

                            instr += "Update TO_AgainstHO_MO Set RemQty=(RemQty+" + txtIssuedQty.Text + ") where STO_No='" + hdfSTO_No.Value + "' and MoveOrdernum='" + txtMONo.Text + "' and ModeofDispatch='13'; ";

                            instr += "Insert Into DeliveryChallan_MO_Trans_Logs (MoveOrdernum,SMO,TO_No,STO_No,DC_No,Transporter_ID,FrmDist,ToDist,Commodity,CropYear,TOEndDate,ModeofDispatch,IsReceived,DC_MO,CreatedDate,IP,OperatorID,Issue_Center,Default_Branch,Default_Godown,Change_Branch,Change_Godown,Issued_Qty,Issued_Date,Issued_Bags,Bags_Type,Truck_No,Stock_Issued_From,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,STrans_ID,Recd_Qty,Recd_Bags,Recd_Date,RecIC,RecBranch,RecGodown,RSDRecd_Qty,RSDRecd_Bags,RSDRecd_Date,RSDCreatedDate,RRDRecd_Qty,RRDRecd_Bags,RRDRecd_Date,RRDCreated,Distance,Consinment_No,Book_No,Page_No,SubSMO,RMO,DeletedDate,DeletedIP,Operation) select MoveOrdernum,SMO,TO_No,STO_No,DC_No,Transporter_ID,FrmDist,ToDist,Commodity,CropYear,TOEndDate,ModeofDispatch,IsReceived,DC_MO,CreatedDate,IP,OperatorID,Issue_Center,Default_Branch,Default_Godown,Change_Branch,Change_Godown,Issued_Qty,Issued_Date,Issued_Bags,Bags_Type,Truck_No,Stock_Issued_From,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,STrans_ID,Recd_Qty,Recd_Bags,Recd_Date,RecIC,RecBranch,RecGodown,RSDRecd_Qty,RSDRecd_Bags,RSDRecd_Date,RSDCreatedDate,RRDRecd_Qty,RRDRecd_Bags,RRDRecd_Date,RRDCreated,Distance,Consinment_No,Book_No,Page_No,SubSMO,RMO,GETDATE(),'" + GetIp + "','D' From DeliveryChallan_MO where DC_MO='" + ddlPageNo.SelectedValue.ToString() + "' and SMO='" + hdfSMO.Value + "' and STO_No='" + hdfSTO_No.Value + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and ModeofDispatch='13' and Issue_Center='0000' and Truck_No='" + txtTCNo.Text + "' and Book_No='" + ddlBookNo.SelectedItem.ToString() + "' and Page_No='" + ddlPageNo.SelectedItem.ToString() + "' and Consinment_No='" + txtConsNo.Text + "' and IsReceived='N'; ";

                            instr += "Delete From DeliveryChallan_MO where DC_MO='" + ddlPageNo.SelectedValue.ToString() + "' and SMO='" + hdfSMO.Value + "' and STO_No='" + hdfSTO_No.Value + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and ModeofDispatch='13' and Issue_Center='0000' and Truck_No='" + txtTCNo.Text + "' and Book_No='" + ddlBookNo.SelectedItem.ToString() + "' and Page_No='" + ddlPageNo.SelectedItem.ToString() + "' and Consinment_No='" + txtConsNo.Text + "' and IsReceived='N'; ";

                            instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";
                        }


                        cmd = new SqlCommand(instr, con);
                        int count = cmd.ExecuteNonQuery();

                        if (count > 0)
                        {
                            btnDelete.Enabled = false;

                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('डिलेवरी चालान सफलता पूर्वक डिलीट हो चूका है|'); </script> ");
                            txtIssuedQty.Text = "";

                            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
                        }
                        else
                        {
                            Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> ");
                        }
                    }
                    catch (Exception ex)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                    }

                    finally
                    {
                        if (con.State != ConnectionState.Closed)
                        {
                            con.Close();
                        }
                    }
                }
            }
            else
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
    }
예제 #30
0
    protected void bttsubmit_Click(object sender, EventArgs e)
    {
        if (rdbAll.Checked == true)
        {
            using (con = new SqlConnection(strcon))
            {
                try
                {
                    con.Open();

                    ClientIP          objClientIP    = new ClientIP();
                    string            GetIp          = objClientIP.GETIP();
                    ConvertServerDate ServerFromDate = new ConvertServerDate();
                    string            IssuedFromDate = ServerFromDate.getDate_MDY(txtFrmdate.Text);
                    ConvertServerDate ServerToDate   = new ConvertServerDate();
                    string            IssuedToDate   = ServerToDate.getDate_MDY(txtTOdate.Text);
                    //ConvertServerDate ServerDate = new ConvertServerDate();
                    //string strselect = "update PM_RatioMaster set Total='" + txttotal.Text + "', FDR='" + txtfdr.Text + "', Checks='" + txtcheck.Text + "', IP='" + GetIp + "', CreatedDate=getdate(), ParticularMiller='N', Lot_amount='" + txtlot.Text + "',Frm_Date='" + IssuedFromDate + "', To_Date='" + IssuedToDate + "'  where CropYear='" + ddlCropYear.SelectedValue.ToString() + "'";
                    string instr = "";
                    instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                            "insert into PM_RatioMaster_LOG select * from PM_RatioMaster as RM  where RM.CropYear='" + ddlCropYear.SelectedValue.ToString() + "'  and (ParticularMiller='N' or  ParticularMiller is null or  ParticularMiller='')  ; ";

                    instr += "update PM_RatioMaster set Total='" + txttotal.Text + "', FDR='" + txtfdr.Text + "', Checks='" + txtcheck.Text + "', IP='" + GetIp + "', CreatedDate=getdate(), ParticularMiller='N', Lot_amount='" + txtlot.Text + "',Frm_Date='" + IssuedFromDate + "', To_Date='" + IssuedToDate + "'  where CropYear='" + ddlCropYear.SelectedValue.ToString() + "' and (ParticularMiller='N' or  ParticularMiller is null or  ParticularMiller='') ; ";

                    instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";

                    cmd = new SqlCommand(instr, con);
                    int count = cmd.ExecuteNonQuery();

                    if (count > 0)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully for Crop Year  " + ddlCropYear.SelectedValue.ToString() + "'); </script> ");
                        ddlCropYear.Enabled = false;
                        txtlot.Enabled      = false;
                        txttotal.Enabled    = false;
                        txtfdr.Enabled      = false;
                        txtcheck.Enabled    = false;
                        txtTOdate.Enabled   = false;
                        txtFrmdate.Enabled  = false;

                        bttsubmit.Enabled = false;
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                }

                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
        else if (rdbparticularMiller.Checked == true)
        {
            using (con = new SqlConnection(strcon))
            {
                try
                {
                    con.Open();

                    ClientIP objClientIP = new ClientIP();
                    string   GetIp       = objClientIP.GETIP();

                    ConvertServerDate ServerFromDate = new ConvertServerDate();
                    string            IssuedFromDate = ServerFromDate.getDate_MDY(txtFrmdate.Text);
                    ConvertServerDate ServerToDate   = new ConvertServerDate();
                    string            IssuedToDate   = ServerToDate.getDate_MDY(txtTOdate.Text);
                    //ConvertServerDate ServerDate = new ConvertServerDate();
                    //string strselect = "update PM_RatioMaster set Total='" + txttotal.Text + "', FDR='" + txtfdr.Text + "', Checks='" + txtcheck.Text + "', ParticularMiller='Y',  CreatedDate=getdate(),  IP='" + GetIp + "',   Lot_amount='" + txtlot.Text + "',Frm_Date='" + IssuedFromDate + "', To_Date='" + IssuedToDate + "' where CropYear='" + ddlCropYear.SelectedValue.ToString() + "' and Mill_ID='" + ddlMillName.SelectedValue.ToString() + "' and MillerDist='" + ddlmillDist.SelectedValue.ToString() + "'";

                    string instr = "";
                    instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " +
                            "insert into PM_RatioMaster_LOG select * from PM_RatioMaster as RM  where RM.CropYear='" + ddlCropYear.SelectedValue.ToString() + "' and MillerDist='" + ddlmillDist.SelectedValue.ToString() + "'  and Mill_ID='" + ddlMillName.SelectedValue.ToString() + "' ; ";

                    instr += "update PM_RatioMaster set Total='" + txttotal.Text + "', FDR='" + txtfdr.Text + "', Checks='" + txtcheck.Text + "', ParticularMiller='Y',  CreatedDate=getdate(),  IP='" + GetIp + "',   Lot_amount='" + txtlot.Text + "',Frm_Date='" + IssuedFromDate + "', To_Date='" + IssuedToDate + "' where CropYear='" + ddlCropYear.SelectedValue.ToString() + "' and Mill_ID='" + ddlMillName.SelectedValue.ToString() + "' and MillerDist='" + ddlmillDist.SelectedValue.ToString() + "'; ";

                    instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorSeverity = ERROR_SEVERITY(),   @ErrorState = ERROR_STATE();  RAISERROR (@ErrorMessage,  @ErrorSeverity,@ErrorState ); END CATCH;";


                    cmd = new SqlCommand(instr, con);
                    int count = cmd.ExecuteNonQuery();

                    if (count > 0)
                    {
                        Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully for Crop Year  " + ddlCropYear.SelectedValue.ToString() + "'); </script> ");
                        ddlCropYear.Enabled = false;
                        ddlmillDist.Enabled = false;
                        ddlMillName.Enabled = false;
                        txtlot.Enabled      = false;
                        txttotal.Enabled    = false;
                        txtfdr.Enabled      = false;
                        txtcheck.Enabled    = false;
                        txtTOdate.Enabled   = false;
                        txtFrmdate.Enabled  = false;
                        bttsubmit.Enabled   = false;
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> ");
                }

                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
    }