using System;
using System.Data;
using System.Web.UI;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                    Started Date  : 12-Aug-2007
* Module          : User Groups                                  Last Modified : 14-Aug-2007
* Programmer      : Senthil Kumar NP
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Masters_TA_UI_Master_usergroups_del : Base.BasePage
{
    userRightsEventData delUserGrp = new userRightsEventData();
    cls_Common objCommon = new cls_Common();
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking and reset date format
        if (!IsPostBack)
        {
            objCommon.menu("Previlege", "21");
        }
        base.Page_Load(sender, e);
        int gid;
        Cls_CheckUser chck = new Cls_CheckUser();
        DataSet dsCheck = chck.checkRights(21, Convert.ToInt32(Session["userGroup_Id"]), "deletePrv");
        if (dsCheck.Tables[0].Rows.Count > 0)
        {
        }
        else
        {
            Response.Redirect("TA_UI_Master_groupView.aspx");
        }
        if (Request.QueryString["gid"] != null)
        {
            gid = Convert.ToInt16(Request.QueryString["gid"]);
            DataSet ds = new DataSet();
            ds = delUserGrp.CheckUserGroupForDel(gid, "C");
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["recCount"] != DBNull.Value)
                {
                    if (Convert.ToInt16(ds.Tables[0].Rows[0]["recCount"]) > 0)
                    {
                        string strScript = "";
                        strScript = strScript + "<script language='javascript'>";
                        strScript = strScript + "alert('Cannot Delete this Record, It is Already mapped with Employee');history.go(-1)";
                        strScript = strScript + "</script>";
                        Page.RegisterStartupScript("DelAlert", strScript);
                    }
                    else
                    {
                        delUserGrp.DelUserGroup(gid, "D");
                    }
                }
            }
        }
        string str = "alert('User Group Deleted Successfully.');location.replace('TA_UI_Master_groupView.aspx');";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "alertBox", str, true);
    }
}
