public void Extract(Guid srcPackID, string productCode) { Pack pack = PackBLL.Get4Extract(srcPackID); PackBLL.Add(pack.DIN, productCode, pack); if (pack.Status != Pack.StatusX.Produced) { PackBLL.ChangeStatus(pack.ID, Pack.StatusX.Produced, PackTransaction.TypeX.Out_Product); } }
public static void Return(int returnID, int packOrderID, string note) { RedBloodDataContext db = new RedBloodDataContext(); PackOrder po = Get4Return(db, packOrderID); po.ReturnID = returnID; db.SubmitChanges(); PackBLL.ChangeStatus(po.Pack.ID, Pack.StatusX.Product, PackTransaction.TypeX.In_Return, note); }
public static void Delete(int deleteID, Guid packID, string note) { RedBloodDataContext db = new RedBloodDataContext(); Pack p = Get4Delete(db, packID); p.DeleteID = deleteID; db.SubmitChanges(); PackBLL.ChangeStatus(p.ID, Pack.StatusX.Delete, PackTransaction.TypeX.Out_Delete, note); }
public void Divide(Guid srcPackID, string division, int volume) { Pack pack = PackBLL.Get4Extract(srcPackID); string newProductCode = pack.ProductCode.Substring(0, pack.ProductCode.Length - 2) + division; PackBLL.Add(pack.DIN, newProductCode, volume, orgPack: pack); if (pack.Status != Pack.StatusX.Produced) { PackBLL.ChangeStatus(pack.ID, Pack.StatusX.Produced, PackTransaction.TypeX.Out_Product); } }
//public static void Add(string DIN, string productCode) //{ // Pack toPack = new Pack(); // toPack.DIN = DIN; // toPack.ProductCode = productCode; // toPack.Status = Pack.StatusX.Product; // toPack.Actor = RedBloodSystem.CurrentActor; // //toPack.Volume = p.OriginalVolume; // toPack.ExpirationDate = DateTime.Now.Add(p.Duration.Value - RedBloodSystem.RootTime); // db.Packs.InsertOnSubmit(toPack); // db.SubmitChanges(); // PackTransactionBLL.Add(toPack.ID, PackTransaction.TypeX.In_Product); // //Update fromPack // PackStatusHistory h = PackBLL.Update(db, pack, Pack.StatusX.Produced, ""); // if (h != null) // { // db.SubmitChanges(); // PackTransactionBLL.Add(pack.ID, PackTransaction.TypeX.Out_Product); // } // return PackErrEnum.Non; //} public static Pack Get4Order(string DIN, string productCode) { Pack p = PackBLL.Get(DIN, productCode); if (p.Status != Pack.StatusX.Product) { throw new Exception("Không thể cấp phát. Túi máu: " + p.Status); } if (p.Donation.TestResultStatus != Donation.TestResultStatusX.Negative) { throw new Exception("Không thể cấp phát túi máu này. KQ xét nghiệm sàng lọc: " + p.Donation.TestResultStatus); } return(p); }
public static PackOrder Get4Return(string DIN, string productCode) { Pack p = PackBLL.Get(DIN, productCode); var v = p.PackOrders.Where(r => !r.ReturnID.HasValue); if (v.Count() > 1) { throw new Exception("Sai dữ liệu. Túi máu cấp phát 2 lần."); } if (v.Count() == 0) { throw new Exception("Chưa có cấp phát túi máu này."); } return(v.FirstOrDefault()); }
public void Divide() { string err = ValidateAllList4Divide(); if (!string.IsNullOrEmpty(err)) { throw new Exception(err); } List <Pack> packList = DINInList.Select(r => PackBLL.Get4Extract(r, ProductCodeInList.FirstOrDefault())).ToList(); foreach (Pack item in packList) { foreach (var item1 in DivisionList) { Divide(item.ID, item1.Ext, item1.Volume); } } }
public void Extract() { string err = ValidateAllList(); if (!string.IsNullOrEmpty(err)) { throw new Exception(err); } List <Pack> packList = DINInList.Select(r => PackBLL.Get4Extract(r, ProductCodeInList.FirstOrDefault())).ToList(); foreach (Pack item in packList) { foreach (string code in ProductCodeOutList) { //TODO: display all err pack. Extract(item.ID, code); } } }
public static int Add(List <Guid> packIDList, string note) { RedBloodDataContext db = new RedBloodDataContext(); List <Pack> poL = PackBLL.Get4Delete(db, packIDList); Delete re = new Delete(); re.Note = note; re.Actor = RedBloodSystem.CurrentActor; db.Deletes.InsertOnSubmit(re); db.SubmitChanges(); foreach (var item in packIDList) { PackBLL.Delete(re.ID, item, note); } return(re.ID); }
public static void Add(int orderID, string DIN, string productCode) { RedBloodDataContext db = new RedBloodDataContext(); Order r = OrderBLL.Get4Add(orderID); Pack p = PackBLL.Get4Order(DIN, productCode); PackOrder po = new PackOrder(); po.OrderID = r.ID; po.PackID = p.ID; db.PackOrders.InsertOnSubmit(po); db.SubmitChanges(); PackTransaction.TypeX transType = r.Type == Order.TypeX.ForCR ? PackTransaction.TypeX.Out_Order4CR : r.Type == Order.TypeX.ForOrg ? PackTransaction.TypeX.Out_Order4Org : PackTransaction.TypeX.Out_OrderGen; PackBLL.ChangeStatus(p.ID, Pack.StatusX.Delivered, transType, "PackOrderID = " + po.ID.ToString()); }
public static void Add(string DIN, string productCode, string fullSideEffects, string note) { Pack p = PackBLL.Get4ReportSideEffects(DIN, productCode); if (string.IsNullOrEmpty(fullSideEffects)) { throw new Exception("Phản ứng phụ trống."); } PackSideEffect se = new PackSideEffect(); se.PackID = p.ID; se.SetSideEffect(fullSideEffects); se.Actor = RedBloodSystem.CurrentActor; se.Date = DateTime.Now; se.Note = note; RedBloodDataContext db = new RedBloodDataContext(); db.PackSideEffects.InsertOnSubmit(se); db.SubmitChanges(); }
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"); } } }
public ActionResult _612(DateTime? from, DateTime? to) { if (!from.HasValue || !to.HasValue) { from = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); to = DateTime.Now.Date; } ViewBag.from = from.Value.ToStringVNLong(); ViewBag.to = to.Value.ToStringVNLong(); RedBloodDataContext db = new RedBloodDataContext(); db.CommandTimeout = 3600; PackBLL packBLL = new PackBLL(); var end = packBLL.GetRemainByDate(to.Value) .Where(r => Product.Apheresis.ProductCodeList.Contains(r.ProductCode)) .Select(r => new { r.Donation.BloodGroup }) .ToList() .GroupBy(r => BloodGroupBLL.GetLetter(r.BloodGroup)) .Select(r => new { ABO = r.Key, Count = r.Count(), }) .ToList(); ViewBag.L = db.PackTransactions .Where(r => from <= r.Date && r.Date <= to && Product.Apheresis.ProductCodeList.Contains(r.Pack.ProductCode)) .Select(r => new { r.Pack.ProductCode, r.Pack.Donation.BloodGroup, r.Type }) .ToList() .GroupBy(r => new { r.ProductCode, r.BloodGroup, r.Type }) .Select(r => new { r.Key.ProductCode, r.Key.BloodGroup, r.Key.Type, Count = r.Count() }) .ToList() .GroupBy(r => BloodGroupBLL.GetLetter(r.BloodGroup)) .Select(r => new Rpt612 { ABO = r.Key, In = r.Where(r1 => PackTransactionBLL.InTypeList.Contains(r1.Type)).Sum(r1 => r1.Count), Out = r.Where(r1 => PackTransactionBLL.OutTypeList.Contains(r1.Type)).Sum(r1 => r1.Count), End = end.Where(r1 => r1.ABO == r.Key).FirstOrDefault() != null ? end.Where(r1 => r1.ABO == r.Key).FirstOrDefault().Count : 0, }).ToList(); return View(); }
public ActionResult _609(string productCode, DateTime? from, DateTime? to, bool? Start, bool? In, bool? Out, bool? End) { if (!Start.HasValue) Start = true; if (!End.HasValue) End = true; if (!In.HasValue) In = true; if (!Out.HasValue) Out = true; if (!from.HasValue || !to.HasValue) { from = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); to = DateTime.Now.Date; } ViewBag.from = from.Value.ToStringVNLong(); ViewBag.to = to.Value.ToStringVNLong(); ViewBag.chkStart = Start.Value; ViewBag.chkEnd = End.Value; ViewBag.chkIn = In.Value; ViewBag.chkOut = Out.Value; RedBloodDataContext db = new RedBloodDataContext(); ViewBag.Start = new List<RptModel1>(); ViewBag.End = new List<RptModel1>(); ViewBag.In = new List<RptModel1>(); ViewBag.Out = new List<RptModel1>(); PackBLL packBLL = new PackBLL(); if (Start.HasValue && Start.Value) { ViewBag.Start = packBLL.GetRemainByDate(from.Value) .Where(r => r.ProductCode == productCode) .Select(r => new { r.ID }.ToExpando()) .ToList() ; } if (End.HasValue && End.Value) { ViewBag.End = packBLL.GetRemainByDate(to.Value) .Where(r => r.ProductCode == productCode) .Select(r => new { r.ID }.ToExpando()) .ToList() ; } Func<IGrouping<string, Rpt608_M1>, string, int> f1 = (l, aboLetter) => { return l.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == aboLetter).Sum(r1 => r1.Count); }; if (In.HasValue && In.Value) { ViewBag.In = db.PackTransactions .Where(r => (r.Type == PackTransaction.TypeX.In_Collect || r.Type == PackTransaction.TypeX.In_Product) && from <= r.Date && r.Date <= to ) .Where(r => r.Pack.ProductCode == productCode) .Select(r => new { ID = r.PackID }.ToExpando()) .ToList() ; } if (Out.HasValue && Out.Value) { ViewBag.Out = db.PackTransactions .Where(r => PackTransactionBLL.OutTypeList.Contains(r.Type) && from <= r.Date && r.Date <= to ) .Where(r => r.Pack.ProductCode == productCode) .Select(r => new { ID = r.PackID }.ToExpando()) .ToList() ; } return View(); }
public ActionResult _608(DateTime? from, DateTime? to, bool? Start, bool? In, bool? Out, bool? End) { if (!Start.HasValue) Start = true; if (!End.HasValue) End = true; if (!In.HasValue) In = true; if (!Out.HasValue) Out = true; if (!from.HasValue || !to.HasValue) { from = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); to = DateTime.Now.Date; } ViewBag.from = from.Value.ToStringVNLong(); ViewBag.to = to.Value.ToStringVNLong(); ViewBag.chkStart = Start.Value; ViewBag.chkEnd = End.Value; ViewBag.chkIn = In.Value; ViewBag.chkOut = Out.Value; RedBloodDataContext db = new RedBloodDataContext(); db.CommandTimeout = 3600; ViewBag.Start = new List<RptModel1>(); ViewBag.End = new List<RptModel1>(); ViewBag.In = new List<RptModel1>(); ViewBag.Out = new List<RptModel1>(); PackBLL packBLL = new PackBLL(); if (Start.HasValue && Start.Value) { ViewBag.Start = packBLL.GetRemainByDate(from.Value) .Select(r => new { r.ProductCode, r.Donation.BloodGroup }) .ToList() .GroupBy(r => r.ProductCode) .Select(r => new RptModel1 { ProductCode = r.Key, Name = ProductBLL.GetGroupName(r.Key), Sum = r.Count(), A = r.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == BloodGroup.ABOLetter_A).Count(), B = r.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == BloodGroup.ABOLetter_B).Count(), AB = r.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == BloodGroup.ABOLetter_AB).Count(), O = r.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == BloodGroup.ABOLetter_O).Count(), }).ToList(); } if (End.HasValue && End.Value) { ViewBag.End = packBLL.GetRemainByDate(to.Value) .Select(r => new { r.ProductCode, r.Donation.BloodGroup }) .ToList() .GroupBy(r => r.ProductCode) .Select(r => new RptModel1 { ProductCode = r.Key, Name = ProductBLL.GetGroupName(r.Key), Sum = r.Count(), A = r.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == BloodGroup.ABOLetter_A).Count(), B = r.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == BloodGroup.ABOLetter_B).Count(), AB = r.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == BloodGroup.ABOLetter_AB).Count(), O = r.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == BloodGroup.ABOLetter_O).Count(), }).ToList(); } Func<IGrouping<string, Rpt608_M1>, string, int> f1 = (l, aboLetter) => { return l.Where(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup) == aboLetter).Sum(r1 => r1.Count); }; if (In.HasValue && In.Value) { ViewBag.In = db.PackTransactions .Where(r => (r.Type == PackTransaction.TypeX.In_Collect || r.Type == PackTransaction.TypeX.In_Product) && from <= r.Date && r.Date <= to ) .GroupBy(r => new { r.Pack.ProductCode, r.Pack.Donation.BloodGroup }) .Select(r => new Rpt608_M1 { ProductCode = r.Key.ProductCode, BloodGroup = r.Key.BloodGroup, Count = r.Count() }) .ToList() .GroupBy(r => r.ProductCode) .Select(r => new RptModel1 { ProductCode = r.Key, Name = ProductBLL.GetGroupName(r.Key), Sum = r.Sum(r1 => r1.Count), A = f1(r, BloodGroup.ABOLetter_A), B = f1(r, BloodGroup.ABOLetter_B), AB = f1(r, BloodGroup.ABOLetter_AB), O = f1(r, BloodGroup.ABOLetter_O), }).ToList(); } if (Out.HasValue && Out.Value) { ViewBag.Out = db.PackTransactions .Where(r => PackTransactionBLL.OutTypeList.Contains(r.Type) && from <= r.Date && r.Date <= to ) .GroupBy(r => new { r.Pack.ProductCode, r.Pack.Donation.BloodGroup }) .Select(r => new Rpt608_M1 { ProductCode = r.Key.ProductCode, BloodGroup = r.Key.BloodGroup, Count = r.Count() }) .ToList() .ToList() .GroupBy(r => r.ProductCode) .Select(r => new RptModel1 { ProductCode = r.Key, Name = ProductBLL.GetGroupName(r.Key), Sum = r.Sum(r1 => r1.Count), A = f1(r, BloodGroup.ABOLetter_A), B = f1(r, BloodGroup.ABOLetter_B), AB = f1(r, BloodGroup.ABOLetter_AB), O = f1(r, BloodGroup.ABOLetter_O), }).ToList(); } return View(); }
public static List <PackSideEffect> Get(string DIN, string productCode) { return(PackBLL.Get4ReportSideEffects(DIN, productCode).PackSideEffects.ToList()); }
private void Extract(Guid srcPackID, string productCode, int productionID, bool isAllowPos) { if (productionID <= 0) throw new Exception("Production null"); PackBLL bll = new PackBLL(); Pack pack = bll.Get4Extract(srcPackID, isAllowPos); var newP = PackBLL.Add(pack.DIN, productCode, pack); if (pack.Status != Pack.StatusX.Produced) PackBLL.ChangeStatus(pack.ID, Pack.StatusX.Produced, PackTransaction.TypeX.Out_Product); var pDetail = new ProductionDetail() { ProductionID = productionID, FromPackID = pack.ID, ToPackID = newP.ID, }; Add(pDetail); }
private void Divide(Guid srcPackID, string division, int volume, int productionID) { PackBLL bll = new PackBLL(); Pack pack = bll.Get4Extract(srcPackID); string newProductCode = pack.ProductCode.Substring(0, pack.ProductCode.Length - 2) + division; var newP = PackBLL.Add(pack.DIN, newProductCode, volume, orgPack: pack); if (pack.Status != Pack.StatusX.Produced) PackBLL.ChangeStatus(pack.ID, Pack.StatusX.Produced, PackTransaction.TypeX.Out_Product); var pDetail = new ProductionDetail() { ProductionID = productionID, FromPackID = pack.ID, ToPackID = newP.ID, }; Add(pDetail); }
public int Extract(string note, bool isAllowPos = false) { var p = new Production() { Actor = RedBloodSystem.CurrentActor, Note = note, FromProductCode1 = ProductCodeInList.ElementAtOrDefault(0), FromProductCode2 = ProductCodeInList.ElementAtOrDefault(1), FromProductCode3 = ProductCodeInList.ElementAtOrDefault(2), ToProductCode1 = ProductCodeOutList.ElementAtOrDefault(0), ToProductCode2 = ProductCodeOutList.ElementAtOrDefault(1), ToProductCode3 = ProductCodeOutList.ElementAtOrDefault(2), Type = Production.TypeX.Extract, }; p = Create(p); PackBLL bll = new PackBLL(); string err = ValidateAllList(); if (!string.IsNullOrEmpty(err)) throw new Exception(err); List<Pack> packList = DINInList.Select(r => bll.Get4Extract(r, ProductCodeInList.FirstOrDefault(), isAllowPos)).ToList(); foreach (Pack item in packList) { foreach (string code in ProductCodeOutList) { //TODO: display all err pack. Extract(item.ID, code, p.ID, isAllowPos); } } return p.ID; }
public void Divide(string note) { var p = new Production() { Actor = RedBloodSystem.CurrentActor, Note = note, FromProductCode1 = ProductCodeInList.ElementAtOrDefault(0), FromProductCode2 = ProductCodeInList.ElementAtOrDefault(1), FromProductCode3 = ProductCodeInList.ElementAtOrDefault(2), //TODO: Ser value for ProductCodeOutList //ToProductCode1 = ProductCodeOutList.ElementAtOrDefault(0), //ToProductCode2 = ProductCodeOutList.ElementAtOrDefault(1), //ToProductCode3 = ProductCodeOutList.ElementAtOrDefault(2), Type = Production.TypeX.Divide, }; p = Create(p); PackBLL bll = new PackBLL(); string err = ValidateAllList4Divide(); if (!string.IsNullOrEmpty(err)) throw new Exception(err); List<Pack> packList = DINInList.Select(r => bll.Get4Extract(r, ProductCodeInList.FirstOrDefault())).ToList(); foreach (Pack item in packList) { foreach (var item1 in DivisionList) { Divide(item.ID, item1.Ext, item1.Volume, p.ID); } } }