コード例 #1
0
 protected void addButton_Click(object sender, EventArgs e)
 {
     SMSentities dbcontext = new SMSentities();
     studinfo stdobj = new studinfo();
     stdobj.Id = int.Parse(IdTextBox.Text);
     stdobj.stuname = NameTextBox.Text;
     stdobj.fathername = FatherTextBox.Text;
     stdobj.mothername = MotherTextBox.Text;
     stdobj.address = AddressTextBox.Text;
     stdobj.contactNo = int.Parse(contTextBox.Text);
     stdobj.email = emailTextBox.Text;
     stdobj.DepartMent = deptTextBox.Text;
     dbcontext.studinfoes.Add(stdobj);
     dbcontext.SaveChanges();
     msgLabel.Text = "added successfully";
     //SMSentities dbcontext=new SMSentities();
     //studinfo obj =new studinfo();
     //obj.Id = int.Parse(IdTextBox.Text);
     //obj.stuname = NameTextBox.Text;
     //obj.fathername = FatherTextBox.Text;
     //obj.mothername = MotherTextBox.Text;
     //obj.address = AddressTextBox.Text;
     //obj.contactNo = int.Parse(contTextBox.Text);
     //obj.email = emailTextBox.Text;
     //obj.DepartMent = deptTextBox.Text;
     //dbcontext.studinfoes.Add(obj);
     //dbcontext.SaveChanges();
 }
コード例 #2
0
 protected void updateButton_Click(object sender, EventArgs e)
 {
     SMSentities dbcontex=new SMSentities();
     StudentManagementSystem.studinfo objStudinfo=new studinfo();
     //try
     {
         int id1 = int.Parse(IdTextBox.Text);
         objStudinfo = dbcontex.studinfoes.FirstOrDefault(xx => xx.Id==id1);
         objStudinfo.DepartMent = deptTextBox.Text;
         objStudinfo.address = AddressTextBox.Text;
         dbcontex.SaveChanges();
         msgLabel.Text = "update successfully";
     }
     //catch (Exception e1)
     {
         msgLabel.Text = "not found id";
         //throw;
     }
 }
コード例 #3
0
        protected void delateButton_Click(object sender, EventArgs e)
        {
            SMSentities dbcontext=new SMSentities();
            StudentManagementSystem.studinfo sobject = new studinfo();
               // try
            {
                int id1 = int.Parse(IdTextBox.Text);
                var sobj = dbcontext.studinfoes.FirstOrDefault(xx => xx.Id == id1);
                dbcontext.studinfoes.Remove(sobj);
                dbcontext.SaveChanges();
                msgLabel.Text = "successfully delated";

            }
               // catch (Exception e1)
            {

                msgLabel.Text = "not found";
            }

            {

            }
        }