Exemplo n.º 1
0
        private void bt_Them_Click(object sender, EventArgs e)
        {
            if (cbb_MaSachHD.Text != "" && num_SLSachHD.Value > 0)
            {
                if (check == true)
                {
                    HoaDon hd = new HoaDon();
                    hd.ID = Convert.ToInt32(lb_ID.Text);
                    //hd.MaHD = h.MaHD + 1;

                    hd.Ngay = dtpicker_HD.Value.Date;
                    check   = false;
                    BLL_PBL3.Instance.AddHD(hd);
                    txb_MHD.Text = hd.MaHD.ToString();
                }
                Sach s = BLL_PBL3.Instance.GetSachByMS(Convert.ToInt32(cbb_MaSachHD.SelectedItem.ToString()));
                if (num_SLSachHD.Value <= s.SoLuongTon)
                {
                    HoaDonCT hdct = new HoaDonCT();
                    hdct.MaSach  = Convert.ToInt32(cbb_MaSachHD.SelectedItem.ToString());
                    hdct.SoLuong = Convert.ToInt32(num_SLSachHD.Value);
                    BLL_PBL3.Instance.DownSLT(Convert.ToInt32(cbb_MaSachHD.SelectedItem.ToString()), Convert.ToInt32(num_SLSachHD.Value));
                    hdct.DonGia = s.DonGia * hdct.SoLuong;
                    KhuyenMaiCT kmct = BLL_PBL3.Instance.GetKMCTByMS(Convert.ToInt32(cbb_MaSachHD.SelectedItem.ToString()));
                    if (kmct != null)
                    {
                        KhuyenMai km = BLL_PBL3.Instance.GetKMByKMCT(kmct);
                        if (km.TGBatDau < DateTime.Now && DateTime.Now < km.TGKetThuc)
                        {
                            hdct.GiaKM = hdct.DonGia * (1 - kmct.DonGiaKM);
                        }
                        else
                        {
                            hdct.GiaKM = hdct.DonGia;
                        }
                    }
                    else
                    {
                        hdct.GiaKM = hdct.DonGia;
                    }
                    hdct.MaHD      = Convert.ToInt32(txb_MHD.Text);
                    tt            += hdct.GiaKM;
                    txb_TCong.Text = tt.ToString();
                    BLL_PBL3.Instance.AddHDCT(hdct);
                    dtgridview_Sach.DataSource = BLL_PBL3.Instance.GetSachByMaHD(Convert.ToInt32(txb_MHD.Text));
                    setdtHD();
                }
                else
                {
                    MessageBox.Show("Vượt quá số lượng !");
                }
            }
            else
            {
                MessageBox.Show("Thông tin chưa chính xác !");
            }
        }
Exemplo n.º 2
0
        public void setGUI()
        {
            PBL3      db  = new PBL3();
            int       mkm = Convert.ToInt32(makm);
            KhuyenMai k   = db.KhuyenMai.Find(mkm);

            if (k != null)
            {
                textBox1.Text         = k.TenKM;
                dateTimePicker1.Value = k.TGBatDau;
                dateTimePicker2.Value = k.TGKetThuc;
                check = false;
            }
        }