public void BindData() { Store_Branches branches = GetBranchByID(Convert.ToInt32(Request.QueryString["BranchID"])); txtBranchAddress.Text = branches.Branch_Address; txtBranchName.Text = branches.Branch_Name; if (branches.Is_Active == true) { chkIsActive.Checked = true; } else { chkIsActive.Checked = false; } }
public Boolean SaveStoreBranch(Store_Branches storeBranch) { if (string.IsNullOrEmpty(storeBranch.Store_Branch_ID.ToString())) // New Record { using (UtilitySaleDBContext dbContext = new UtilitySaleDBContext()) { dbContext.Store_Branches.Add(storeBranch); dbContext.SaveChanges(); return(true); } } else // Update Record { using (UtilitySaleDBContext dbContext = new UtilitySaleDBContext()) { Store_Branches branches = dbContext.Store_Branches.Where(x => x.Store_Branch_ID == storeBranch.Store_Branch_ID).FirstOrDefault(); branches.Branch_Address = storeBranch.Branch_Address; branches.Branch_Name = storeBranch.Branch_Name; branches.Is_Active = storeBranch.Is_Active; dbContext.SaveChanges(); return(true); } } }