예제 #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();
    }
예제 #2
0
    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();
    }
예제 #3
0
    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();
    }
예제 #4
0
        // 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");
        }
예제 #5
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();
    }
예제 #6
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");
    }
예제 #7
0
    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();
    }
예제 #8
0
 public BaseRepository()
 {
     dbContext = new BankingDBEntities();
 }
예제 #9
0
 public Services()
 {
     dbContext = new BankingDBEntities();
 }
예제 #10
0
    protected void SP2_Click(object sender, EventArgs e)
    {
        var db = new BankingDBEntities();

        db.updateBalance();
    }
예제 #11
0
    protected void SP3_Click(object sender, EventArgs e)
    {
        var db = new BankingDBEntities();

        db.sp_deleteAccount(Convert.ToInt32(txt_AccNo.Text));
    }