public static bool AddNew(HDS_TypeQuestion Typ)
 {
     try
     {
         ExamSystemManagerDBEntities exMana = new ExamSystemManagerDBEntities();
         exMana.AddToHDS_TypeQuestion(Typ);
         exMana.SaveChanges();
     }
     catch (Exception e)
     {
         errMsg = e.Message;
         return false;
     }
     errMsg = "";
     return true;
 }
 public static bool Update(HDS_TypeQuestion Typ)
 {
     try
     {
         ExamSystemManagerDBEntities exMana = new ExamSystemManagerDBEntities();
         HDS_TypeQuestion obj = exMana.HDS_TypeQuestion.First(temp => temp.typ_ID == Typ.typ_ID);
         obj.Typ_Name = Typ.Typ_Name;
         obj.Typ_Description = Typ.Typ_Description;
         exMana.SaveChanges();
     }
     catch (Exception e)
     {
         errMsg = e.Message;
         return false;
     }
     errMsg = "";
     return true;
 }
 protected void gridEmp_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     int strId = Int32.Parse(e.CommandArgument.ToString());
     HDS_TypeQuestion obj = new HDS_TypeQuestion();
     switch (e.CommandName)
     {
         case "cmdEdit":
             pnlAddnew.Visible = true;
             pnlData.Visible = false;
             pnlMessage.Visible = true;
             obj = HDS_TypeQuestionBL.getById(strId);
             txtid.Text = strId.ToString();
             txtType.Text = obj.Typ_Name;
             txtdes.Text = obj.Typ_Description;
             break;
         case "cmdView":
             pnlAddnew.Visible = true;
             pnlData.Visible = false;
             pnlMessage.Visible = true;
             obj = HDS_TypeQuestionBL.getById(strId);
             txtid.Text = strId.ToString();
             txtType.Text = obj.Typ_Name;
             txtdes.Text = obj.Typ_Description;
             break;
         case "cmdDelete":
             string cusrent_user = Session["ad_user"].ToString();
             string cusrent_role = Session["ad_role"].ToString();
             if (HDS_TypeQuestionBL.Delete(strId, cusrent_role))
             {
                 ShowMessage(1, "Data deleted successfully ! ");
                 gridBind();
             }
             else
             {
                 ShowMessage(0, "Data deleted fail : " + HDS_TypeQuestionBL.errMsg);
             }
             break;
         default:
             break;
     }
 }
        protected void btnsave_Click(object sender, EventArgs e)
        {
            HDS_TypeQuestion Type = new HDS_TypeQuestion();

            Type.Typ_Name = txtType.Text;
            Type.Typ_Description = txtdes.Text;
            string strid = txtid.Text;

            if (strid.Trim() == "")
            {
                Type.typ_ID = Int32.Parse(txtid.Text);
                if (HDS_TypeQuestionBL.AddNew(Type))
                {
                    ShowMessage(1, "Data added successfully !");
                    gridBind();
                }
                else
                {
                    ShowMessage(0, "Data added fail : " + HDS_UserBL.errMsg);
                }
            }
            else
            {
                Type.typ_ID = Int32.Parse(strid);
                if (HDS_TypeQuestionBL.Update(Type))
                {
                    ShowMessage(1, "Data updated successfully ! ");
                    gridBind();
                }
                else
                {
                    ShowMessage(0, "Data updated fail : " + HDS_TypeQuestionBL.errMsg);
                }
            }

            pnlAddnew.Visible = false;
            pnlData.Visible = true;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the HDS_TypeQuestion EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToHDS_TypeQuestion(HDS_TypeQuestion hDS_TypeQuestion)
 {
     base.AddObject("HDS_TypeQuestion", hDS_TypeQuestion);
 }
 /// <summary>
 /// Create a new HDS_TypeQuestion object.
 /// </summary>
 /// <param name="typ_ID">Initial value of the typ_ID property.</param>
 public static HDS_TypeQuestion CreateHDS_TypeQuestion(global::System.Int32 typ_ID)
 {
     HDS_TypeQuestion hDS_TypeQuestion = new HDS_TypeQuestion();
     hDS_TypeQuestion.typ_ID = typ_ID;
     return hDS_TypeQuestion;
 }