Example #1
0
 private void grvctdspc_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         PrintPreView printPreView = new PrintPreView(grvrootdspc.GetRowCellValue(grvrootdspc.FocusedRowHandle, "TenNCC").ToString(), "",
                                                      grvrootdspc.GetRowCellValue(grvrootdspc.FocusedRowHandle, "GhiChu").ToString(), float.Parse(grvrootdspc.GetRowCellValue(grvrootdspc.FocusedRowHandle, "TongTien").ToString()), DocSoThanhChu.So_chu(Double.Parse(grvrootdspc.GetRowCellValue(grvrootdspc.FocusedRowHandle, "TongTien").ToString())), grvrootdspc.GetRowCellValue(grvrootdspc.FocusedRowHandle, "MaPNH").ToString(), grvrootdspc.GetRowCellValue(grvrootdspc.FocusedRowHandle, "MaPC").ToString(), "", 0);
         printPreView.ShowDialog();
     }
     catch { }
 }
 private void btnin_Click(object sender, EventArgs e)
 {
     try
     {
         PrintPreView printPreView = new PrintPreView(grvdspt.GetRowCellValue(grvdspt.FocusedRowHandle, "TenKH").ToString(), "",
                                                      grvdspt.GetRowCellValue(grvdspt.FocusedRowHandle, "GhiChu").ToString(), float.Parse(grvdspt.GetRowCellValue(grvdspt.FocusedRowHandle, "TongTien").ToString()), DocSoThanhChu.So_chu(Double.Parse(grvdspt.GetRowCellValue(grvdspt.FocusedRowHandle, "TongTien").ToString())), grvdspt.GetRowCellValue(grvdspt.FocusedRowHandle, "MaPBH").ToString(), grvdspt.GetRowCellValue(grvdspt.FocusedRowHandle, "MaPT").ToString(), "", 1);
         printPreView.ShowDialog();
     }
     catch { }
 }
 private void btnluu_Click(object sender, EventArgs e)
 {
     if (vaitro == 0)
     {
         if (PhieuChiTheoChungTuBUS.KiemTraMaPCDaTonTai(txtphieuchi.Text) < 1)
         {
             if (PhieuChiTheoChungTuBUS.LuuThongTinPhieuChi(txtphieuchi.Text, maphieu, txtngay_pc.EditValue.ToString(), mancc, txtkhachhang.Text, float.Parse(txtsotien.Text.ToString()), txtghichu.Text) > 0)
             {
                 whenInsertSuccessed();
                 DialogResult dialogResult = MessageBox.Show("Bạn có muốn in không?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (dialogResult == DialogResult.Yes)
                 {
                     PrintPreView printPreView = new PrintPreView(txtkhachhang.Text, diachi, txtghichu.Text, float.Parse(txtsotien.Text.ToString()), DocSoThanhChu.So_chu(Double.Parse(txtsotien.Text.ToString())), txttheochungtu.Text, txtphieuchi.Text, txtnhanvien.EditValue.ToString(), vaitro);
                     printPreView.ShowDialog();
                 }
                 else
                 {
                 }
             }
             else
             {
                 MessageBox.Show("Lưu Thông tin Phiếu Chi Thất Bại.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             Random rnd  = new Random();
             int    temp = rnd.Next(1, 100000);
             txtphieuchi.Text = PhieuChiTheoChungTuBUS.PhatSinhMaPhieuChi(maphieu, temp);
             MessageBox.Show("Mã Phiếu Chi Đã Tồn Tại, đã phát sinh mã phiếu mới", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     if (vaitro == 1)
     {
         if (PhieuChiTheoChungTuBUS.KiemTraMaPhieuThuDaTonTai(txtphieuchi.Text) < 1)
         {
             if (PhieuChiTheoChungTuBUS.LuuThongTinPhieuThu(txtphieuchi.Text, maphieu, txtngay_pc.EditValue.ToString(), makh, txtkhachhang.Text, float.Parse(txtsotien.Text.ToString()), txtghichu.Text) > 0)
             {
                 whenInsertSuccessed();
                 DialogResult dialogResult = MessageBox.Show("Bạn có muốn in không?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (dialogResult == DialogResult.Yes)
                 {
                     PrintPreView printPreView = new PrintPreView(txtkhachhang.Text, diachi, txtghichu.Text, float.Parse(txtsotien.Text.ToString()), DocSoThanhChu.So_chu(Double.Parse(txtsotien.Text.ToString())), txttheochungtu.Text, txtphieuchi.Text, txtnhanvien.EditValue.ToString(), vaitro);
                     printPreView.ShowDialog();
                 }
                 else
                 {
                 }
             }
             else
             {
                 MessageBox.Show("Lưu Thông tin Phiếu Thu Thất Bại.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Mã Phiếu Thu Đã Tồn Tại, Đã Phát Sinh Mã Mới", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             Random rnd  = new Random();
             int    temp = rnd.Next(1, 100000);
             txtphieuchi.Text = PhieuChiTheoChungTuBUS.PhatSinhMaPhieuChi(maphieu, temp);
         }
     }
 }
        private void btnin_Click(object sender, EventArgs e)
        {
            PrintPreView printPreView = new PrintPreView(txtkhachhang.Text, diachi, txtghichu.Text, float.Parse(txtsotien.Text.ToString()), DocSoThanhChu.So_chu(Double.Parse(txtsotien.Text.ToString())), txttheochungtu.Text, txtphieuchi.Text, txtnhanvien.EditValue.ToString(), vaitro);

            printPreView.ShowDialog();
        }