Esempio n. 1
0
    protected void btnSaveAndClose_Click(object sender, EventArgs e)
    {
        lblMsg.Text    = "";
        lblMsg.Visible = false;
        int REFF = 0;

        if (ViewState["AddEdit"].ToString() == "Add")
        {
            int       MaxID = BLL_Infra_ShipSettings.Ins_RANK_SCREEN_Access(UDFLib.ConvertToInteger(ViewState["ScreenID"].ToString()), txtButtonName.Text.Trim(), UDFLib.ConvertToInteger(Session["UserID"].ToString()), ref REFF);
            DataTable dt    = new DataTable();

            dt.Columns.Add("Rank_ID");
            dt.Columns.Add("RANK_SCREEN_Access_ID");
            dt.Columns.Add("Created_By");

            foreach (ListItem chkitem in chkRanksList.Items)
            {
                DataRow dr = dt.NewRow();
                dr["Rank_ID"] = UDFLib.ConvertToInteger(chkitem.Value);
                dr["RANK_SCREEN_Access_ID"] = MaxID;
                dr["Created_By"]            = UDFLib.ConvertToInteger(Session["UserID"].ToString());

                if (chkitem.Selected == true)
                {
                    dt.Rows.Add(dr);
                }
            }
            if (dt.Rows.Count != 0)
            {
                int    result   = BLL_Infra_ShipSettings.Ins_RANK_SCREEN_Access_Details(dt);
                string Ranklist = String.Format("hideModal('dvAddButton',false);");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Ranklist", Ranklist, true);
                BindScreen_By_SrceenID();
                upDetails.Update();
                ViewState["AddEdit"] = null;
            }
            else
            {
                string Ranklist = "Please select at least one rank..! ";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Ranklist", Ranklist, true);
                lblMsg.Text    = "Please select at least one rank..! ";
                lblMsg.Visible = true;
            }
        }
        else
        {
            int       MaxID = BLL_Infra_ShipSettings.Update_RANK_SCREEN_Access(UDFLib.ConvertToInteger(ViewState["ID"].ToString()), txtButtonName.Text.Trim(), UDFLib.ConvertToInteger(Session["UserID"].ToString()));
            DataTable dt    = new DataTable();

            dt.Columns.Add("Rank_ID");
            dt.Columns.Add("RANK_SCREEN_Access_ID");
            dt.Columns.Add("Created_By");

            foreach (ListItem chkitem in chkRanksList.Items)
            {
                DataRow dr = dt.NewRow();
                dr["Rank_ID"] = UDFLib.ConvertToInteger(chkitem.Value);
                dr["RANK_SCREEN_Access_ID"] = UDFLib.ConvertToInteger(ViewState["ID"].ToString());
                dr["Created_By"]            = UDFLib.ConvertToInteger(Session["UserID"].ToString());

                if (chkitem.Selected == true)
                {
                    dt.Rows.Add(dr);
                }
            }
            if (dt.Rows.Count != 0)
            {
                int    result   = BLL_Infra_ShipSettings.Update_RANK_SCREEN_Access_Details(dt, UDFLib.ConvertToInteger(ViewState["ID"].ToString()));
                string Ranklist = String.Format("hideModal('dvAddButton',false);");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Ranklist", Ranklist, true);
                BindScreen_By_SrceenID();
                upDetails.Update();
                ViewState["AddEdit"] = null;
            }
            else
            {
                string Ranklist = "Please select at least one rank..! ";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Ranklist", Ranklist, true);
                lblMsg.Text    = "Please select at least one rank..! ";
                lblMsg.Visible = true;
            }
        }
    }