Esempio n. 1
0
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Int32  empIdno = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
            string strMsg  = string.Empty;

            if (e.CommandName == "cmdedit")
            {
                Response.Redirect("ContainerTypeMaster.aspx?ConType_Idno=" + e.CommandArgument, true);
            }
            else if (e.CommandName == "cmddelete")
            {
                ContainerTypeMasterDAL objclsConTypeMaster = new ContainerTypeMasterDAL();
                Int32 intValue = objclsConTypeMaster.Delete(Convert.ToInt32(e.CommandArgument));
                objclsConTypeMaster = null;
                if (intValue > 0)
                {
                    this.BindGrid();
                    strMsg = "Record deleted successfully.";
                    //  ddlGroupType.Focus();
                }
                else
                {
                    if (intValue == -1)
                    {
                        strMsg = "Record can not be deleted. It is in use.";
                    }
                    else
                    {
                        strMsg = "Record not deleted.";
                    }
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
                this.BindGrid();
            }
            else if (e.CommandName == "cmdstatus")
            {
                int      intTypeIdno = 0;
                bool     bStatus     = false;
                string[] strStatus   = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strStatus.Length > 1)
                {
                    intTypeIdno = Convert.ToInt32(strStatus[0]);
                    if (Convert.ToBoolean(strStatus[1]) == true)
                    {
                        bStatus = false;
                    }
                    else
                    {
                        bStatus = true;
                    }
                    ContainerTypeMasterDAL objclsConTypeMaster = new ContainerTypeMasterDAL();
                    int value = objclsConTypeMaster.UpdateStatus(intTypeIdno, bStatus, empIdno);
                    objclsConTypeMaster = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Status updated successfully.";
                        //ddlGroupType.Focus();
                    }
                    else
                    {
                        strMsg = "Status not updated.";
                    }
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
                }
            }
        }