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"; } } }
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(); } } } }