Пример #1
0
        void LoadChiNhanh()
        {
            DataTable listChiNhanh = XuLyDuLieu.docDuLieu("SELECT TenCN FROM dbo.CHI_NHANH");

            cbChiNhanh.DataSource    = listChiNhanh;
            cbChiNhanh.DisplayMember = "TenCN";
        }
Пример #2
0
        void Form_Load()
        {
            dt = XuLyDuLieu.docDuLieu("Select N.HoTen, C.TenCN, C.MaCN, N.MaNV From NHAN_VIEN N,CHI_NHANH C Where N.MaCN = C.MaCN and TaiKhoan = '" + TaiKhoan + "'");
            foreach (DataRow dr in dt.Rows)
            {
                txtTen.Text     = dr[0].ToString();
                HoaDon.HoTenNV  = dr[0].ToString();
                lbChiNhanh.Text = dr[1].ToString();
                MaCN            = dr[2].ToString();
                MaNV            = dr[3].ToString();
            }
            int M = 0;

            dt = XuLyDuLieu.docDuLieu("Select * From DAT_HANG Where MaBan = " + MaBan);
            foreach (DataRow dr in dt.Rows)
            {
                M = int.Parse(dr[0].ToString());
            }
            Ma = M;
            Load_Ban();
            dtDonHang                     = XuLyDuLieu.docDuLieu("Select D.MaDonHang, D.MaDH, M.TenMA, M.DonGia, D.SoLuong, M.DonGia * D.SoLuong as ThanhTien From DON_HANG D, MON_AN M, DAT_HANG DH Where D.MaDH = DH.MaDH and D.MaMA = M.MaMA and MaBan = " + MaBan);
            dv                            = new DataView(dtDonHang);
            dgvGioHang.DataSource         = dv;
            dgvGioHang.Columns[0].Visible = false;
            dgvGioHang.Columns[1].Visible = false;

            dsChiNhanh             = XuLyDuLieu.docDuLieu("Select * From Chi_Nhanh");
            ds                     = new DataView(dsChiNhanh);
            dgvChiNhanh.DataSource = ds;
        }
Пример #3
0
        private void btThem_Click(object sender, EventArgs e)
        {
            pnMonAn.Controls.Clear();
            int       i  = 1;
            int       j  = 1;
            int       z  = 1;
            int       y  = 1;
            DataTable dt = XuLyDuLieu.docDuLieu("Select M.* From MON_AN M,CHI_NHANH C Where M.MaCN = C.MaCN and M.Loai like N'Them' and C.TenCN like N'" + lbChiNhanh.Text + "'");

            foreach (DataRow dr in dt.Rows)
            {
                Button N = new Button();
                N.Width     = 60;
                N.Height    = 60;
                N.Top       = 10 * z;
                N.Left      = 10 * i;
                N.BackColor = Color.SkyBlue;
                //N.Name = "BT" + i;
                N.Tag  = string.Format("{0}", dr[0].ToString());
                N.Text = dr[1].ToString();
                this.pnMonAn.Controls.Add(N);
                N.Click += new EventHandler(N_Click);
                i       += 6;
                j++;
                if (j == 8 * y)
                {
                    y++;
                    i = 1;
                    j = 1;
                    z = 7;
                }
            }
        }
Пример #4
0
        void Load_Ban()
        {
            dgvDSBan.Controls.Clear();
            int i = 1;
            int j = 1;
            int z = 1;
            int y = 1;

            dt = XuLyDuLieu.docDuLieu("Select * From BAN Where MaCN = '" + MaCN + "'");
            foreach (DataRow dr in dt.Rows)
            {
                Button N = new Button();
                N.Width     = 60;
                N.Height    = 60;
                N.Top       = 10 * z;
                N.Left      = 10 * i;
                N.BackColor = Color.Aqua;
                //N.Name = "BT" + i;
                N.Tag  = string.Format("{0}", dr[0].ToString());
                N.Text = dr[1].ToString();
                this.dgvDSBan.Controls.Add(N);
                N.Click       += new EventHandler(Ban_Click);
                N.DialogResult = DialogResult.OK;
                i += 6;
                j++;
                if (j == 7 * y)
                {
                    y++;
                    i = 1;
                    j = 1;
                    z = 7;
                }
            }
        }
Пример #5
0
        private void btXacNhan_Click(object sender, EventArgs e)
        {
            MaQL M = new MaQL();

            M.ShowDialog();
            if (M.DialogResult == DialogResult.OK)
            {
                dt = XuLyDuLieu.docDuLieu("Select MaCN From CHI_NHANH Where TenCN like N'" + txtChiNhanh.Text + "'");
                foreach (DataRow dr in dt.Rows)
                {
                    Ma = dr[0].ToString();
                }

                // Store
                SqlConnection con = new SqlConnection(XuLyDuLieu.connectionString);
                con.Open();
                SqlCommand cmd = new SqlCommand("DangKy", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@MaCN", SqlDbType.Char));
                cmd.Parameters.Add(new SqlParameter("@HoTen", SqlDbType.NVarChar));
                cmd.Parameters.Add(new SqlParameter("@GioiTinh", SqlDbType.Char));
                cmd.Parameters.Add(new SqlParameter("@DienThoai", SqlDbType.Int));
                cmd.Parameters.Add(new SqlParameter("@DiaChi", SqlDbType.NVarChar));
                cmd.Parameters.Add(new SqlParameter("@NgaySinh", SqlDbType.DateTime));
                cmd.Parameters.Add(new SqlParameter("@TaiKhoan", SqlDbType.Char));
                cmd.Parameters.Add(new SqlParameter("@MatKhau", SqlDbType.Char));

                cmd.Parameters["@MaCN"].Value  = Ma;
                cmd.Parameters["@HoTen"].Value = txtHoTen.Text;
                if (cbNam.CheckState == CheckState.Checked)
                {
                    cmd.Parameters["@GioiTinh"].Value = cbNam.Text;
                }
                else
                {
                    cmd.Parameters["@GioiTinh"].Value = cbNu.Text;
                }
                cmd.Parameters["@DienThoai"].Value = txtSDT.Text;
                cmd.Parameters["@DiaChi"].Value    = txtDiaChi.Text;
                cmd.Parameters["@NgaySinh"].Value  = txtNgaySinh.Text;
                cmd.Parameters["@TaiKhoan"].Value  = txtTaiKhoan.Text;
                cmd.Parameters["@MatKhau"].Value   = txtMatKhau.Text;

                cmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
                cmd.ExecuteNonQuery();
                con.Close();

                int ReturnValueInt = Convert.ToInt32(cmd.Parameters["RETURN_VALUE"].Value);
                if (ReturnValueInt == 1)
                {
                    MessageBox.Show("Đăng ký thành công");
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Tài khoản đã tồn tại");
                }
            }
        }
Пример #6
0
        void LoadMonAnTheoDanhMuc(string tenDanhMuc)
        {
            DataTable listFood = XuLyDuLieu.docDuLieu(string.Format("SELECT M.TenMA FROM dbo.MON_AN M, dbo.CHI_NHANH C WHERE M.MaCN = C.MaCN and M.Loai = '{0}' AND C.TenCN like N'{1}'", tenDanhMuc, cbChiNhanh.Text));

            cbMonAn.DataSource    = listFood;
            cbMonAn.DisplayMember = "TenMA";
            //cbMonAn.ValueMember = "Tên Món";
        }
Пример #7
0
 private void DangKy_Load(object sender, EventArgs e)
 {
     dt = XuLyDuLieu.docDuLieu("Select TenCN From CHI_NHANH");
     foreach (DataRow dr in dt.Rows)
     {
         txtChiNhanh.Items.Add(dr[0].ToString());
     }
 }
Пример #8
0
 private void GhiChu_Load(object sender, EventArgs e)
 {
     dt = XuLyDuLieu.docDuLieu("Select GhiChu From DAT_HANG Where MaDH = " + UDQL.Ma + "and MaBan = " + UDQL.MaBan);
     foreach (DataRow dr in dt.Rows)
     {
         txtGhiChu.Text = dr[0].ToString();
     }
 }
Пример #9
0
        private void LoadDSBan(string MaCN)
        {
            string str = "Select * From BAN Where MaCN like N'%" + MaCN.ToString() + "'";

            dsBan                     = XuLyDuLieu.docDuLieu(str);
            dgvBan.DataSource         = dsBan;
            dgvBan.Columns[0].Visible = false;
            dgvBan.Columns[2].Visible = false;
        }
Пример #10
0
        public void loadDSMM()
        {
            string str = "Select * from MON_AN where Loai = 'Nuoc' and MaCN like N'%" + cbbChiNhanh.SelectedValue + "'";

            dsMM = XuLyDuLieu.docDuLieu(str);
            dgvNuoc.DataSource         = dsMM;
            dgvNuoc.Columns[0].Visible = false;
            dgvNuoc.Columns[5].Visible = false;
        }
Пример #11
0
        private void loadDSChiNhanh()
        {
            string str = "select * from CHI_NHANH";

            dsCN = XuLyDuLieu.docDuLieu(str);
            cbbChiNhanh.DataSource    = dsCN;
            cbbChiNhanh.ValueMember   = "MaCN";
            cbbChiNhanh.DisplayMember = "TenCN";
        }
Пример #12
0
 private void btSua_Click(object sender, EventArgs e)
 {
     if (dgvKhachHang.SelectedRows.Count > 0)
     {
         DataRow cn = ((DataRowView)dgvKhachHang.SelectedRows[0].DataBoundItem).Row;
         XuLyDuLieu.ghiDuLieu("KHACH_HANG", dt);
     }
     Form_Load();
 }
Пример #13
0
 private void dgvBan_SelectionChanged(object sender, EventArgs e)
 {
     if (dgvBan.SelectedRows.Count > 0)
     {
         DataRow dr = ((DataRowView)dgvBan.SelectedRows[0].DataBoundItem).Row;
         this.txtTenBan.Text   = dr[1].ToString();
         this.cbTrangThai.Text = dr[3].ToString();
         XuLyDuLieu.ghiDuLieu("CHI_NHANH", dsBan);
     }
 }
Пример #14
0
 private void cbbChiNhanh_SelectedIndexChanged(object sender, EventArgs e)
 {
     dt = XuLyDuLieu.docDuLieu("Select C.SoDienT, N.HoTen, B.SoLuongDH, B.TongDT, B.Ngay From BAO_CAO B, NHAN_VIEN N, CHI_NHANH C Where B.MaNV = N.MaNV and B.MaCN = C.MaCN and C.TenCN like N'" + cbbChiNhanh.Text + "'");
     dgvThongKe.DataSource         = dt;
     dgvThongKe.Columns[0].Visible = false;
     foreach (DataRow dr in dt.Rows)
     {
         lbSDT.Text = dr[0].ToString();
     }
 }
Пример #15
0
 private void btSuaBan_Click_1(object sender, EventArgs e)
 {
     if (dgvBan.SelectedRows.Count > 0)
     {
         DataRow dr = ((DataRowView)dgvBan.SelectedRows[0].DataBoundItem).Row;
         dr[1] = this.txtTenBan.Text;
         dr[3] = this.cbTrangThai.Text;
         XuLyDuLieu.ghiDuLieu("BAN", dsBan);
     }
     Form_Load();
 }
Пример #16
0
        private void ThongKe_Load(object sender, EventArgs e)
        {
            dt = XuLyDuLieu.docDuLieu("Select TenCN From CHI_NHANH");
            foreach (DataRow dr in dt.Rows)
            {
                cbbChiNhanh.Items.Add(dr[0].ToString());
            }

            dt = XuLyDuLieu.docDuLieu("Select N.HoTen, C.TenCN, B.SoLuongDH, B.TongDT, B.Ngay From BAO_CAO B, NHAN_VIEN N, CHI_NHANH C Where B.MaNV = N.MaNV and B.MaCN = C.MaCN");
            dgvThongKe.DataSource = dt;
        }
Пример #17
0
        private void btThemBan_Click(object sender, EventArgs e)
        {
            DataRow cn = ((DataRowView)dgvChiNhanh.SelectedRows[0].DataBoundItem).Row;
            DataRow dr = dsBan.NewRow();

            dr[1] = this.txtTenBan.Text;
            dr[2] = cn[0].ToString();
            dr[3] = this.cbTrangThai.Text;
            dsBan.Rows.Add(dr);
            XuLyDuLieu.ghiDuLieu("BAN", dsBan);
            Form_Load();
        }
Пример #18
0
        private void btSua_Click(object sender, EventArgs e)
        {
            if (dgvNuoc.SelectedRows.Count > 0)
            {
                DataRow cn = ((DataRowView)dgvNuoc.SelectedRows[0].DataBoundItem).Row;
                cn[1] = txtTen.Text;
                cn[2] = txtDonGia.Text;
                cn[3] = txtThongTin.Text;

                XuLyDuLieu.ghiDuLieu("MON_AN", dsMM);
            }
        }
Пример #19
0
        private void btInHoaDon_Click(object sender, EventArgs e)
        {
            dt = XuLyDuLieu.docDuLieu("Select * From HOA_DON");
            DataRow dr = dt.NewRow();

            dr[0] = Ma + 1;
            dr[1] = UDQL.Ma;
            dr[2] = TongTien;
            dt.Rows.Add(dr);
            XuLyDuLieu.ghiDuLieu("HOA_DON", dt);
            this.Hide();
        }
Пример #20
0
        private void btXacNhan_Click(object sender, EventArgs e)
        {
            dt = XuLyDuLieu.docDuLieu("Select * From KHACH_HANG");
            DataRow dr = dt.NewRow();

            dr[2] = txtTenKH.Text;
            dr[1] = txtSDTKH.Text;
            dr[3] = txtDiaChiKH.Text;
            dt.Rows.Add(dr);
            XuLyDuLieu.ghiDuLieu("KHACH_HANG", dt);
            this.Hide();
        }
Пример #21
0
        private void N_Click(object sender, EventArgs e)
        {
            dtDonHang = XuLyDuLieu.docDuLieu("Select * From DON_HANG");
            DataRow dr = dtDonHang.NewRow();

            dr[1] = Ma;
            dr[2] = ((Button)sender).Tag;
            dr[3] = 1;
            dtDonHang.Rows.Add(dr);
            XuLyDuLieu.ghiDuLieu("DON_HANG", dtDonHang);
            Form_Load();
        }
Пример #22
0
        private void btGuiDonHang_Click(object sender, EventArgs e)
        {
            DataTable dt = XuLyDuLieu.docDuLieu("Select * From GIAO_HANG");
            DataRow   dr = dt.NewRow();

            dr[1] = DateTime.Now;
            dr[2] = MaDH;
            dt.Rows.Add(dr);
            XuLyDuLieu.ghiDuLieu("GIAO_HANG", dt);
            MaKH = string.Empty;
            Form_Load();
            btnThemMon.Enabled = false;
            btTaoMoi.Enabled   = false;
        }
Пример #23
0
 private void btXoa_Click(object sender, EventArgs e)
 {
     if (dgvNuoc.SelectedRows.Count > 0)
     {
         DataRow      cn      = ((DataRowView)dgvNuoc.SelectedRows[0].DataBoundItem).Row;
         String       noidung = String.Format("Anh/chi co muon xoa món '{0}' khong?", cn[1]);
         DialogResult dr      = MessageBox.Show(noidung, "Thong bao", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (dr == DialogResult.Yes)
         {
             cn.Delete();
             XuLyDuLieu.ghiDuLieu("MON_AN", dsMM);
         }
     }
 }
Пример #24
0
        private void btThemCN_Click(object sender, EventArgs e)
        {
            DataRow dr = dsChiNhanh.NewRow();

            dr[0] = this.txtMaCN.Text;
            dr[1] = this.txtTenCN.Text;
            dr[2] = this.txtSoLuongBanCN.Text;
            dr[3] = this.txtDiaChiCN.Text;
            dr[4] = this.txtSDTCN.Text;
            dr[5] = this.txtQuanLyCN.Text;
            dsChiNhanh.Rows.Add(dr);
            XuLyDuLieu.ghiDuLieu("CHI_NHANH", dsChiNhanh);
            Form_Load();
        }
Пример #25
0
 private void btSuaCN_Click(object sender, EventArgs e)
 {
     if (dgvChiNhanh.SelectedRows.Count > 0)
     {
         DataRow dr = ((DataRowView)dgvChiNhanh.SelectedRows[0].DataBoundItem).Row;
         dr[0] = this.txtMaCN.Text;
         dr[1] = this.txtTenCN.Text;
         dr[2] = this.txtSoLuongBanCN.Text;
         dr[3] = this.txtDiaChiCN.Text;
         dr[4] = this.txtSDTCN.Text;
         dr[5] = this.txtQuanLyCN.Text;
         XuLyDuLieu.ghiDuLieu("CHI_NHANH", dsChiNhanh);
     }
     Load_Ban();
 }
Пример #26
0
        private void btMoi_Click(object sender, EventArgs e)
        {
            dt = XuLyDuLieu.docDuLieu("Select * From DAT_HANG");
            DataRow dr = dt.NewRow();

            dr[1] = MaNV;
            dr[2] = DBNull.Value;
            dr[3] = MaCN;
            dr[4] = MaBan;
            dr[5] = DateTime.Now;
            dr[6] = DBNull.Value;
            dt.Rows.Add(dr);
            XuLyDuLieu.ghiDuLieu("DAT_HANG", dt);
            Form_Load();
            pnMonAn.Enabled = true;
        }
Пример #27
0
        private void TongDai_Load(object sender, EventArgs e)
        {
            btnThemMon.Enabled = false;
            btTaoMoi.Enabled   = false;
            DataTable db = XuLyDuLieu.docDuLieu("Select * From DAT_HANG");

            foreach (DataRow r in db.Rows)
            {
                MaDH = r[0].ToString();
            }
            DataTable dT = XuLyDuLieu.docDuLieu("Select * From KHACH_HANG");

            foreach (DataRow r in dT.Rows)
            {
                MaKH = r[0].ToString();
            }
            Form_Load();
        }
Пример #28
0
 private void ProFile_Load(object sender, EventArgs e)
 {
     dt = XuLyDuLieu.docDuLieu("Select * From NHAN_VIEN Where TaiKhoan = '" + UDQL.TaiKhoan + "'");
     foreach (DataRow dr in dt.Rows)
     {
         txtHoTen.Text    = dr[2].ToString();
         txtDiaChi.Text   = dr[5].ToString();
         txtSDT.Text      = dr[4].ToString();
         txtTaiKhoan.Text = dr[7].ToString();
         txtMatKhau.Text  = dr[8].ToString();
         if (dr[3].ToString() == "Nam")
         {
             cbNam.CheckState = CheckState.Checked;
         }
         else
         {
             cbNu.CheckState = CheckState.Checked;
         }
     }
 }
Пример #29
0
        private void btTaoMoi_Click(object sender, EventArgs e)
        {
            DataTable dt = XuLyDuLieu.docDuLieu("Select * From DAT_HANG");
            DataRow   dr = dt.NewRow();

            dr[1] = UDQL.MaNV;
            dr[2] = dsKhachHang.MaKH;
            dr[3] = DBNull.Value;
            dr[4] = DBNull.Value;
            dr[5] = DateTime.Now;
            dr[6] = DBNull.Value;
            dt.Rows.Add(dr);
            XuLyDuLieu.ghiDuLieu("DAT_HANG", dt);

            DataTable db = XuLyDuLieu.docDuLieu("Select * From DAT_HANG Where MaKH = '" + dsKhachHang.MaKH + "'");

            foreach (DataRow r in db.Rows)
            {
                MaDH = r[0].ToString();
            }
            Form_Load();
        }
Пример #30
0
        void Form_Load()
        {
            DataTable db = XuLyDuLieu.docDuLieu("Select * From DAT_HANG Where MaKH = '" + dsKhachHang.MaKH + "'");

            foreach (DataRow r in db.Rows)
            {
                MaDH = r[0].ToString();
            }
            Tong = 0;
            DataTable dt = XuLyDuLieu.docDuLieu("Select D.MaDonHang, D.MaDH, M.TenMA, M.DonGia, D.SoLuong, M.DonGia * D.SoLuong as ThanhTien From DON_HANG D, MON_AN M, DAT_HANG DH Where D.MaDH = DH.MaDH and D.MaMA = M.MaMA and DH.MaDH = '" + MaDH + "'");

            foreach (DataRow dr in dt.Rows)
            {
                Tong += int.Parse(dr[5].ToString());
            }
            txtTongTien.Text = Tong.ToString();
            DataTable dtDonHang = XuLyDuLieu.docDuLieu("Select D.MaDonHang, D.MaDH, M.TenMA, M.DonGia, D.SoLuong, M.DonGia * D.SoLuong as ThanhTien From DON_HANG D, MON_AN M, DAT_HANG DH Where D.MaDH = DH.MaDH and D.MaMA = M.MaMA and DH.MaDH = '" + MaDH + "'");

            dgvGioHang.DataSource         = dtDonHang;
            dgvGioHang.Columns[0].Visible = false;
            dgvGioHang.Columns[1].Visible = false;
        }