public void BindData() { bobject = new UserInformation(); blogic = new BusinessLogic.BusinessLogic(); List<UserInformation> lst = blogic.ShowData(bobject); grd_show.DataSource = lst; grd_show.DataBind(); }
public void DeleteData() { bobject = new UserInformation(); blogic = new BusinessLogic.BusinessLogic(); bobject.Id = Convert.ToInt32(Request.QueryString["Id"]); blogic.DeleteData(bobject.Id); BindData(); }
public int DeleteById(int id) { RegistrationEntities mypro = new RegistrationEntities(); UserInformation uinfo = new UserInformation(); uinfo.Id = id; mypro.UserInformations.Attach(uinfo); mypro.UserInformations.Remove(uinfo); mypro.SaveChanges(); return mypro.SaveChanges(); }
public void AddData(UserInformation bobject) { RegistrationEntities mypro1 = new RegistrationEntities(); UserInformation uinfo = new UserInformation(); uinfo.Name = bobject.Name; uinfo.Email= bobject.Email; uinfo.Age = bobject.Age; uinfo.Address = bobject.Address; uinfo.Gender = bobject.Gender; uinfo.Country = bobject.Country; uinfo.PhoneNumber = bobject.PhoneNumber; uinfo.DateOfBirth = bobject.DateOfBirth; uinfo.Salary = bobject.Salary; mypro1.UserInformations.Add(uinfo); mypro1.SaveChanges(); }
public void SaveEditedData(UserInformation bobject) { RegistrationEntities mypro1 = new RegistrationEntities(); var result = mypro1.UserInformations.SingleOrDefault(x => x.Id == bobject.Id); if (result != null) { result.Name = bobject.Name ; result.Email =bobject.Email ; result.Age = bobject.Age; result.Address = bobject.Address ; result.Gender = bobject.Gender ; result.Country = bobject.Country; result.PhoneNumber =bobject.PhoneNumber; result.DateOfBirth = bobject.DateOfBirth; result.Salary = bobject.Salary; mypro1.SaveChanges(); } }
protected void BtnAdd_Click(object sender, EventArgs e) { if (BtnAdd.Text == "Add New") { bobject = new UserInformation(); blogic = new BusinessLogic.BusinessLogic(); bobject.Id = Convert.ToInt32(Request.QueryString["Id"]); bobject.Name = TxtName.Text; bobject.Email = TxtEmail.Text; bobject.Age = TxtAge.Text; bobject.Address = TxtAddress.Text; bobject.Gender = TxtGender.Text; bobject.Country = TxtCountry.Text; bobject.PhoneNumber = TxtPhone.Text; bobject.DateOfBirth = TxtDateOfBirth.Text; bobject.Salary = TxtSalary.Text; blogic.AddInfo(bobject); BindData(); ClearFeild(); } else { bobject = new UserInformation(); blogic = new BusinessLogic.BusinessLogic(); bobject.Id = Convert.ToInt32(Request.QueryString["Id"]); bobject.Name = TxtName.Text; bobject.Email = TxtEmail.Text; bobject.Age = TxtAge.Text; bobject.Address = TxtAddress.Text; bobject.Gender = TxtGender.Text; bobject.Country = TxtCountry.Text; bobject.PhoneNumber = TxtPhone.Text; bobject.DateOfBirth = TxtDateOfBirth.Text; bobject.Salary = TxtSalary.Text; blogic.SaveEdit(bobject); BindData(); ClearFeild(); BtnAdd.Text = "Add New"; } }
public List<UserInformation> ShowAllData(UserInformation bobject) { RegistrationEntities mypro1 = new RegistrationEntities(); return mypro1.UserInformations.ToList(); }
protected void Page_Load(object sender, EventArgs e) { BindData(); if(!IsPostBack) { if (Request.QueryString["Id"] != null) { bobject = new UserInformation(); blogic = new BusinessLogic.BusinessLogic(); bobject.Id = Convert.ToInt32(Request.QueryString["Id"]); UserInformation uinfo = new UserInformation(); uinfo = blogic.ShowEditData(bobject.Id); TxtName.Text = uinfo.Name; TxtEmail.Text = uinfo.Email; TxtAge.Text = uinfo.Age; TxtAddress.Text = uinfo.Address; TxtGender.Text = uinfo.Gender; TxtCountry.Text = uinfo.Country; TxtPhone.Text =( uinfo.PhoneNumber).ToString(); TxtDateOfBirth.Text = uinfo.DateOfBirth; TxtSalary.Text = uinfo.Salary; BtnAdd.Text = "Update"; } if (Request.QueryString["DId"] != null) { DeleteData(); } } }