Example #1
0
    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();
    }
Example #2
0
    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();
    }
Example #3
0
    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");
    }