protected void btn_Delete_Click(object sender, EventArgs e) { var db = new BankingDBEntities(); //var acNo = Convert.ToInt32(txt_AccNo.Text); //Delete single //var acc = (from a in db.AccountDetails // where a.accNo == acNo // select a).Single(); //db.AccountDetails.Remove(acc); //db.SaveChanges(); //Delete Multiple var acc = from a in db.AccountDetails where a.accType == txt_AccType.Text select a; foreach (var item in acc) { db.AccountDetails.Remove(item); } db.SaveChanges(); { } db.SaveChanges(); }
protected void Button1_Click(object sender, EventArgs e) { BankingDBEntities dbsource = new BankingDBEntities(); var accounts = from a in dbsource.AccountDetails select a; GridView1.DataSource = accounts.ToList(); GridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { var db = new BankingDBEntities(); var data = from a in db.AccountDetails group a by a.accType into res select new { Type = res.Key, TotalBalance = res.Sum(x => x.accBalance) }; GridView1.DataSource = data.ToList(); GridView1.DataBind(); }
// POST api/<controller> public string Post(string UserName, string PassWord) { BankingDBEntities db = new BankingDBEntities(); var currentUser = (from a in db.UserInfoes where a.userName == UserName && a.password == PassWord select a).Count(); if (currentUser == 1) { return("Success"); } return("Fail"); }
protected void btn_Update_Click(object sender, EventArgs e) { var db = new BankingDBEntities(); int accNo = Convert.ToInt32(txt_AccNo.Text); var acc = (from a in db.AccountDetails where a.accNo == accNo select a).Single(); acc.accName = txt_AccName.Text; acc.accBalance = Convert.ToInt32(txt_AccBal.Text); acc.accBranch = Convert.ToInt32(txt_AccBr.Text); acc.accType = txt_AccType.Text; db.SaveChanges(); }
protected void btn_Insert_Click(object sender, EventArgs e) { var accObj = new AccountDetail() { accNo = Convert.ToInt32(txt_AccNo.Text), accName = txt_AccName.Text, accType = txt_AccType.Text, accBranch = Convert.ToInt32(txt_AccBr.Text), accBalance = Convert.ToInt32(txt_AccBal.Text) }; var db = new BankingDBEntities(); db.AccountDetails.Add(accObj); db.SaveChanges(); Response.Write("Account added successfully"); }
protected void Button2_Click(object sender, EventArgs e) { BankingDBEntities db = new BankingDBEntities(); var data = from a in db.AccountDetails join br in db.BranchInfoes on a.accBranch equals br.branchNo select new { a.accNo, a.accName, a.accType, a.accBalance, a.accBranch, br.branchCity, br.branchName }; GridView1.DataSource = data.ToList(); GridView1.DataBind(); }
public BaseRepository() { dbContext = new BankingDBEntities(); }
public Services() { dbContext = new BankingDBEntities(); }
protected void SP2_Click(object sender, EventArgs e) { var db = new BankingDBEntities(); db.updateBalance(); }
protected void SP3_Click(object sender, EventArgs e) { var db = new BankingDBEntities(); db.sp_deleteAccount(Convert.ToInt32(txt_AccNo.Text)); }