Beispiel #1
0
    protected void dgDetailPO_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete"))
        {
            if (!ModifyLog(((Label)(dgDetailPO.Rows[e.RowIndex].FindControl("lblIWM_CODE"))).Text))
            {
                try
                {
                    string cpom_code = ((Label)(dgDetailPO.Rows[e.RowIndex].FindControl("lblIWM_CODE"))).Text;

                    if (CommonClasses.CheckUsedInTran("INSPECTION_S_MASTER", "INSM_IWM_CODE", "AND ES_DELETE=0", cpom_code))
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You can't delete this record, it is used in Material Inspection";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                        return;
                    }
                    else
                    {
                        bool flag = CommonClasses.Execute1("UPDATE INWARD_MASTER SET ES_DELETE = 1 WHERE IWM_CODE='" + Convert.ToInt32(cpom_code) + "'");
                        if (flag == true)
                        {
                            DataTable dtq = CommonClasses.Execute("SELECT IWD_REV_QTY,IWD_I_CODE,IWD_CPOM_CODE FROM INWARD_DETAIL where IWD_IWM_CODE=" + cpom_code + " ");

                            for (int i = 0; i < dtq.Rows.Count; i++)
                            {
                                CommonClasses.Execute("update SUPP_PO_DETAILS set SPOD_INW_QTY=SPOD_INW_QTY-" + dtq.Rows[i]["IWD_REV_QTY"] + " where SPOD_I_CODE='" + dtq.Rows[i]["IWD_I_CODE"] + "' and SPOD_SPOM_CODE='" + dtq.Rows[i]["IWD_CPOM_CODE"] + "'");
                                //CommonClasses.Execute("UPDATE ITEM_MASTER SET I_CURRENT_BAL=I_CURRENT_BAL-" + dtq.Rows[i]["IWD_REV_QTY"] + " where I_CODE='" + dtq.Rows[i]["IWD_I_CODE"] + "'");
                            }

                            DataTable dtchallan = new DataTable();
                            dtchallan = CommonClasses.Execute("SELECT * FROM CHALLAN_STOCK_LEDGER where CL_DOC_TYPE='IWIAP' AND CL_DOC_ID='" + cpom_code + "'");

                            for (int z = 0; z < dtchallan.Rows.Count; z++)
                            {
                                CommonClasses.Execute("UPDATE CHALLAN_STOCK_LEDGER SET CL_CON_QTY=CL_CON_QTY +" + Convert.ToDouble(dtchallan.Rows[z]["CL_CQTY"].ToString()) + " where CL_DOC_TYPE='OutSUBINM' AND CL_P_CODE='" + dtchallan.Rows[z]["CL_P_CODE"].ToString() + "' AND CL_CH_NO='" + dtchallan.Rows[z]["CL_CH_NO"].ToString() + "' AND CL_I_CODE='" + dtchallan.Rows[z]["CL_I_CODE"].ToString() + "'  ");
                            }
                            CommonClasses.Execute(" DELETE FROM CHALLAN_STOCK_LEDGER where CL_DOC_TYPE='IWIAP' AND CL_DOC_ID='" + cpom_code + "'");

                            //flag = CommonClasses.Execute1("DELETE FROM STOCK_LEDGER WHERE STL_DOC_NO='" + cpom_code + "' and STL_DOC_TYPE='IWIM'");
                            //if (flag == true)
                            //{
                            //    flag = CommonClasses.Execute1("DELETE FROM GIN_STOCK_LEDGER WHERE GL_DOC_ID='" + cpom_code + "' and GL_DOC_TYPE='IWIM'");
                            //}


                            //CommonClasses.WriteLog("Material Inward ", "Delete", "Material Inward", cpom_code, Convert.ToInt32(cpom_code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]),(Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                            CommonClasses.WriteLog("Material Inward ", "Delete", "Material Inward", cpom_code, Convert.ToInt32(cpom_code), Convert.ToInt32(Session["CompanyId"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                            PanelMsg.Visible = true;
                            lblmsg.Text      = "Record deleted successfully";
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    CommonClasses.SendError("Material Inward", "dgDetailPO_RowDeleting", Ex.Message);
                }
            }
            else
            {
                PanelMsg.Visible = true;
                lblmsg.Text      = "Record used by another person";
                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                return;
            }


            LoadInward();
        }
        else
        {
            PanelMsg.Visible = true;
            lblmsg.Text      = "You have no rights to delete";
            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

            //ShowMessage("#Avisos", "You Have No Rights To Delete", CommonClasses.MSG_Erro);
            return;
        }
    }
Beispiel #2
0
    protected void dgDetailServicePO_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            #region View
            if (e.CommandName.Equals("View"))
            {
                if (CommonClasses.ValidRights(int.Parse(right.Substring(1, 1)), this, "For View"))
                {
                    if (!ModifyLog(e.CommandArgument.ToString()))
                    {
                        string type      = "VIEW";
                        string cpom_code = e.CommandArgument.ToString();
                        Response.Redirect("~/Transactions/ADD/ServicePurchaseOrder.aspx?c_name=" + type + "&cpom_code=" + cpom_code, false);
                    }
                    else
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "Record Used By Another Person";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                        return;
                    }
                }
                else
                {
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "You have no rights to View";
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                    return;
                }
            }
            #endregion

            #region Modify
            else if (e.CommandName.Equals("Modify"))
            {
                if (CommonClasses.ValidRights(int.Parse(right.Substring(2, 1)), this, "For Modify"))
                {
                    if ((CommonClasses.Execute("select count(*) as counted from SERVICE_PO_MASTER where SRPOM_CANCEL_PO=1 and ES_DELETE=0 and SRPOM_CODE='" + e.CommandArgument.ToString() + "'")).Rows[0][0].ToString() == "0")
                    {
                        if (!ModifyLog(e.CommandArgument.ToString()))
                        {
                            string    type      = "MODIFY";
                            string    cpom_code = e.CommandArgument.ToString();
                            DataTable dt        = CommonClasses.Execute("select isnull(SRPOM_POST,0) as SRPOM_POST,isnull(SRPOM_P_AMEND_CODE,0) as SRPOM_P_AMEND_CODE  from SERVICE_PO_MASTER where SRPOM_CODE='" + cpom_code + "' ");
                            if (dt.Rows.Count > 0)
                            {
                                if (Convert.ToBoolean(dt.Rows[0]["SRPOM_POST"].ToString()) == true)
                                {
                                    PanelMsg.Visible = true;
                                    lblmsg.Text      = "This PO is posted and can not be modified";
                                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                                    return;
                                }
                                //else if (Convert.ToInt32(dt.Rows[0]["SRPOM_P_AMEND_CODE"]) != 0)
                                //{
                                //    PanelMsg.Visible = true;
                                //    lblmsg.Text = "You Can't Modify Because These PO Is Amend";
                                //    return;
                                //}
                                else
                                {
                                    if (CommonClasses.CheckUsedInTran("INWARD_MASTER,INWARD_DETAIL", "IWD_CPOM_CODE", "AND IWD_CPOM_CODE=SRPOM_CODE and INWARD_MASTER.ES_DELETE=0", cpom_code))
                                    {
                                        PanelMsg.Visible = true;
                                        lblmsg.Text      = "You can't delete this record, it is used in Inward Master";
                                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                                        return;
                                    }
                                    else
                                    {
                                        Response.Redirect("~/Transactions/ADD/ServicePurchaseOrder.aspx?c_name=" + type + "&cpom_code=" + cpom_code, false);
                                    }
                                }
                            }
                        }
                    }

                    else
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You Can't Modify Because it is cancelled";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                        return;
                    }
                }
                else
                {
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "You have no rights to Modify";
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);


                    return;
                }
            }
            #endregion

            #region Print
            else if (e.CommandName.Equals("Print"))
            {
                if (CommonClasses.ValidRights(int.Parse(right.Substring(5, 1)), this, "For Print"))
                {
                    if ((CommonClasses.Execute("select count(*) as counted from SERVICE_PO_MASTER where SRPOM_CANCEL_PO=1 and ES_DELETE=0 and SRPOM_CODE='" + e.CommandArgument.ToString() + "'")).Rows[0][0].ToString() == "0")
                    {
                        if (!ModifyLog(e.CommandArgument.ToString()))
                        {
                            string    cpom_code = e.CommandArgument.ToString();
                            string    PoType    = "";
                            DataTable dtAuth    = CommonClasses.Execute("Select SRPOM_AUTHR_FLAG,SRPOM_TYPE,PO_T_SHORT_NAME from SERVICE_PO_MASTER,PO_TYPE_MASTER  where  PO_T_CODE=SRPOM_TYPE and SRPOM_CODE='" + cpom_code + "'");
                            string    AuthoFlag = "";
                            if (dtAuth.Rows[0]["SRPOM_AUTHR_FLAG"].ToString() == "False")
                            {
                                AuthoFlag = "true";
                            }
                            //if (dtAuth.Rows[0]["SRPOM_TYPE"].ToString() == "-2147483647")
                            if (dtAuth.Rows[0]["PO_T_SHORT_NAME"].ToString().Contains("IMPORT"))
                            {
                                PoType = "Export PO";
                            }
                            else
                            {
                                PoType = "Domestic PO";
                            }
                            Response.Redirect("~/RoportForms/ADD/ServiceOrderPrint.aspx?cpom_code=" + cpom_code + "&AuthoType=" + AuthoFlag + "&PoType=" + PoType, false);
                        }
                        //else
                        //{
                        //    PanelMsg.Visible = true;
                        //    lblmsg.Text = "Record used by another person";

                        //    return;
                        //}
                    }
                    else
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You Can't Modify Because it is cancelled";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                        return;
                    }
                }
                else
                {
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "You have no rights to Print";
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                    return;
                }
            }

            #endregion

            #region Authorize
            else if (e.CommandName.Equals("Authorize"))
            {
                if ((CommonClasses.Execute("select count(*) as counted from SERVICE_PO_MASTER where SRPOM_CANCEL_PO=1 and ES_DELETE=0 and SRPOM_CODE='" + e.CommandArgument.ToString() + "'")).Rows[0][0].ToString() == "0")
                {
                    int    index   = Convert.ToInt32(e.CommandArgument);
                    string qe_code = ((Label)dgDetailServicePO.Rows[index].FindControl("lblCPOM_CODE")).Text;

                    CommonClasses.Execute("update SERVICE_PO_MASTER set SRPOM_AUTHR_FLAG=1 where SRPOM_CODE=" + qe_code + "");
                    CommonClasses.WriteLog("Service Purchase Order ", "Authorize", "Service Purchase Order", qe_code, Convert.ToInt32(qe_code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                }
                else
                {
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "You Can't Modify Because it is cancelled";
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                    return;
                }
            }

            #endregion

            #region Post
            else if (e.CommandName.Equals("Post"))
            {
                if ((CommonClasses.Execute("select count(*) as counted from SERVICE_PO_MASTER where SRPOM_CANCEL_PO=1 and ES_DELETE=0 and SRPOM_CODE='" + e.CommandArgument.ToString() + "'")).Rows[0][0].ToString() == "0")
                {
                    if (!ModifyLog(e.CommandArgument.ToString()))
                    {
                        string cpom_code = e.CommandArgument.ToString();
                        if (CommonClasses.Execute1("update SERVICE_PO_MASTER set SRPOM_POST=1 where SRPOM_CODE='" + cpom_code + "'"))
                        {
                            CommonClasses.WriteLog("Service Purchase Order ", "Post", "Service Purchase Order", cpom_code, Convert.ToInt32(cpom_code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));

                            LoadServicePO();
                            PanelMsg.Visible = true;
                            lblmsg.Text      = "Record Posted";
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                            return;
                        }
                        else
                        {
                            PanelMsg.Visible = true;
                            lblmsg.Text      = "Record Not Posted";
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                            return;
                        }
                    }
                    //else
                    //{
                    //    PanelMsg.Visible = true;
                    //    lblmsg.Text = "Record used by another person";
                    //    return;
                    //}
                }
                else
                {
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "You Can't Modify Because it is cancelled";
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                    return;
                }
            }
            #endregion

            #region Amend
            else if (e.CommandName.Equals("Amend"))
            {
                //string cpom_code = e.CommandArgument.ToString();
                //DataTable dt = CommonClasses.Execute("select isnull(SRPOM_POST,0) as SRPOM_POST  from SERVICE_PO_MASTER where SRPOM_CODE='" + cpom_code + "' ");
                //if (dt.Rows.Count > 0)
                //{
                //    if (Convert.ToBoolean(dt.Rows[0]["SRPOM_POST"].ToString()) == false)
                //    {
                //        PanelMsg.Visible = true;
                //        lblmsg.Text = "First Post This PO";
                //        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                //        return;
                //    }
                //    else
                //    {
                //        if (!ModifyLog(e.CommandArgument.ToString()))
                //        {
                //            string type = "AMEND";
                //            Session["AMEND"] = "AMEND";
                //            Response.Redirect("~/Transactions/ADD/ServicePurchaseOrder.aspx?c_name=" + type + "&cpom_code=" + cpom_code, false);
                //        }
                //        //else
                //        //{
                //        //    PanelMsg.Visible = true;
                //        //    lblmsg.Text = "Record used by another person";
                //        //    return;
                //        //}
                //    }
                //}
                if ((CommonClasses.Execute("select count(*) as counted from SERVICE_PO_MASTER where SRPOM_CANCEL_PO=1 and ES_DELETE=0 and SRPOM_CODE='" + e.CommandArgument.ToString() + "'")).Rows[0][0].ToString() == "0")
                {
                    string cpom_code = e.CommandArgument.ToString();
                    if (!ModifyLog(e.CommandArgument.ToString()))
                    {
                        DataTable dt = CommonClasses.Execute("select SRPOD_SPOM_CODE,SRPOM_IS_SHORT_CLOSE, sum(SRPOD_ORDER_QTY) AS SRPOD_ORDER_QTY,sum(SRPOD_INW_QTY) AS SRPOD_INW_QTY FROM SERVICE_PO_MASTER,SERVICE_PO_DETAILS WHERE SRPOM_CODE=SRPOD_SPOM_CODE AND SRPOM_CODE='" + cpom_code + "' AND SRPOM_POST=1 Group BY SRPOD_SPOM_CODE,SRPOM_IS_SHORT_CLOSE");
                        if (dt.Rows.Count > 0)
                        {
                            double ORDER_QTY      = Convert.ToDouble(dt.Rows[0]["SRPOD_ORDER_QTY"].ToString());
                            double INW_QTY        = Convert.ToDouble(dt.Rows[0]["SRPOD_INW_QTY"].ToString());
                            string IS_SHORT_CLOSE = dt.Rows[0]["SRPOM_IS_SHORT_CLOSE"].ToString();
                            //if (ORDER_QTY - INW_QTY == 0 || INW_QTY == 0 || IS_SHORT_CLOSE == "True")
                            //if (IS_SHORT_CLOSE == "True" || INW_QTY == 0)
                            //{
                            string type1 = "AMEND";
                            Session["AMEND"] = "AMEND";
                            Response.Redirect("~/Transactions/ADD/ServicePurchaseOrder.aspx?c_name=" + type1 + "&cpom_code=" + cpom_code, false);
                            return;
                            //}
                            //else if (INW_QTY > 0)
                            //{
                            //    PanelMsg.Visible = true;
                            //    lblmsg.Text = "Couldn't  Amend, This is Open Purchase order.";
                            //    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                            //    return;
                            //}
                        }
                        else
                        {
                            PanelMsg.Visible = true;
                            lblmsg.Text      = "First Post This PO";
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                            return;
                        }
                    }
                    else
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "Record used by another person";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                        return;
                    }
                }
                else
                {
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "You Can't Modify Because it is cancelled";
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                    return;
                }
            }
            #endregion

            #region ShortClose
            else if (e.CommandName.Equals("ShortClose"))
            {
                if ((CommonClasses.Execute("select count(*) as counted from SERVICE_PO_MASTER where SRPOM_CANCEL_PO=1 and ES_DELETE=0 and SRPOM_CODE='" + e.CommandArgument.ToString() + "'")).Rows[0][0].ToString() == "0")
                {
                    if (!ModifyLog(e.CommandArgument.ToString()))
                    {
                        string    cpom_code = e.CommandArgument.ToString();
                        DataTable dt        = CommonClasses.Execute("select isnull(SRPOM_IS_SHORT_CLOSE,0) as SRPOM_IS_SHORT_CLOSE,SRPOM_POST  from SERVICE_PO_MASTER where SRPOM_CODE='" + cpom_code + "' AND SRPOM_IS_SHORT_CLOSE=0");
                        if (dt.Rows.Count > 0)
                        {
                            if ((dt.Rows[0]["SRPOM_POST"]).ToString() == "True")
                            {
                                //DataTable DtInw = CommonClasses.Execute("SELECT MAX (SRPOD_INW_QTY) as SRPOD_INW_QTY FROM SERVICE_PO_MASTER,SERVICE_PO_DETAILS WHERE SRPOM_CODE=SRPOD_SPOM_CODE AND SERVICE_PO_MASTER.ES_DELETE=0 AND SRPOM_CODE='" + cpom_code + "'");
                                //double INW_QTY = Convert.ToDouble(DtInw.Rows[0]["SRPOD_INW_QTY"].ToString());
                                //if (INW_QTY > 0)
                                //{
                                bool Res = CommonClasses.Execute1("UPDATE SERVICE_PO_MASTER SET SRPOM_IS_SHORT_CLOSE=1 WHERE SRPOM_CODE='" + cpom_code + "'");
                                if (Res == true)
                                {
                                    CommonClasses.WriteLog("Service Purchase Order ", "ShortClose", "Service Purchase Order", cpom_code, Convert.ToInt32(cpom_code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                                    PanelMsg.Visible = true;
                                    lblmsg.Text      = "Short Close Successfully";
                                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                                    return;
                                }

                                //}
                                //else
                                //{
                                //    PanelMsg.Visible = true;
                                //    lblmsg.Text = "Can Not Short Close Pending for Inward";
                                //    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                                //    return;
                                //}
                            }
                            else
                            {
                                PanelMsg.Visible = true;
                                lblmsg.Text      = "First Post This PO";
                                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                                return;
                            }
                        }
                        else
                        {
                            PanelMsg.Visible = true;
                            lblmsg.Text      = "Allready Short Closed";
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                            return;
                        }
                    }
                }
                else
                {
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "You Can't Modify Because it is cancelled";
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                    return;
                }
            }
            #endregion

            #region CancelPO
            else if (e.CommandName.Equals("CancelPO"))
            {
                if (!ModifyLog(e.CommandArgument.ToString()))
                {
                    string cpom_code = e.CommandArgument.ToString();
                    //if (CommonClasses.CheckUsedInTran("INWARD_MASTER,INWARD_DETAIL", "IWD_CPOM_CODE", "AND IWD_CPOM_CODE=SRPOM_CODE and INWARD_MASTER.ES_DELETE=0", cpom_code))
                    //{
                    //    PanelMsg.Visible = true;
                    //    lblmsg.Text = "You Can't Cancel This PO, It Is Used In Inward Master";
                    //    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                    //    return;
                    //}
                    //else
                    //{
                    if (CommonClasses.Execute1("update SERVICE_PO_MASTER set SRPOM_CANCEL_PO=1 where SRPOM_CODE='" + cpom_code + "'"))
                    {
                        CommonClasses.WriteLog("Service Purchase Order ", "CancelPO", "Service Purchase Order", cpom_code, Convert.ToInt32(cpom_code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));

                        LoadServicePO();
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "PO Canceled";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                        return;
                    }
                    else
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "PO Canceled";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                        return;
                    }
                    //}
                }
            }
            #endregion
        }
        catch (Exception Ex)
        {
            CommonClasses.SendError("Service Po Transaction", "dgDetailServicePO_RowCommand", Ex.Message);
        }
    }
    protected void dgState_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete"))
            {
                if (!ModifyLog(((Label)(dgState.Rows[e.RowIndex].FindControl("lblL_CODE"))).Text))
                {
                    string s_code = ((Label)(dgState.Rows[e.RowIndex].FindControl("lblL_CODE"))).Text;
                    string s_name = ((Label)(dgState.Rows[e.RowIndex].FindControl("lblL_NAME"))).Text;

                    if (CommonClasses.CheckUsedInTran("CASH_BOOK_ENTRY", "C_NAME", "AND ES_DELETE=0", s_code))
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You can't delete this record because it has used in Cash Book Entry";

                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                        //ShowMessage("#Avisos", "You cant delete this record it has used in city master", CommonClasses.MSG_Warning);
                    }
                    else if (CommonClasses.CheckUsedInTran("CASH_BOOK_ENTRY", "C_L_CODE", "AND ES_DELETE=0", s_code))
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You can't delete this record because it has used in Cash Book Entry";

                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                        //ShowMessage("#Avisos", "You cant delete this record it has used in city master", CommonClasses.MSG_Warning);
                    }
                    else
                    {
                        bool flag = CommonClasses.Execute1("UPDATE ACCOUNT_LEDGER SET ES_DELETE = 1 WHERE L_CODE='" + Convert.ToInt32(s_code) + "'");
                        if (flag == true)
                        {
                            CommonClasses.WriteLog("Account Ledger Master", "Delete", "Account Ledger Master", s_code, Convert.ToInt32(s_code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                            // ShowMessage("#Avisos", CommonClasses.strRegDelSucesso, CommonClasses.MSG_Erro);
                            PanelMsg.Visible = true;
                            lblmsg.Text      = "Record Deleted Successfully";

                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                        }
                    }
                    //}
                    LoadState();
                }
                else
                {
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "Record Used By Another Person";

                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                    //ShowMessage("#Avisos", "Record Used By Another Person", CommonClasses.MSG_Erro);
                    return;
                }
            }
            else
            {
                PanelMsg.Visible = true;
                lblmsg.Text      = "You Have No Rights To Delete";

                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                //    //ShowMessage("#Avisos", "You Have No Rights To Delete", CommonClasses.MSG_Erro);
                //   return;
            }
        }
        catch (Exception Ex)
        {
            CommonClasses.SendError("Account Ledger Master", "dgState_RowDeleting", Ex.Message);
        }
    }
    protected void dgServiceTypeMaster_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete"))
        {
            if (!ModifyLog(((Label)(dgServiceTypeMaster.Rows[e.RowIndex].FindControl("lblS_CODE"))).Text))
            {
                string i_code   = ((Label)(dgServiceTypeMaster.Rows[e.RowIndex].FindControl("lblS_CODE"))).Text;
                string i_name   = ((Label)(dgServiceTypeMaster.Rows[e.RowIndex].FindControl("lblS_NAME"))).Text;
                string i_codeno = ((Label)(dgServiceTypeMaster.Rows[e.RowIndex].FindControl("lblS_CODENO"))).Text;

                if (CommonClasses.CheckUsedInTran("SERVICE_PO_MASTER,SERVICE_PO_DETAILS", "SRPOD_I_CODE", "AND SRPOD_SPOM_CODE=SRPOM_CODE and SERVICE_PO_MASTER.ES_DELETE=0", i_code))
                {
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "You cant delete this record it has used in Service Purchase Order";
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                    return;
                }
                //if (CommonClasses.CheckUsedInTran("CUSTPO_MASTER,CUSTPO_DETAIL", "CPOD_I_CODE", "AND CPOD_CPOM_CODE=CPOM_CODE and CUSTPO_MASTER.ES_DELETE=0", i_code))
                //{
                //    PanelMsg.Visible = true;
                //    lblmsg.Text = "You cant delete this record it has used in Sales Order";
                //    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                //    return;
                //}
                //if (CommonClasses.CheckUsedInTran("ISSUE_MASTER,ISSUE_MASTER_DETAIL ", "IMD_I_CODE", " AND ISSUE_MASTER.IM_CODE=ISSUE_MASTER_DETAIL.IM_CODE AND ISSUE_MASTER.ES_DELETE=0", i_code))
                //{
                //    PanelMsg.Visible = true;
                //    lblmsg.Text = "You cant delete this record it has used in Issue To Production";
                //    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                //    return;
                //}
                //if (CommonClasses.CheckUsedInTran("PRODUCTION_TO_STORE_MASTER,PRODUCTION_TO_STORE_DETAIL ", "PSD_I_CODE", " AND PS_CODE=PSD_PS_CODE AND PRODUCTION_TO_STORE_MASTER.ES_DELETE=0", i_code))
                //{
                //    PanelMsg.Visible = true;
                //    lblmsg.Text = "You cant delete this record it has used in  Production TO store";
                //    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                //    return;
                //}
                bool flag = CommonClasses.Execute1("UPDATE SERVICE_TYPE_MASTER SET ES_DELETE = 1 WHERE S_CODE='" + Convert.ToInt32(i_code) + "'");
                if (flag == true)
                {
                    CommonClasses.WriteLog("Service Type Master", "Delete", "Service Type Master", i_name, Convert.ToInt32(i_code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                    //ShowMessage("#Avisos", CommonClasses.strRegDelSucesso, CommonClasses.MSG_Erro);
                    PanelMsg.Visible = true;
                    lblmsg.Text      = "Record Deleted Successfully";
                    LoadItem();
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                }
            }
            else
            {
                PanelMsg.Visible = true;
                lblmsg.Text      = "Record Used By Another Person";
                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                return;
            }
        }
        else
        {
            //ShowMessage("#Avisos", "You Have No Rights To Delete", CommonClasses.MSG_Erro);
            PanelMsg.Visible = true;
            lblmsg.Text      = "You Have No Rights To Delete";
            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
            return;
        }
    }
Beispiel #5
0
    protected void dgSalesTaxMaster_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete"))
            {
                if (!ModifyLog(((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_CODE"))).Text))
                {
                    BL_SalesTaxMAster = new SalesTaxMaster_BL();
                    string ST_CODE      = ((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_CODE"))).Text;
                    string ST_TAX_NAME  = ((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_TAX_NAME"))).Text;
                    string ST_ALIAS     = ((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_ALIAS"))).Text;
                    string ST_SALES_TAX = ((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_SALES_TAX"))).Text;
                    string ST_TCS_TAX   = ((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_TCS_TAX"))).Text;
                    // string ST_SET_OFF = ((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_SET_OFF"))).Text;
                    string ST_FORM_NO        = ((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_FORM_NO"))).Text;
                    string ST_SALES_ACC_HEAD = ((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_SALES_ACC_HEAD"))).Text;
                    string ST_TAX_ACC_HEAD   = ((Label)(dgSalesTaxMaster.Rows[e.RowIndex].FindControl("lblST_TAX_ACC_HEAD"))).Text;

                    BL_SalesTaxMAster.ST_CODE = Convert.ToInt32(ST_CODE);
                    if (CommonClasses.CheckUsedInTran("ITEM_MASTER", "I_ACCOUNT_SALES", "AND ES_DELETE=0", ST_CODE))
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You cant delete this record it has used in Item Master";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                        // ShowMessage("#Avisos", "You cant delete this record it has used in Sales Tax Master", CommonClasses.MSG_Warning);
                    }
                    else if (CommonClasses.CheckUsedInTran("ITEM_MASTER", "I_ACCOUNT_PURCHASE", "AND ES_DELETE=0", ST_CODE))
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You cant delete this record it has used in Item Master";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                        // ShowMessage("#Avisos", "You cant delete this record it has used in Sales Tax Master", CommonClasses.MSG_Warning);
                    }

                    else
                    {
                        bool flag = BL_SalesTaxMAster.Delete();
                        if (flag == true)
                        {
                            CommonClasses.WriteLog("Sales Tax Master", "Delete", "Sales Tax Master", ST_CODE, Convert.ToInt32(ST_CODE), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                            //ShowMessage("#Avisos", CommonClasses.strRegDelSucesso, CommonClasses.MSG_Erro);
                            PanelMsg.Visible = true;
                            lblmsg.Text      = "Record Deleted Successfully";
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                        }
                        LoadSalesTaxMasterDetails();
                    }
                }
            }



            else
            {
                PanelMsg.Visible = true;
                lblmsg.Text      = "You Have No Rights To Delete";
                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                //ShowMessage("#Avisos", "You Have No Rights To Delete", CommonClasses.MSG_Erro);
                return;
            }
        }
        catch (Exception Ex)
        {
            CommonClasses.SendError("Saltes Tax Master", "dgSalesTaxMaster_RowDeleting", Ex.Message);
        }
    }