Beispiel #1
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            if (IsInputErr()) return;

            using (QuanLyBanBUS bus = new QuanLyBanBUS())
            {
                BanHangDTO info = new BanHangDTO
                {
                    Msnv = ThuNgan.MsnvLogin,
                    MaSoBan = QuanLyBanBUS.Masoban,
                    SoHoaDon = Convert.ToInt32(txtSoHoaDon.Text),
                    GioRa = DateTime.Now,
                    GhiChu = txtGhiChu.Text,
                    KhuyenMai = nudThue.Value,
                    TongTien = int.Parse(lblTongTien.Text, NumberStyles.AllowThousands,
                            CultureInfo.CreateSpecificCulture("vi-VN")),
                    ChiTiet = bus.LoadHangHoa()
                };

                bus.BanHang(info);
            }

            using (QuanLyBanBUS bus = new QuanLyBanBUS())
                bus.ClearHangHoa();
            RefreshHangHoa();
        }
Beispiel #2
0
        private void btnIn_Click(object sender, EventArgs e)
        {
            if(IsInputErr()) return;

            using (QuanLyBanBUS bus = new QuanLyBanBUS())
            {
                BanHangDTO info = new BanHangDTO
                {
                    MaSoBan = QuanLyBanBUS.Masoban,
                    SoHoaDon = Convert.ToInt32(txtSoHoaDon.Text),
                    GioRa = DateTime.Now,
                    GhiChu = txtGhiChu.Text,
                    ChuaThue = int.Parse(lblExclTax.Text, NumberStyles.AllowThousands, CultureInfo.CreateSpecificCulture("vi-VN")),
                    KhuyenMai = nudThue.Value,
                    TongTien = int.Parse(lblTongTien.Text, NumberStyles.AllowThousands, CultureInfo.CreateSpecificCulture("vi-VN")),
                    ChiTiet = bus.LoadHangHoa()
                };

                new BanHangReport(info).ShowDialog();
            }
        }
Beispiel #3
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.Rows.Count == 0) return;

            string tenhanghoa = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            string soluong = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

            using (QuanLyBanBUS bus = new QuanLyBanBUS())
                bus.UpdateSoLuong(tenhanghoa, soluong);

            RefreshHangHoa();
        }
Beispiel #4
0
 private void btnHuyBan_Click(object sender, EventArgs e)
 {
     using (QuanLyBanBUS bus = new QuanLyBanBUS())
         bus.ClearHangHoa();
     RefreshHangHoa();
 }
Beispiel #5
0
        private void RefreshHangHoa()
        {
            using (QuanLyBanBUS bus = new QuanLyBanBUS())
                dataGridView1.DataSource = bus.LoadHangHoa();

            using (QuanLyBanBUS bus = new QuanLyBanBUS())
            {
                int exclTax = bus.ExclTax();
                lblExclTax.Text = exclTax.ToString("N0", CultureInfo.CreateSpecificCulture("vi-VN"));
                lblTongTien.Text = (exclTax - (exclTax * nudThue.Value * 0.01m)).ToString("N0", CultureInfo.CreateSpecificCulture("vi-VN"));
            }

            listView1.Items.OfType<ListViewItem>().Single(i => (int) i.Tag == QuanLyBanBUS.Masoban).ImageIndex = dataGridView1.Rows.Count == 0 ? 0 : 1;
        }
Beispiel #6
0
        private void QuanLyBan_Load(object sender, EventArgs e)
        {
            using (HangHoaBUS bus = new HangHoaBUS())
                dataGridView2.DataSource = bus.ListHangHoa2();

            using (KhuVucBUS bus = new KhuVucBUS())
            {
                foreach (DataRow row in bus.ListKhuVuc().Rows)
                {
                    var group = new ListViewGroup(row["TenKhuVuc"].ToString());
                    listView1.Groups.Add(group);

                    foreach (DataRow r in bus.ListBan(row["TenKhuVuc"].ToString()).Rows)
                        listView1.Items.Add(new ListViewItem(r["TenBan"].ToString(),
                            bus.IsAvailable(r["MaSoBan"].ToString()) ? 0 : 1, group)).Tag = r["MaSoBan"];

                    listView1.Items[0].Selected = true;
                }
            }

            using (QuanLyBanBUS bus = new QuanLyBanBUS())
                txtSoHoaDon.Text = bus.GetSoHoaDon().ToString();
        }
Beispiel #7
0
        private void dataGridView2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                string hanghoa = dataGridView2.CurrentRow?.Cells[0].Value.ToString();
                string dongia = dataGridView2.CurrentRow?.Cells[1].Value.ToString();

                using (QuanLyBanBUS bus = new QuanLyBanBUS())
                    bus.InsertHangHoa(hanghoa, dongia);

                RefreshHangHoa();
            }
            catch (SqlException ex)
            {
                if (ex.Number != DbConnection.MssqlEng002627) throw;
            }
        }
Beispiel #8
0
 private void dataGridView1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
 {
     using (QuanLyBanBUS bus = new QuanLyBanBUS())
         bus.DeleteHangHoa(e.Row.Cells[0].Value.ToString());
     e.Cancel = true;
     RefreshHangHoa();
 }