Пример #1
0
        private void btn_hoantat_Click(object sender, EventArgs e)
        {
            DONDATHANG dh = new DONDATHANG();

            dh.IDNCC      = int.Parse(cbbncc.SelectedValue.ToString());
            dh.NGAYDAT    = DateTime.Today;
            dh.IDNGUOIDAT = FormMain.currentuser;
            dh.TONGCONG   = int.Parse(txt_tongtien.Text.ToString());
            dh.TRANGTHAI  = false;
            DONDATHANGBUS        bus   = new DONDATHANGBUS();
            List <CT_DONDATHANG> ctddh = new List <CT_DONDATHANG>();

            foreach (DataGridViewRow row in dgvphieudat.Rows)
            {
                CT_DONDATHANG ct = new CT_DONDATHANG();
                ct.IDSANPHAM = int.Parse(row.Tag.ToString());
                ct.SL        = int.Parse(row.Cells[1].Value.ToString());
                ct.DONGIA    = int.Parse(row.Cells[2].Value.ToString());
                ct.TONG      = int.Parse(row.Cells[3].Value.ToString());
                ct.SL_NHAP   = 0;
                ctddh.Add(ct);
            }
            if (bus.Insert(dh, ctddh))
            {
                MessageBox.Show("đã lưu đơn hàng");
            }
            else
            {
                MessageBox.Show(DONDATHANGDAO.error_message);
            }
        }
Пример #2
0
        private void donnhapgv_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int              ma  = int.Parse(donnhapgv[0, e.RowIndex].Value.ToString());
            DONDATHANGBUS    bus = new DONDATHANGBUS();
            List <ViewCTDDH> ct  = bus.GetList(ma);

            nhapkhogv.DataSource = ct;
            nhapkhogv.Columns["TENSP"].HeaderText    = "Tên SP";
            nhapkhogv.Columns["SL_Nhap"].HeaderText  = "SL Nhập";
            nhapkhogv.Columns["SL"].HeaderText       = "SL Đặt";
            nhapkhogv.Columns["DonGia"].HeaderText   = "Đơn giá";
            nhapkhogv.Columns["TongTien"].HeaderText = "Tổng";
            nhapkhogv.Columns["MASP"].Visible        = false;
        }
Пример #3
0
        private void btn_hoantat_Click(object sender, EventArgs e)
        {
            int index    = donnhapgv.CurrentCell.RowIndex;
            int madh     = int.Parse(donnhapgv[0, index].Value.ToString());
            int index_ct = nhapkhogv.CurrentCell.RowIndex;
            List <CT_DONDATHANG> ctddh = new List <CT_DONDATHANG>();

            foreach (DataGridViewRow row in nhapkhogv.Rows)
            {
                CT_DONDATHANG ct = new CT_DONDATHANG();
                ct.IDDONDAT  = madh;
                ct.IDSANPHAM = int.Parse(nhapkhogv[5, index_ct].Value.ToString());
                ct.SL_NHAP   = int.Parse(nhapkhogv[1, index_ct].Value.ToString());
                ctddh.Add(ct);
            }
            DONDATHANGBUS bus = new DONDATHANGBUS();

            if (bus.Update(madh, ctddh))
            {
                MessageBox.Show("Cập nhật thành công!");
                btn_laydulieu.PerformClick();
            }
        }
Пример #4
0
        private void btn_laydulieu_Click(object sender, EventArgs e)
        {
            if (donnhapgv.Rows.Count > 0)
            {
                donnhapgv.Rows.Clear();
            }

            DONDATHANGBUS     bus     = new DONDATHANGBUS();
            List <DONDATHANG> lst_ddh = bus.GetList();

            foreach (DONDATHANG dh in lst_ddh)
            {
                if (dh.TRANGTHAI == false)
                {
                    donnhapgv.Rows.Add(dh.ID, dh.NGAYDAT, dh.IDNCC, dh.IDNGUOIDAT, dh.TONGCONG, "Chưa Xử Lý");
                    donnhapgv[5, donnhapgv.Rows.Count - 1].Style.BackColor = Color.IndianRed;
                }
                else
                {
                    donnhapgv.Rows.Add(dh.ID, dh.NGAYDAT, dh.IDNCC, dh.IDNGUOIDAT, dh.TONGCONG, "Đã Xử Lý");
                    donnhapgv[5, donnhapgv.Rows.Count - 1].Style.BackColor = Color.Green;
                }
            }
        }