Ejemplo n.º 1
0
        public void Update_PHIEUTHUTIEN(string sql, PHIEUTHUTIEN ptt)
        {
            DBService db = new DBService();

            db.openconn();
            SqlCommand cmd = new SqlCommand(sql, db.conn);
            //đánh dấu điểm bắt đầu
            SqlTransaction tran = db.conn.BeginTransaction("ThemLopTransaction");

            cmd.Transaction = tran;
            try
            {
                SqlParameter pa1 = new SqlParameter("@mapt", ptt.Mapt);
                cmd.Parameters.Add(pa1);
                SqlParameter pa2 = new SqlParameter("@stt", ptt.Stt);
                cmd.Parameters.Add(pa2);
                SqlParameter pa3 = new SqlParameter("@ntt", ptt.Ntt);
                cmd.Parameters.Add(pa3);
                SqlParameter pa4 = new SqlParameter("@makh", ptt.Makh);
                cmd.Parameters.Add(pa4);

                cmd.ExecuteNonQuery();
                tran.Commit();//kết thúc transaction
            }
            catch (Exception ex)
            {
                tran.Rollback();//quay lui tới thời điểm beginTran
                throw ex;
            }
            db.closeconn();
        }
Ejemplo n.º 2
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            PHIEUTHUTIEN ptt = new PHIEUTHUTIEN(gView_DSPTT.GetRowCellValue(gView_DSPTT.FocusedRowHandle, "Mã phiếu thu").ToString(), 0, DateTime.Now, "");

            ptt.Xoa();
            load_DSPTT_TheoMaKH(gView_DSKH.GetRowCellValue(gView_DSKH.FocusedRowHandle, "Mã KH").ToString());
        }
Ejemplo n.º 3
0
        private void btXacNhan_Click_1(object sender, EventArgs e)
        {
            if (btXacNhan.Text == "Nhập mới")
            {
                btXacNhan.Text        = "Xác nhận";
                groupControl1.Enabled = datiNgayLap.Enabled = txtSTT.Enabled = btEditMa.Enabled = true;
                txtMa.Text            = txtTen.Text = txtDiaChi.Text = txtSDT.Text = txtEmail.Text = txtSTN.Text = txtSTT.Text = "";
                mapt             = DateTime.Now.ToString("ddMMhhmmss");
                btReport.Enabled = false;
                btEditMa.Text    = mapt;
                return;
            }

            if (txtMa.Text == "" || btEditMa.Text == "" || txtSTT.Text == "")
            {
                MessageBox.Show("Chưa nhập đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (timKH_TheoMa(txtMa.Text) == false || timKH_TheoTen(txtTen.Text) == false)
                {
                    MessageBox.Show("Mã hoặc tên khách hàng không tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (ktMaPTT(btEditMa.Text))
                {
                    MessageBox.Show("Mã phiếu đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (lblQD4.Visible)
                    {
                        if (int.Parse(txtSTT.Text) > int.Parse(txtSTN.Text))
                        {
                            MessageBox.Show("Vi phạm lưu ý!", "Thông cáo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    PHIEUTHUTIEN ptt = new PHIEUTHUTIEN(btEditMa.Text, float.Parse(txtSTT.Text.Trim()), Convert.ToDateTime(datiNgayLap.Text), txtMa.Text);
                    ptt.Them();
                    MessageBox.Show("Thêm phiếu thu tiền thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    KHACHHANG kh = new KHACHHANG(txtMa.Text, "", "", "", "", float.Parse(txtSTT.Text));
                    kh.Sua_STN_Giam();

                    btReport.Enabled = true;

                    groupControl1.Enabled = datiNgayLap.Enabled = txtSTT.Enabled = btEditMa.Enabled = false;
                    btXacNhan.Text        = "Nhập mới";
                }
            }
        }
Ejemplo n.º 4
0
 private void btReport_Click(object sender, EventArgs e)
 {
     if (btReport.Text == "Xuất report")
     {
         string t = txtTen.Text;
         fmReportPhieuThuTien hd = new fmReportPhieuThuTien(t);
         hd.ShowDialog();
     }
     else // lệnh cho hàm sửa PTT bên form DSPTT
     {
         PHIEUTHUTIEN xoa_ptt = new PHIEUTHUTIEN(btEditMa.Text, 0, DateTime.Now, "");
         xoa_ptt.Xoa();
         if (txtMa.Text == "" || btEditMa.Text == "" || txtSTT.Text == "")
         {
             MessageBox.Show("Chưa nhập đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             if (timKH_TheoMa(txtMa.Text) == false || timKH_TheoTen(txtTen.Text) == false)
             {
                 MessageBox.Show("Mã hoặc tên khách hàng không tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else if (ktMaPTT(btEditMa.Text))
             {
                 MessageBox.Show("Mã phiếu đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {
                 PHIEUTHUTIEN ptt = new PHIEUTHUTIEN(btEditMa.Text, float.Parse(txtSTT.Text.Trim()), Convert.ToDateTime(datiNgayLap.Text), txtMa.Text);
                 ptt.Them();
                 MessageBox.Show("Sửa phiếu thu tiền thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
         }
     }
 }