Example #1
0
        protected void btnCreateNews_Click(object sender, EventArgs e)
        {
            TestOnlineDataContext db = new TestOnlineDataContext();

            if (txtAcountID.Text == "" || txtAddress.Text == "" || txtFullName.Text == "" || txtPass.Text == "" || ddlDay.SelectedIndex == 0 || ddlMonth.SelectedIndex == 0 || ddlYear.SelectedIndex == 0)
            {
                lblThongBao.Text    = "Bạn chưa nhập đầy đủ thông tin";
                lblThongBao.Visible = true;
            }
            else
            {
                if (TestCodeAcountID(txtAcountID.Text) == false)
                {
                    tblAcount tbl = new tblAcount();
                    tbl.AcountID = txtAcountID.Text;
                    tbl.Address  = txtAddress.Text;
                    tbl.Brithday = ddlDay.Text + "/" + ddlMonth.Text + "/" + ddlYear.Text;
                    tbl.FullName = txtFullName.Text;
                    tbl.Pass     = txtPass.Text;
                    db.tblAcounts.InsertOnSubmit(tbl);
                    db.SubmitChanges();
                    lblThongBao.Text    = "Bạn đã nhập thành công";
                    lblThongBao.Visible = true;
                    LoadGridView();
                }
            }
        }
Example #2
0
        protected void btnEdit1_Click(object sender, EventArgs e)
        {
            TestOnlineDataContext db = new TestOnlineDataContext();

            if (txtAcountID.Text == "" || txtAddress.Text == "" || txtFullName.Text == "" || txtPass.Text == "" || ddlDay.SelectedIndex == 0 || ddlMonth.SelectedIndex == 0 || ddlYear.SelectedIndex == 0)
            {
                lblThongBao.Text    = "Bạn chưa nhập đầy đủ thông tin";
                lblThongBao.Visible = true;
            }
            else
            {
                tblAcount tbl = db.tblAcounts.SingleOrDefault(c => c.AcountID.ToString().ToLower().Trim() == txtAcountID.Text.ToLower().Trim());
                if (tbl != null)
                {
                    tbl.AcountID = txtAcountID.Text;
                    tbl.Address  = txtAddress.Text;
                    tbl.Brithday = ddlDay.Text + "/" + ddlMonth.Text + "/" + ddlYear.Text;
                    tbl.FullName = txtFullName.Text;
                    tbl.Pass     = txtPass.Text;
                    db.SubmitChanges();
                    lblThongBao.Text    = "Bạn đã sửa thành công";
                    lblThongBao.Visible = true;
                    LoadGridView();
                }
            }
        }
Example #3
0
    public bool takemoney(string code, string money)
    {
        tblAcount account = (from x in ctx.tblAcounts where x._code == code select x).First();

        account._current = account._current - long.Parse(money);
        ctx.SubmitChanges();
        return(true);
    }
Example #4
0
    public bool CheckLogin(string user, string pass)
    {
        tblAcount acc = (from a in ctx.tblAcounts
                         where a._code == user && a._pass == pass
                         select a).SingleOrDefault();

        return(acc != null);
    }
Example #5
0
    public bool transfer(string code, string code2, string money)
    {
        tblAcount account = (from x in ctx.tblAcounts where x._code == code select x).First();

        account._current = account._current - long.Parse(money);
        ctx.SubmitChanges();
        tblAcount tblaccount2 = (from x in ctx.tblAcounts where x._code == code2 select x).First();

        tblaccount2._current = tblaccount2._current + long.Parse(money);
        ctx.SubmitChanges();
        return(true);
    }
Example #6
0
    public String getAccount(string code)
    {
        tblAcount account = (from x in ctx.tblAcounts where x._code == code select x).First();
        Account   acc     = new Account();

        acc.code    = account._code;
        acc.pass    = account._pass;
        acc.name    = account._name;
        acc.current = (long)account._current;

        return(acc.ToString());
    }
Example #7
0
        /// <summary>
        /// Kiểm tra mã tài khoản có trùng hay không
        /// </summary>
        bool TestCodeAcountID(string acountID)
        {
            TestOnlineDataContext db  = new TestOnlineDataContext();
            tblAcount             tbl = db.tblAcounts.SingleOrDefault(c => c.AcountID.ToString().Trim().ToLower() == acountID.ToLower().Trim());

            if (tbl != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            TestOnlineDataContext db  = new TestOnlineDataContext();
            tblAcount             tbl = db.tblAcounts.SingleOrDefault(c => c.AcountID.Trim().ToLower() == txtUserName.Text.Trim().ToLower() && c.Pass == txtPass.Text);

            if (tbl != null)
            {
                Session.Contents["loginManager"] = "1";
                Response.Redirect("HomeManagement.aspx");
            }
            else
            {
                lblError.Text = "Tài khoản hoặc mật khẩu không đúng";
            }
        }
Example #9
0
        protected void grvManager_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            acountID_ = e.CommandArgument.ToString();
            TestOnlineDataContext db = new TestOnlineDataContext();

            //Xóa 1 hàng trong gridview
            if (e.CommandName == "Delete")
            {
                tblAcount doc = db.tblAcounts.SingleOrDefault(d => d.AcountID.ToString().Trim() == e.CommandArgument.ToString().Trim());
                if (doc != null)
                {
                    db.tblAcounts.DeleteOnSubmit(doc);
                    db.SubmitChanges();
                    LoadGridView();
                    lblThongBao.Visible = true;
                    lblThongBao.Text    = "Bạn đã xóa thành công";
                    Resfresh();
                }
            }
            // Chọn hàng muốn sửa
            if (e.CommandName == "Edit")
            {
                tblAcount doc = db.tblAcounts.SingleOrDefault(d => d.AcountID.ToString().Trim() == e.CommandArgument.ToString().Trim());
                if (doc != null)
                {
                    txtAcountID.Text = doc.AcountID;
                    txtAddress.Text  = doc.Address;
                    txtFullName.Text = doc.FullName;
                    txtPass.Text     = doc.Pass;
                    string [] mang = doc.Brithday.Split('/');
                    ddlDay.Text          = mang[0];
                    ddlMonth.Text        = mang[1];
                    ddlYear.Text         = mang[2];
                    txtAcountID.ReadOnly = true;
                    btnCreate.Enabled    = false;
                    btnEdit1.Enabled     = true;
                    lblThongBao.Text     = "";
                }
            }
        }
Example #10
0
        protected void btnDeleteAll_Click(object sender, EventArgs e)
        {
            int record = 0;
            TestOnlineDataContext db = new TestOnlineDataContext();

            foreach (GridViewRow row in grvManager.Rows)
            {
                CheckBox chk = (CheckBox)row.FindControl("chkSelect");
                if (chk != null)
                {
                    if (chk.Checked)
                    {
                        LinkButton link = (LinkButton)row.FindControl("btnSua");
                        tblAcount  at   = db.tblAcounts.SingleOrDefault(c => c.AcountID.ToString() == link.CommandArgument.ToString());
                        if (at != null)
                        {
                            // delete file when xoa

                            db.tblAcounts.DeleteOnSubmit(at);
                            db.SubmitChanges();
                            record++;
                        }
                    }
                }
            }
            if (record > 0)
            {
                LoadGridView();
                // when will announciment

                lblThongBao.Text    = "Bạn vừa xóa thành công " + record.ToString() + " bản ghi!";
                lblThongBao.Visible = true;
            }
            else
            {
                lblThongBao.Text    = "Không có bản ghi nào được chọn !";
                lblThongBao.Visible = true;
            }
            btnEdit1.Enabled = false;
        }
 partial void DeletetblAcount(tblAcount instance);
 partial void UpdatetblAcount(tblAcount instance);
 partial void InserttblAcount(tblAcount instance);