Ejemplo 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 !");
            }
        }
Ejemplo n.º 2
0
 private void bt_OK_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "" || txb_Dongia.Text == "" || comboBox2.Text == "")
     {
         MessageBox.Show("Vui lòng nhập đầy đủ thông tin !");
     }
     else
     {
         KhuyenMaiCT s = new KhuyenMaiCT
         {
             MaKMCT   = MaKMCT,
             MaSach   = ((CBBItem)comboBox1.SelectedItem).Value,
             DonGiaKM = Convert.ToDouble(txb_Dongia.Text),
             MaKM     = ((CBBItem)comboBox2.SelectedItem).Value
         };
         BLL_KM.Instance.ExecuteDB(s);
     }
     //Dispose();
     d();
 }