Exemplo n.º 1
0
 private void btnThu_Click(object sender, EventArgs e)
 {
     if (txtTienThu.Text.Equals("") == false)
     {
         float tienNo  = (float)Convert.ToDouble(txtTienNo.Text);
         float tienThu = (float)Convert.ToDouble(txtTienThu.Text);
         if (tienThu <= tienNo)
         {
             int              id        = dsIdDL[cbDaiLy.SelectedIndex];
             DateTime         ngayThu   = dtNgayThu.Value;
             float            soTienThu = (float)Convert.ToDouble(txtTienThu.Text);
             string           cmnd      = nhanVien.Cmnd;
             DTO_PhieuThuTien pt        = new DTO_PhieuThuTien(0, ngayThu, soTienThu, id, cmnd);
             BUS_PhieuThuTien.ThemPhieuThu(pt);
             float tienNoMoi = tienNo - tienThu;
             int   kq        = BUS_DaiLy.UpdateTienNo(id, tienNoMoi);
             if (kq == 1)
             {
                 MessageBox.Show("Thu thành công");
                 txtTienNo.Text  = BUS_DaiLy.GetTienNo(id).ToString();
                 txtTienThu.Text = "";
             }
             else if (kq == 2)
             {
                 MessageBox.Show("tiền nợ vượt quá quy định");
             }
             else
             {
                 MessageBox.Show("Thu thất bại");
             }
         }
     }
 }
Exemplo n.º 2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (KiemTraDuLieu())
            {
                BUS_PhieuThuTien pt = new BUS_PhieuThuTien();

                int      madaily    = int.Parse(cbDaiLy.EditValue.ToString());
                int      manhanvien = BUS_NguoiDung.CurUser.MaNguoiDung;
                DateTime ngaythu    = DateTime.Parse(dtpNgayLap.EditValue.ToString());
                double   sotienthu  = double.Parse(txtSoTienThu.Text, NumberStyles.Currency);

                int flag = pt.LapPhieuThu(madaily, manhanvien, ngaythu, sotienthu);

                if (flag == 1)
                {
                    KhiThemPhieuThu(EventArgs.Empty);   //  https://msdn.microsoft.com/en-us/library/9aackb16(v=vs.110).aspx

                    MessageBox.Show("Bạn đã lập phiếu thu tiền thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.ResetForm();
                }
                else
                {
                    MessageBox.Show("Số tiền thu không được vượt quá số tiền đại lý đang nợ.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 3
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (txtTienThu.Text.Equals("") == false)
     {
         float tienNo  = (float)Convert.ToDouble(txtTienNo.Text);
         float tienThu = (float)Convert.ToDouble(txtTienThu.Text);
         if (tienThu <= tienNo)
         {
             int              id        = dsIdDL[cbDaiLy.SelectedIndex];
             DateTime         ngayThu   = dtNgayThu.Value;
             float            soTienThu = (float)Convert.ToDouble(txtTienThu.Text);
             string           cmnd      = nhanVien.Cmnd;
             DTO_PhieuThuTien pt        = new DTO_PhieuThuTien(0, ngayThu, soTienThu, id, cmnd);
             BUS_PhieuThuTien.ThemPhieuThu(pt);
             float tienNoMoi = tienNo - tienThu;
             BUS_DaiLy.UpdateTienNo(id, tienNoMoi);
         }
     }
 }