private void OnDeletePhieuThu() { List <string> deletedPTThuocList = new List <string>(); List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgPhieuThu.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { deletedRows.Add(row); } } if (deletedRows.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những phiếu thu mà bạn đã đánh dấu ?") == DialogResult.Yes) { List <string> noteList = new List <string>(); foreach (DataRow row in deletedRows) { string maPhieuThuHopDong = row["MaPhieuThuHopDong"].ToString(); string phieuThuHopDongGUID = row["PhieuThuHopDongGUID"].ToString(); dlgLyDoXoa dlg = new dlgLyDoXoa(maPhieuThuHopDong, 0); if (dlg.ShowDialog(this) == DialogResult.OK) { noteList.Add(dlg.Notes); deletedPTThuocList.Add(phieuThuHopDongGUID); } } if (deletedPTThuocList.Count > 0) { Result result = PhieuThuHopDongBus.DeletePhieuThuHopDong(deletedPTThuocList, noteList); if (result.IsOK) { foreach (DataRow row in deletedRows) { string phieuThuHopDongGUID = row["PhieuThuHopDongGUID"].ToString(); if (deletedPTThuocList.Contains(phieuThuHopDongGUID)) { dt.Rows.Remove(row); } } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuHopDongBus.DeletePhieuThuHopDong"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.DeletePhieuThuHopDong")); } } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những phiếu thu cần xóa.", IconType.Information); } }
private void OnDisplayPhieuThuHopDongList() { Result result = PhieuThuHopDongBus.GetPhieuThuHopDongList(_filterType, _fromDate, _toDate, _tenNguoiNop, _tenHopDong, _type, _type2); if (result.IsOK) { MethodInvoker method = delegate { ClearData(); DataTable dt = result.QueryResult as DataTable; dgPhieuThu.DataSource = dt; HighlightExportedInvoice(); lbKetQuaTimDuoc.Text = string.Format("Kết quả tìm được: {0}", dt.Rows.Count); ShowTongTien(); }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuHopDongBus.GetPhieuThuHopDongList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.GetPhieuThuHopDongList")); } }
private void dlgAddPhieuThuHopDong_FormClosing(object sender, FormClosingEventArgs e) { if (this.DialogResult == System.Windows.Forms.DialogResult.OK) { if (_isNew) { if (CheckInfo()) { SaveInfoAsThread(); } else { e.Cancel = true; } } else //if (Global.StaffType == StaffType.Admin) { Result result = PhieuThuHopDongBus.CapNhatTrangThaiPhieuThu(_phieuThuHopDong.PhieuThuHopDongGUID.ToString(), chkDaXuatHD.Checked, chkDaThuTien.Checked, (byte)cboHinhThucThanhToan.SelectedIndex, txtGhiChu.Text); if (!result.IsOK) { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuHopDongBus.CapNhatTrangThaiPhieuThu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.CapNhatTrangThaiPhieuThu")); e.Cancel = true; } else { _drPhieuThu["IsExported"] = chkDaXuatHD.Checked; _drPhieuThu["DaThuTien"] = chkDaThuTien.Checked; _drPhieuThu["HinhThucThanhToan"] = (byte)cboHinhThucThanhToan.SelectedIndex; _drPhieuThu["HinhThucThanhToanStr"] = cboHinhThucThanhToan.Text; _drPhieuThu["Notes"] = txtGhiChu.Text; } } } else { if (_isNew) { if (MsgBox.Question(this.Text, "Bạn có muốn lưu thông tin phiếu thu hợp đồng ?") == System.Windows.Forms.DialogResult.Yes) { if (CheckInfo()) { this.DialogResult = System.Windows.Forms.DialogResult.OK; SaveInfoAsThread(); } else { e.Cancel = true; } } } } }
private void GenerateCode() { Cursor.Current = Cursors.WaitCursor; Result result = PhieuThuHopDongBus.GetPhieuThuHopDongCount(); if (result.IsOK) { int count = Convert.ToInt32(result.QueryResult); txtMaPhieuThu.Text = Utility.GetCode("PTHD", count + 1, 7); } else { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuHopDongBus.GetPhieuThuHopDongCount"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.GetPhieuThuHopDongCount")); } }
private string GetGenerateCode() { Result result = PhieuThuHopDongBus.GetPhieuThuHopDongCount(); if (result.IsOK) { int count = Convert.ToInt32(result.QueryResult); return(Utility.GetCode("PTHD", count + 1, 7)); } else { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuHopDongBus.GetPhieuThuHopDongCount"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.GetPhieuThuHopDongCount")); return(string.Empty); } }
private void DisplayCongNoHopDong() { if (_hopDongGUID == string.Empty) { return; } Result result = PhieuThuHopDongBus.GetCongNoTheoHopDong(_hopDongGUID); if (result.IsOK) { double congNo = Convert.ToDouble(result.QueryResult); numCongNo.Value = (Decimal)congNo; } else { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuHopDongBus.GetCongNoTheoHopDong"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.GetCongNoTheoHopDong")); } }
private void ShowTongTien() { if (!chkTongTien.Checked) { chkTongTien.Text = "Tổng tiền:"; } else { Result result = PhieuThuHopDongBus.GetTongTien(_filterType, _fromDate, _toDate, _tenNguoiNop, _tenHopDong, _type, _type2); if (result.IsOK) { chkTongTien.Text = string.Format("Tổng tiền: {0:N0} VNĐ", result.QueryResult); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuHopDongBus.GetTongTien"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.GetTongTien")); } } }
private void OnSaveInfo() { try { MethodInvoker method = delegate { _phieuThuHopDong.MaPhieuThuHopDong = txtMaPhieuThu.Text; _phieuThuHopDong.HopDongGUID = Guid.Parse(cboMaHopDong.SelectedValue.ToString()); _phieuThuHopDong.NgayThu = dtpkNgayThu.Value; _phieuThuHopDong.TenNguoiNop = txtTenKhachHang.Text; _phieuThuHopDong.TenCongTy = txtTenCongTy.Text; _phieuThuHopDong.DiaChi = txtDiaChi.Text; _phieuThuHopDong.Status = (byte)Status.Actived; _phieuThuHopDong.ChuaThuTien = !chkDaThuTien.Checked; _phieuThuHopDong.HinhThucThanhToan = (byte)cboHinhThucThanhToan.SelectedIndex; _phieuThuHopDong.Notes = txtGhiChu.Text; if (_isNew) { _phieuThuHopDong.CreatedDate = DateTime.Now; _phieuThuHopDong.CreatedBy = Guid.Parse(Global.UserGUID); } List <ChiTietPhieuThuHopDong> addedList = new List <ChiTietPhieuThuHopDong>(); ChiTietPhieuThuHopDong ctpthd = new ChiTietPhieuThuHopDong(); ctpthd.CreatedDate = DateTime.Now; ctpthd.CreatedBy = Guid.Parse(Global.UserGUID); ctpthd.DichVu = txtDichVu.Text; ctpthd.DonGia = (double)numThu.Value; ctpthd.SoLuong = 1; ctpthd.Giam = 0; ctpthd.ThanhTien = ctpthd.DonGia; ctpthd.Status = (byte)Status.Actived; addedList.Add(ctpthd); string maPhieuThu = GetGenerateCode(); if (maPhieuThu == string.Empty) { return; } _phieuThuHopDong.MaPhieuThuHopDong = maPhieuThu; Result result = PhieuThuHopDongBus.InsertPhieuThuHopDong(_phieuThuHopDong, addedList); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuHopDongBus.InsertPhieuThuHopDong"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.InsertPhieuThuHopDong")); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } catch (Exception e) { MsgBox.Show(this.Text, e.Message, IconType.Error); Utility.WriteToTraceLog(e.Message); } }
private void DisplayInfo(DataRow drPhieuThu) { try { Cursor.Current = Cursors.WaitCursor; txtMaPhieuThu.Text = drPhieuThu["MaPhieuThuHopDong"] as string; cboMaHopDong.SelectedValue = drPhieuThu["HopDongGUID"].ToString(); dtpkNgayThu.Value = Convert.ToDateTime(drPhieuThu["NgayThu"]); txtTenKhachHang.Text = drPhieuThu["TenNguoiNop"].ToString(); txtTenCongTy.Text = drPhieuThu["TenCongTy"] as string; txtDiaChi.Text = drPhieuThu["DiaChi"] as string; chkDaThuTien.Checked = Convert.ToBoolean(drPhieuThu["DaThuTien"]); chkDaXuatHD.Checked = Convert.ToBoolean(drPhieuThu["IsExported"]); cboHinhThucThanhToan.SelectedIndex = Convert.ToInt32(drPhieuThu["HinhThucThanhToan"]); txtGhiChu.Text = drPhieuThu["Notes"] as string; _phieuThuHopDong.PhieuThuHopDongGUID = Guid.Parse(drPhieuThu["PhieuThuHopDongGUID"].ToString()); if (drPhieuThu["CreatedDate"] != null && drPhieuThu["CreatedDate"] != DBNull.Value) { _phieuThuHopDong.CreatedDate = Convert.ToDateTime(drPhieuThu["CreatedDate"]); } if (drPhieuThu["CreatedBy"] != null && drPhieuThu["CreatedBy"] != DBNull.Value) { _phieuThuHopDong.CreatedBy = Guid.Parse(drPhieuThu["CreatedBy"].ToString()); } if (drPhieuThu["UpdatedDate"] != null && drPhieuThu["UpdatedDate"] != DBNull.Value) { _phieuThuHopDong.UpdatedDate = Convert.ToDateTime(drPhieuThu["UpdatedDate"]); } if (drPhieuThu["UpdatedBy"] != null && drPhieuThu["UpdatedBy"] != DBNull.Value) { _phieuThuHopDong.UpdatedBy = Guid.Parse(drPhieuThu["UpdatedBy"].ToString()); } if (drPhieuThu["DeletedDate"] != null && drPhieuThu["DeletedDate"] != DBNull.Value) { _phieuThuHopDong.DeletedDate = Convert.ToDateTime(drPhieuThu["DeletedDate"]); } if (drPhieuThu["DeletedBy"] != null && drPhieuThu["DeletedBy"] != DBNull.Value) { _phieuThuHopDong.DeletedBy = Guid.Parse(drPhieuThu["DeletedBy"].ToString()); } _phieuThuHopDong.Status = Convert.ToByte(drPhieuThu["Status"]); Result result = PhieuThuHopDongBus.GetChiTietPhieuThuHopDong(_phieuThuHopDong.PhieuThuHopDongGUID.ToString()); if (result.IsOK) { DataTable dtChiTiet = result.QueryResult as DataTable; if (dtChiTiet != null && dtChiTiet.Rows.Count > 0) { DataRow row = dtChiTiet.Rows[0]; txtDichVu.Text = row["DichVu"].ToString(); numThu.Value = (Decimal)Convert.ToDouble(row["ThanhTien"]); } } else { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuHopDongBus.GetChiTietPhieuThuHopDong"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.GetChiTietPhieuThuHopDong")); } } catch (Exception e) { MsgBox.Show(this.Text, e.Message, IconType.Error); Utility.WriteToTraceLog(e.Message); } }
private void OnTinhTongTienChecklist(DataRow patientRow) { try { DataTable dt = dgService.DataSource as DataTable; if (dt == null || dt.Rows.Count <= 0) { lbTongTienChecklist.Text = "Tổng tiền: 0 (VNĐ)"; return; } string patientGUID = patientRow["PatientGUID"].ToString(); double tongTien = 0; foreach (DataRow row in dt.Rows) { bool isUsing = Convert.ToBoolean(row["Using"]); if (!isUsing) { continue; } string serviceGUID = row["ServiceGUID"].ToString(); string nguoiChuyenNhuong = row["NguoiChuyenNhuong"] as string; Result result = null; if (nguoiChuyenNhuong == null || nguoiChuyenNhuong.Trim() == string.Empty) { result = PhieuThuHopDongBus.GetThanhTienDichVuKhamTheoHopDong(_hopDongGUID, serviceGUID, patientGUID); if (!result.IsOK) { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuHopDongBus.GetGiaDichVuKhamTheoHopDong"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.GetGiaDichVuKhamTheoHopDong")); return; } } else { result = PhieuThuHopDongBus.GetThanhTienDichVuKhamChuyenNhuong(_hopDongGUID, serviceGUID, patientGUID); if (!result.IsOK) { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuHopDongBus.GetThanhTienDichVuKhamChuyenNhuong"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuHopDongBus.GetThanhTienDichVuKhamChuyenNhuong")); return; } } double soTien = Convert.ToDouble(result.QueryResult); tongTien += soTien; } string gioiTinh = patientRow["GenderAsStr"].ToString(); string tinhTrangGiaDinh = string.Empty; if (patientRow["Tinh_Trang_Gia_Dinh"] != null && patientRow["Tinh_Trang_Gia_Dinh"] != DBNull.Value) { tinhTrangGiaDinh = patientRow["Tinh_Trang_Gia_Dinh"].ToString(); } if (gioiTinh.ToLower() == "nam") { if (_giamGiaNam > 0) { tongTien = Math.Round((tongTien * (100 - _giamGiaNam)) / 100, 0); } } else { if (tinhTrangGiaDinh.ToLower() == "có gia đình") { if (_giamGiaNuCoGD > 0) { tongTien = Math.Round((tongTien * (100 - _giamGiaNuCoGD)) / 100, 0); } } else { if (_giamGiaNu > 0) { tongTien = Math.Round((tongTien * (100 - _giamGiaNu)) / 100, 0); } } } if (tongTien == 0) { lbTongTienChecklist.Text = "Tổng tiền: 0 (VNĐ)"; } else { lbTongTienChecklist.Text = string.Format("Tổng tiền: {0} (VNĐ)", tongTien.ToString("#,###")); } } catch (Exception e) { MM.MsgBox.Show(this.Text, e.Message, IconType.Error); Utility.WriteToTraceLog(e.Message); } }