public List <string> AddDIN4Divide(string DIN) { if (DINInList.Contains(DIN)) { throw new Exception("Mã túi máu này đã có."); } Donation d = DonationBLL.Get(DIN); if (d == null) { throw new Exception("Không có mã túi máu này."); } //Can be produce positive product for research //if (d.TestResultStatus == Donation.TestResultStatusX.Positive) //{ // throw new Exception("Xét nghiệm sàng lọc: Dương tính."); //} RedBloodDataContext db = new RedBloodDataContext(); int count = db.Packs.Where(r => ProductCodeInList.Contains(r.ProductCode) && r.DIN == DIN).Count(); if (count == 0) { throw new Exception("Mã túi máu này không có sản phẩm đầu vào."); } DINInList.Add(DIN); return(DINInList); }
protected void Page_Load(object sender, EventArgs e) { PrintSettingBLL.Reload(); DonationBLL bll = new DonationBLL(); int campID = Request["CampaignID"].ToInt(); string rptType = Request["RptType"]; string DINList = Request["DINList"]; string count = Request["Count"]; List<Donation> pL = new List<Donation>(); if (campID != 0 && !string.IsNullOrEmpty(rptType)) { ReportType type = (ReportType)rptType.ToInt(); pL = DonationBLL.Get(campID, type, count.Split(',').ToList().Select(r => r.ToInt()).ToArray()); } else if (!string.IsNullOrEmpty(DINList)) { pL = bll.Get(DINList.Split(',')); } foreach (Donation item in pL) { Panel p = new Panel(); p.Style.Add("position", "relative"); p.Style.Add("page-break-after", "always"); p.Style.Apply(PrintSettingBLL.Card.PaperSize); p.Style.Add("border", "1px solid white"); divCon.Controls.Add(p); AddDINLabelControl(item, p); } }
public static void Update(string DIN, string bloodGroup, string note) { RedBloodDataContext db = new RedBloodDataContext(); Donation e = DonationBLL.Get(db, DIN); if (e == null) { throw new Exception(DonationErrEnum.NonExist.Message); } if (!CanUpdateTestResult(e)) { throw new Exception(DonationErrEnum.TRLocked.Message); } if (bloodGroup.Trim() != e.BloodGroup) { e.BloodGroup = bloodGroup; DonationTestLogBLL.Insert(db, e, PropertyName.For <Donation>(r => r.BloodGroup), note); } //Have to save before updaye TestResult Status db.SubmitChanges(); UpdateTestResultStatus(e); db.SubmitChanges(); }
protected void LinqDataSourcePack_Selecting(object sender, LinqDataSourceSelectEventArgs e) { DonationBLL bll = new DonationBLL(); var v = bll.Get(DINInList.ToArray()); e.Result = v; PanelAllNeg.Visible = v.Count > 0; lblTotal.Text = v.Count.ToString(); }
public static DonationErr Update(string DIN, string HIV, string HCV_Ab, string HBs_Ag, string Syphilis, string Malaria, string note, bool updateIfAllNon = false) { RedBloodDataContext db = new RedBloodDataContext(); Donation e = DonationBLL.Get(db, DIN); if (e == null || !CanUpdateTestResult(e)) { return(DonationErrEnum.TRLocked); } string old = e.InfectiousMarkers; if (!updateIfAllNon || (updateIfAllNon && e.Markers.IsAllNon) ) { // Warning: As CR user requirement, value for both test result are always the same. e.InfectiousMarkers = Infection.HIV_Ab.Encode(e.InfectiousMarkers, HIV); e.InfectiousMarkers = Infection.HIV_Ag.Encode(e.InfectiousMarkers, HIV); e.InfectiousMarkers = Infection.HCV_Ab.Encode(e.InfectiousMarkers, HCV_Ab); e.InfectiousMarkers = Infection.HBs_Ag.Encode(e.InfectiousMarkers, HBs_Ag); e.InfectiousMarkers = Infection.Syphilis.Encode(e.InfectiousMarkers, Syphilis); e.InfectiousMarkers = Infection.Malaria.Encode(e.InfectiousMarkers, Malaria); if (old != e.InfectiousMarkers) { DonationTestLogBLL.Insert(db, e, PropertyName.For <Donation>(r => r.Markers), note); } //Have to save before update TestResult Status db.SubmitChanges(); UpdateTestResultStatus(e); db.SubmitChanges(); } return(DonationErrEnum.Non); }
protected void LinqDataSourcePack_Selecting(object sender, LinqDataSourceSelectEventArgs e) { DonationBLL bll = new DonationBLL(); var v = bll.Get(DINInList.ToArray()); e.Result = v.Select(r => new { r.DIN, r.Status, Name = r.People.Name, CollectedDate = r.CollectedDate.ToStringVN_Hour(), r.BloodGroupDesc, r.BloodGroup, HIV = (int)r.TR_HIV, HCV_Ab = (int)r.TR_HCV_Ab, HBs_Ag = (int)r.TR_HBs_Ag, Syphilis = (int)r.TR_Syphilis, Malaria = (int)r.TR_Malaria, }); ; PanelAllNeg.Visible = v.Count > 0; lblTotal.Text = v.Count.ToString(); }
public static void Add(string DIN, string productCode, int?volume, Pack orgPack = null, DateTime?packDate = null) { RedBloodDataContext db = new RedBloodDataContext(); Donation d = null; if (orgPack == null) { d = DonationBLL.Get4CreateOriginal(db, DIN); } else { d = DonationBLL.Get(DIN); } Product product = ProductBLL.Get(productCode); if (IsExist(DIN, productCode)) { throw new Exception(PackErrEnum.Existed.Message); } //TODO: Check to see valid product code in collection //Code will be here //TODO: Check to see if the pack is collector too late //Code check will be here. Pack pack = new Pack(); pack.DIN = DIN; pack.ProductCode = productCode; pack.Status = Pack.StatusX.Product; pack.Actor = RedBloodSystem.CurrentActor; //pack.Volume = product.OriginalVolume.HasValue ? product.OriginalVolume : defaultVolume; pack.Volume = volume; if (orgPack != null && product.CreatedDateFromOrgPack.HasValue && product.CreatedDateFromOrgPack.Value) { pack.Date = orgPack.Date; } else { if (packDate != null) { pack.Date = packDate; } else { pack.Date = DateTime.Now; } } pack.ExpirationDate = pack.Date.Value.Add(product.Duration.Value - RedBloodSystem.RootTime); db.Packs.InsertOnSubmit(pack); db.SubmitChanges(); PackTransactionBLL.Add(pack.ID, Pack.StatusX.Non, Pack.StatusX.Product, orgPack == null ? PackTransaction.TypeX.In_Collect : PackTransaction.TypeX.In_Product); if (orgPack == null) { DonationBLL.SetOriginalPack(DIN, pack.ID); } }
public static void Importing() { //Validate database before insert List <string> importedGeo = new List <string>(); RedBloodDataContext importDB; try { importDB = new RedBloodDataContext(ConfigurationManager.ConnectionStrings["ImportingRedBlood_DBConnectionString"].ConnectionString); //try to load whatever data to test connection importDB.Sexes.ToList(); } catch (Exception ex) { throw ex; } string strImportWithInDays = ConfigurationManager.AppSettings["ImportWithInDays"]; int importWithInDays = 1; if (!string.IsNullOrEmpty(strImportWithInDays)) { importWithInDays = strImportWithInDays.ToInt(); } if (importWithInDays < 1) { importWithInDays = 1; } List <Donation> importDINList = importDB.Donations .Where(r => r.CollectedDate.HasValue && (DateTime.Now.Date - r.CollectedDate.Value.Date).Days <= importWithInDays - 1 && r.PeopleID.HasValue && r.CampaignID.HasValue ) .ToList(); RedBloodDataContext db = new RedBloodDataContext(); foreach (Donation item in importDINList) { //Validate DIN Donation innerDIN = DonationBLL.Get(item.DIN); if (innerDIN == null || innerDIN.CollectedDate.HasValue || innerDIN.PeopleID.HasValue ) { continue; } //Campaign Campaign innerCam = CampaignBLL.Get(item.CampaignID.Value); if (innerCam == null) { continue; } //People if (item.People == null) { continue; } Guid?peopleID = ImportPeople(db, item.People); if (!peopleID.HasValue || peopleID.Value == Guid.Empty) { continue; } //Import DIN DonationBLL.Assign(innerDIN.DIN, peopleID.Value, innerCam.ID, item.CollectedDate, item.Actor); DonationBLL.UpdateCollector(innerDIN.DIN, item.Collector); if (item.Pack != null) { PackBLL.Add(innerDIN.DIN, item.Pack.ProductCode, item.Pack.Volume, packDate: item.Pack.Date); DonationBLL.Update(innerDIN.DIN, item.BloodGroup, "ImportingFromMDF"); } } }