public void Update(string Ma,string Loai,string Ten,int SttHthi,int TrangThai,byte? TrangthaiMacdinh,string VietTat,string MotaThem,string NguoiTao,DateTime? NgayTao,string NguoiSua,DateTime? NgaySua) { DmucChung item = new DmucChung(); item.MarkOld(); item.IsLoaded = true; item.Ma = Ma; item.Loai = Loai; item.Ten = Ten; item.SttHthi = SttHthi; item.TrangThai = TrangThai; item.TrangthaiMacdinh = TrangthaiMacdinh; item.VietTat = VietTat; item.MotaThem = MotaThem; item.NguoiTao = NguoiTao; item.NgayTao = NgayTao; item.NguoiSua = NguoiSua; item.NgaySua = NgaySua; item.Save(UserName); }
/// <summary> /// Đóng gói dữ liệu vào DataTable để gửi lên Webservice xử lý /// </summary> /// <returns></returns> private DmucChung GetObject() { try { DmucChung obj = new DmucChung(); obj.Ma = Utility.DoTrim(txtMa.Text); obj.Ten = Utility.DoTrim(txtTen.Text); obj.Loai = m_strListType; obj.TrangThai = Utility.Bool2byte(chkTrangthai.Checked); obj.TrangthaiMacdinh = Utility.Bool2byte(chkDefault.Checked ); obj.MotaThem = Utility.DoTrim(txtMotathem.Text); obj.VietTat = Utility.DoTrim(txtViettat.Text); if (m_enAct == action.Update) { obj.NguoiSua = globalVariables.UserName; obj.NgaySua = globalVariables.SysDate; } else { obj.NguoiTao = globalVariables.UserName; obj.NgayTao = globalVariables.SysDate; } obj.SttHthi = short.Parse(txtSTT.Text); return obj; } catch (Exception ex) { Utility.ShowMsg("Lỗi xảy ra khi đóng gói dữ liệu vào DataTable để gửi lên Webservice\n" + ex.Message, "Thông báo"); return null; } }
public void Insert(string Ma,string Loai,string Ten,int SttHthi,int TrangThai,string VietTat,string MotaThem,string NguoiTao,DateTime? NgayTao,string NguoiSua,DateTime? NgaySua) { DmucChung item = new DmucChung(); item.Ma = Ma; item.Loai = Loai; item.Ten = Ten; item.SttHthi = SttHthi; item.TrangThai = TrangThai; item.VietTat = VietTat; item.MotaThem = MotaThem; item.NguoiTao = NguoiTao; item.NgayTao = NgayTao; item.NguoiSua = NguoiSua; item.NgaySua = NgaySua; item.Save(UserName); }
/// <summary> /// Insert một bản ghi vào bảng Danh mục dùng chung /// </summary> /// <param name="obj"></param> /// <returns></returns> public void InsertList(DmucChung obj, int intSTTCu, ref string ActResult) { try { ActionResult _act = isExistedRecord(obj.Ma, obj.Loai); if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception) { ActResult = _act.ToString(); return; } //B1: Tim ban ghi co STT=STT moi DmucChungCollection v_lstDmuc = new DmucChungController().FetchByQuery(DmucChung.CreateQuery().AddWhere(DmucChung.Columns.SttHthi, Comparison.Equals, obj.SttHthi).AND(DmucChung.Columns.Loai, Comparison.Equals, obj.Loai)); if (v_lstDmuc.Count > 0) { new Update(DmucChung.Schema).Set(DmucChung.Columns.SttHthi).EqualTo(intSTTCu) .Where(DmucChung.Columns.Ma).IsEqualTo(v_lstDmuc[0].Ma) .And(DmucChung.Columns.Loai).IsEqualTo(v_lstDmuc[0].Loai).Execute(); } obj.IsNew = true; obj.Save(); if (Utility.Byte2Bool(obj.TrangthaiMacdinh)) new Update(DmucChung.Schema).Set(DmucChung.Columns.TrangthaiMacdinh).EqualTo(0) .Where(DmucChung.Columns.Ma).IsNotEqualTo(obj.Ma) .And(DmucChung.Columns.Loai).IsEqualTo(obj.Loai).Execute(); ActResult = ActionResult.Success.ToString(); } catch { ActResult = ActionResult.Exception.ToString(); } }
private void UpdateChiDanThem() { if (!string.IsNullOrEmpty(txtChiDanThem.Text)) { new Delete().From(DmucChung.Schema) .Where(DmucChung.Columns.Loai).IsEqualTo("CDDT") .And(DmucChung.Columns.NguoiTao).IsEqualTo(globalVariables.UserName) .And(DmucChung.Columns.Ma).IsEqualTo(Utility.UnSignedCharacter(txtChiDanThem.Text.ToUpper())).Execute(); DmucChung objDmucChung = new DmucChung(); objDmucChung.NguoiTao = globalVariables.UserName; objDmucChung.NgayTao = globalVariables.SysDate; objDmucChung.Ten = Utility.sDbnull(Utility.chuanhoachuoi(txtChiDanThem.Text.Trim())); objDmucChung.TrangThai = 1; objDmucChung.MotaThem = Utility.sDbnull(Utility.chuanhoachuoi(txtChiDanThem.Text.Trim())); objDmucChung.Ma = Utility.UnSignedCharacter(objDmucChung.Ten.ToUpper()); objDmucChung.Loai = "CDDT"; objDmucChung.IsNew = true; objDmucChung.Save(); } }
/// <summary> /// Update một bản ghi vào bảng Danh mục dùng chung /// </summary> /// <param name="obj"></param> /// <returns></returns> public void UpdateList(DmucChung obj, string strOldCode, int intSTTCu, ref string ActResult) { try { ActionResult _act = isExistedRecord4Update(obj.Loai,obj.Ma, strOldCode); if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception) { ActResult = _act.ToString(); return; } //B1: Tim ban ghi co STT=STT moi DmucChungCollection v_lstDmuc = new DmucChungController().FetchByQuery(DmucChung.CreateQuery().AddWhere(DmucChung.Columns.SttHthi, Comparison.Equals, obj.SttHthi).AND(DmucChung.Columns.Loai, Comparison.Equals, obj.Loai)); if (v_lstDmuc.Count > 0) { new Update(DmucChung.Schema).Set(DmucChung.Columns.SttHthi).EqualTo(intSTTCu) .Where(DmucChung.Columns.Ma).IsEqualTo(v_lstDmuc[0].Ma) .And(DmucChung.Columns.Loai).IsEqualTo(v_lstDmuc[0].Loai).Execute(); } if (Utility.Byte2Bool(obj.TrangthaiMacdinh)) new Update(DmucChung.Schema).Set(DmucChung.Columns.TrangthaiMacdinh).EqualTo(0) .Where(DmucChung.Columns.Ma).IsNotEqualTo(obj.Ma) .And(DmucChung.Columns.Loai).IsEqualTo(obj.Loai).Execute(); int record = new Update(DmucChung.Schema) .Set(DmucChung.Columns.Ma).EqualTo(obj.Ma) .Set(DmucChung.Columns.Ten).EqualTo(obj.Ten) .Set(DmucChung.Columns.VietTat).EqualTo(obj.VietTat) .Set(DmucChung.Columns.SttHthi).EqualTo(obj.SttHthi) .Set(DmucChung.Columns.MotaThem).EqualTo(obj.MotaThem) .Set(DmucChung.Columns.TrangThai).EqualTo(obj.TrangThai) .Set(DmucChung.Columns.TrangthaiMacdinh).EqualTo(obj.TrangthaiMacdinh) .Set(DmucChung.Columns.NgaySua).EqualTo(obj.NgaySua) .Set(DmucChung.Columns.NguoiSua).EqualTo(obj.NguoiSua) .Where(DmucChung.Columns.Ma).IsEqualTo(strOldCode). And(DmucChung.Columns.Loai).IsEqualTo(obj.Loai).Execute(); if (record > 0) { ActResult = ActionResult.Success.ToString(); } else ActResult = ActionResult.Error.ToString(); } catch { ActResult = ActionResult.Exception.ToString(); } }
/// <summary> /// Update một bản ghi vào bảng Danh mục dùng chung /// </summary> /// <param name="obj"></param> /// <returns></returns> public void UpdateList(DmucChung obj, string strOldCode, int intSTTCu, ref string ActResult) { try { ActionResult _act = isExistedRecord4Update(obj.Loai, obj.Ma, strOldCode); if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception) { ActResult = _act.ToString(); return; } //B1: Tim ban ghi co STT=STT moi DmucChungCollection v_lstDmuc = new DmucChungController().FetchByQuery(DmucChung.CreateQuery().AddWhere(DmucChung.Columns.SttHthi, Comparison.Equals, obj.SttHthi).AND(DmucChung.Columns.Loai, Comparison.Equals, obj.Loai)); if (v_lstDmuc.Count > 0) { new Update(DmucChung.Schema).Set(DmucChung.Columns.SttHthi).EqualTo(intSTTCu) .Where(DmucChung.Columns.Ma).IsEqualTo(v_lstDmuc[0].Ma) .And(DmucChung.Columns.Loai).IsEqualTo(v_lstDmuc[0].Loai).Execute(); } if (Utility.Byte2Bool(obj.TrangthaiMacdinh)) { new Update(DmucChung.Schema).Set(DmucChung.Columns.TrangthaiMacdinh).EqualTo(0) .Where(DmucChung.Columns.Ma).IsNotEqualTo(obj.Ma) .And(DmucChung.Columns.Loai).IsEqualTo(obj.Loai).Execute(); } int record = new Update(DmucChung.Schema) .Set(DmucChung.Columns.Ma).EqualTo(obj.Ma) .Set(DmucChung.Columns.Ten).EqualTo(obj.Ten) .Set(DmucChung.Columns.VietTat).EqualTo(obj.VietTat) .Set(DmucChung.Columns.SttHthi).EqualTo(obj.SttHthi) .Set(DmucChung.Columns.MotaThem).EqualTo(obj.MotaThem) .Set(DmucChung.Columns.TrangThai).EqualTo(obj.TrangThai) .Set(DmucChung.Columns.TrangthaiMacdinh).EqualTo(obj.TrangthaiMacdinh) .Set(DmucChung.Columns.NgaySua).EqualTo(obj.NgaySua) .Set(DmucChung.Columns.NguoiSua).EqualTo(obj.NguoiSua) .Where(DmucChung.Columns.Ma).IsEqualTo(strOldCode). And(DmucChung.Columns.Loai).IsEqualTo(obj.Loai).Execute(); if (record > 0) { ActResult = ActionResult.Success.ToString(); } else { ActResult = ActionResult.Error.ToString(); } } catch { ActResult = ActionResult.Exception.ToString(); } }
void cmdPrint_Click(object sender, EventArgs e) { try { Utility.WaitNow(this); DataTable dtData = SPs.NoitruTonghopChiphiRavien(objLuotkham.MaLuotkham, (int)objLuotkham.IdBenhnhan, Utility.Bool2byte(!Khoanoitrutonghop), idkhoanoitru).GetDataSet().Tables[0]; THU_VIEN_CHUNG.CreateXML(dtData, "noitru_tonghopchiphiravien.XML"); if (dtData.Rows.Count <= 0) { Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning); return; } foreach (DataRow drv in dtData.Rows) { if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "1" ||//Chi phí KCB drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "0" ||//Phí KCB kèm theo drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "4" ||//Buồng giường drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "8" //Gói dịch vụ ) { drv["ten_loaidichvu"] = string.Empty; drv["STT"] = 1; drv["id_loaidichvu"] = -1; } else if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "2") { string ma_loaidichvu = Utility.sDbnull(drv["id_loaidichvu"], -1); //drv["id_loaidichvu"]-->Được xác định trong câu truy vấn DmucChung objService = THU_VIEN_CHUNG.LaydoituongDmucChung("LOAIDICHVUCLS", ma_loaidichvu); if (objService != null) { drv["ten_loaidichvu"] = Utility.sDbnull(objService.Ten); drv["STT"] = Utility.sDbnull(objService.SttHthi); } } else if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "3") { int Drug_ID = Utility.Int32Dbnull(drv["id_dichvu"], -1); DmucThuoc objDrug = DmucThuoc.FetchByID(Drug_ID); if (objDrug != null) { if (objDrug.KieuThuocvattu == "THUOC") { drv["id_loaidichvu"] = 1; drv["STT"] = 1; drv["ten_loaidichvu"] = "Thuốc và dịch truyền"; } else { drv["id_loaidichvu"] = 2; drv["STT"] = 2; drv["ten_loaidichvu"] = "Vật tư y tế "; } } } if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "5") { drv["id_loaidichvu"] = 1; drv["STT"] = 1; drv["ten_loaidichvu"] = "Chi phí thêm "; } } THU_VIEN_CHUNG.Sapxepthutuin(ref dtData, true); dtData.DefaultView.Sort = "stt_in ,stt_hthi_dichvu,stt_hthi_chitiet,ten_chitietdichvu"; dtData.AcceptChanges(); Utility.UpdateLogotoDatatable(ref dtData); string StaffName = globalVariables.gv_strTenNhanvien; if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien)) { StaffName = globalVariables.UserName; } string reportCode = Khoanoitrutonghop ? "noitru_tonghopchiphiravien_theokhoa_dichvu" : "noitru_tonghopchiphiravien_dichvu"; if (THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb)) { reportCode = Khoanoitrutonghop ? "noitru_tonghopchiphiravien_theokhoa" : "noitru_tonghopchiphiravien"; } string tieude = "", reportname = ""; ReportDocument crpt = Utility.GetReport(reportCode, ref tieude, ref reportname); if (crpt == null) { return; } frmPrintPreview objForm = new frmPrintPreview(baocaO_TIEUDE1.TIEUDE, crpt, true, dtData.Rows.Count <= 0 ? false : true); crpt.SetDataSource(dtData); objForm.mv_sReportFileName = Path.GetFileName(reportname); objForm.mv_sReportCode = reportCode; Utility.SetParameterValue(crpt, "StaffName", StaffName); Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name); Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name); Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address); Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone); Utility.SetParameterValue(crpt, "sTitleReport", baocaO_TIEUDE1.TIEUDE); Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(DateTime.Now)); Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition()); objForm.crptViewer.ReportSource = crpt; objForm.ShowDialog(); } catch (Exception ex) { Utility.CatchException(ex); } finally { Utility.DefaultNow(this); } }
/// <summary> /// Insert một bản ghi vào bảng Danh mục dùng chung /// </summary> /// <param name="obj"></param> /// <returns></returns> public void InsertList(DmucChung obj, int intSTTCu, ref string ActResult) { try { ActionResult _act = isExistedRecord(obj.Ma, obj.Loai); if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception) { ActResult = _act.ToString(); return; } //B1: Tim ban ghi co STT=STT moi DmucChungCollection v_lstDmuc = new DmucChungController().FetchByQuery(DmucChung.CreateQuery().AddWhere(DmucChung.Columns.SttHthi, Comparison.Equals, obj.SttHthi).AND(DmucChung.Columns.Loai, Comparison.Equals, obj.Loai)); if (v_lstDmuc.Count > 0) { new Update(DmucChung.Schema).Set(DmucChung.Columns.SttHthi).EqualTo(intSTTCu) .Where(DmucChung.Columns.Ma).IsEqualTo(v_lstDmuc[0].Ma) .And(DmucChung.Columns.Loai).IsEqualTo(v_lstDmuc[0].Loai).Execute(); } obj.IsNew = true; obj.Save(); if (Utility.Byte2Bool(obj.TrangthaiMacdinh)) { new Update(DmucChung.Schema).Set(DmucChung.Columns.TrangthaiMacdinh).EqualTo(0) .Where(DmucChung.Columns.Ma).IsNotEqualTo(obj.Ma) .And(DmucChung.Columns.Loai).IsEqualTo(obj.Loai).Execute(); } ActResult = ActionResult.Success.ToString(); } catch { ActResult = ActionResult.Exception.ToString(); } }
public short GetMaxSTT(string m_strListType) { try { DmucChungCollection CollectionData = new DmucChungController().FetchByQuery(DmucChung.CreateQuery().AddWhere(DmucChung.Columns.Loai, Comparison.Equals, m_strListType)); int shtMaxSTT = 0; //Phải kiểm tra nếu Có dữ liệu mới lấy STT hiện tại=MaxSTT+1 if (CollectionData.Count > 0) { shtMaxSTT = CollectionData.Max(c => c.SttHthi); } return(Convert.ToInt16(shtMaxSTT + 1)); } catch { return(Convert.ToInt16(1)); } }