public static PsReponse UpdateTiepNhan(List <PSTiepNhan> lstpsl) { PsReponse res = new PsReponse(); try { ProcessDataSync cn = new ProcessDataSync(); db = cn.db; var account = db.PSPhieuSangLocs.FirstOrDefault(); db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); foreach (var psl in lstpsl) { var psldb = db.PSTiepNhans.FirstOrDefault(p => p.MaPhieu == psl.MaPhieu); if (psldb != null) { var term = psl.RowIDPhieu; psldb = psl; psldb.RowIDPhieu = term; db.SubmitChanges(); } else { PSTiepNhan newpsl = new PSTiepNhan(); newpsl = psl; newpsl.RowIDPhieu = 0; newpsl.isDongBo = true; db.PSTiepNhans.InsertOnSubmit(newpsl); db.SubmitChanges(); } } db.Transaction.Commit(); db.Connection.Close(); res.Result = true; } catch (Exception ex) { db.Transaction.Rollback(); db.Connection.Close(); res.Result = false; res.StringError = ex.ToString(); } return(res); }
private void ThemMoiPhieuVaoDanhSachTiepNhan(PSTiepNhan phieu) { if (phieu != null) { if (this.lstTiepNhan.FindAll(p => p.MaPhieu == phieu.MaPhieu).Count() > 0) { XtraMessageBox.Show("Phiếu này đã được nhập rồi,vui lòng chọn phiếu mới", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtMaPhieuMoi.ResetText(); } else { this.lstTiepNhan.Add(phieu); this.LoadDanhSachTiepNhan(); this.txtMaPhieuMoi.ResetText(); this.txtMaPhieuMoi.Focus(); } } }
public static PsReponse GetTiepNhan() { PsReponse res = new PsReponse(); res.Result = true; try { ProcessDataSync cn = new ProcessDataSync(); db = cn.db; var account = db.PSAccount_Syncs.FirstOrDefault(); if (account != null) { string token = cn.GetToken(account.userName, account.passWord); if (!string.IsNullOrEmpty(token)) { var result = cn.GetRespone(cn.CreateLink(linkGetTiepNhan), token); if (result.Result) { string json = result.ValueResult; JavaScriptSerializer jss = new JavaScriptSerializer(); ObjectModel.RootObjectAPI psl = jss.Deserialize <ObjectModel.RootObjectAPI>(json); //List<PSPatient> patient = jss.Deserialize<List<PSPatient>>(json); List <PSTiepNhan> lstpsl = new List <PSTiepNhan>(); if (psl.TotalCount > 0) { foreach (var item in psl.Items) { PSTiepNhan term = new PSTiepNhan(); term = cn.CovertDynamicToObjectModel(item, term); lstpsl.Add(term); } //UpdatePatient(patient); UpdateTiepNhan(lstpsl); res.Result = true; } } else { res.Result = false; res.StringError = result.ErorrResult; } } else { res.Result = false; res.StringError = "Kiểm tra lại kết nối mạng hoặc tài khoản đồng bộ!"; } } else { res.Result = false; res.StringError = "Chưa có tài khoản đồng bộ!"; } } catch (Exception ex) { res.Result = false; res.StringError = DateTime.Now.ToString() + "Lỗi khi get dữ liệu Danh Mục Mapping Kỹ Thuật - Dịch Vụ từ server \r\n " + ex.Message; } return(res); }
private void CheckPhieu(string maPhieu, string maDonVi) //kiểm tra mã phiếu đã nằm trong lstTiepNhan hay chưa? { try { if (this.searchLookUpDonViCoSoTiepNhan.EditValue == null && !(string.IsNullOrEmpty(maDonVi))) { this.searchLookUpDonViCoSoTiepNhan.EditValue = maDonVi; } } catch (Exception ex) { } bool isTonTaiTrongDB = BioNet_Bus.KiemTraThongTinPhieuDaDuocTiepNhan(maPhieu); if (isTonTaiTrongDB) { XtraMessageBox.Show("Phiếu này đã được nhập rồi,vui lòng chọn phiếu mới", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtMaPhieuMoi.ResetText(); return; } var ph = this.lstPhieu.FirstOrDefault(p => p.maPhieu == maPhieu); if (ph != null) //lấy dữ liệu từ lstPhieu qua nếu mã thẻ có tồn tại trong lstPhieu { PSTiepNhan tNhan = new PSTiepNhan(); if (!(string.IsNullOrEmpty(maDonVi))) { if (!maDonVi.Equals(ph.maDonViCoSo)) { if (XtraMessageBox.Show("Thông tin phiếu nhập mới tồn tại trong danh sách chờ nhưng khác đơn vị \r\n Bạn bạn đã chọn sai đơn vị đúng không?", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { tNhan.MaDonVi = ph.maDonViCoSo; } else { tNhan.MaDonVi = maDonVi; } } else { tNhan.MaDonVi = ph.maDonViCoSo; } } else { tNhan.MaDonVi = ph.maDonViCoSo; } tNhan.MaNVTiepNhan = this.MaNhanVienDangNhap; ///"Gán mã user đăng nhập vô đây" tNhan.MaPhieu = ph.maPhieu; tNhan.NgayTiepNhan = DateTime.Now; //lấy theo phiên đăng nhập tNhan.isDaDanhGia = false; tNhan.RowIDTiepNhan = 0; tNhan.isDaNhapLieu = true; ThemMoiPhieuVaoDanhSachTiepNhan(tNhan); this.lstPhieu.Remove(ph); this.LoadGCPhieuCho(); } else //thêm phiếu mới vào lstTiepNhan, mã đơn vị = mã đơn vị được người dùng chọn trên combobox { PSTiepNhan tNhan = new PSTiepNhan(); if (!(string.IsNullOrEmpty(maDonVi))) { tNhan.MaDonVi = maDonVi; } else { tNhan.MaDonVi = searchLookUpDonViCoSoTiepNhan.EditValue.ToString(); } tNhan.MaNVTiepNhan = this.MaNhanVienDangNhap;///"Gán mã user đăng nhập vô đây" tNhan.MaPhieu = maPhieu; tNhan.isDaNhapLieu = false; tNhan.isDaDanhGia = false; tNhan.NgayTiepNhan = BioNet_Bus.GetDateTime(); //lấy theo phiên đăng nhập tNhan.RowIDTiepNhan = 0; ThemMoiPhieuVaoDanhSachTiepNhan(tNhan); } }