Пример #1
0
        //isSOD: isStartOfDate
        //public static void ScanExp(bool isSOD)
        //{
        //if (!isSOD || !LogBLL.IsLog(Task.TaskX.ScanExp))
        //{
        //    RedBloodDataContext db = new RedBloodDataContext();

        //    List<Pack.StatusX> statusList = new List<Pack.StatusX> { Pack.StatusX.Product };

        //    IQueryable<Pack> rs = db.Packs.Where(r => statusList.Contains(r.Status) && r.ExpirationDate < DateTime.Now.Date);

        //    foreach (Pack r in rs)
        //    {
        //        PackStatusHistory h = PackBLL.Update(db, r, Pack.StatusX.Expired, RedBloodSystem.SODActor, "");

        //        if (h != null) db.PackStatusHistories.InsertOnSubmit(h);
        //    }

        //    db.SubmitChanges();

        //    LogBLL.Add(Task.TaskX.ScanExp);
        //}
        //}

        //isSOD: isStartOfDate
        //public static void CloseOrder(bool isSOD)
        //{
        //    //if (!isSOD || !LogBLL.IsLog(Task.TaskX.CloseOrder))
        //    //{
        //    //    RedBloodDataContext db = new RedBloodDataContext();

        //    //    OrderBLL.CloseOrder(db);

        //    //    db.SubmitChanges();

        //    //    LogBLL.Add(Task.TaskX.CloseOrder);
        //    //}
        //}

        //isSOD: isStartOfDate
        //public static void LockTestResult()
        //{
        //if (!isSOD || !LogBLL.IsLog(Task.TaskX.LockEnterTestResult))
        //{
        //    RedBloodDataContext db = new RedBloodDataContext();

        //    PackBLL.LockEnterTestResult();

        //    db.SubmitChanges();

        //    LogBLL.Add(Task.TaskX.LockEnterTestResult);
        //}
        //}

        /// <summary>
        /// if true, count remaining packs directly in store
        /// else count by sum up the remaining of previous date and total transaction in day
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        //static bool IsCountDirectly(DateTime date)
        //{
        //    RedBloodDataContext db = new RedBloodDataContext();

        //    bool isCountDirectly = false;

        //    //new system, no data
        //    if (db.PackTransactions.Count() == 0)
        //        isCountDirectly = true;
        //    else
        //    {
        //        if (lastPackTransactionDate == null) throw new Exception("");
        //        else
        //        {
        //            GetLastTransactionDate();

        //            //All pack transactions were in the previous of the date.
        //            if (lastPackTransactionDate.Value.Date <= date.Date)
        //                isCountDirectly = true;
        //        }
        //    }
        //    return isCountDirectly;
        //}

        public static void Find(HttpResponse Response, TextBox txtCode)
        {
            if (txtCode == null)
            {
                return;
            }

            string key = txtCode.Text.Trim();

            if (key.Length == 0)
            {
                return;
            }

            string pattern = @"\d+";
            Regex  regx    = new Regex(pattern);

            if (BarcodeBLL.IsValidPeopleCode(key))
            {
                People r = PeopleBLL.GetByCode(key);
                if (r != null)
                {
                    Response.Redirect(RedBloodSystem.Url4PeopleDetail + "key=" + r.ID.ToString());
                }
            }
            else if (BarcodeBLL.IsValidDINCode(key))
            {
                Response.Redirect(RedBloodSystem.Url4DINDetail + "key=" + BarcodeBLL.ParseDIN(key));
            }
            else if (BarcodeBLL.IsValidCampaignCode(key))
            {
                Campaign r = CampaignBLL.Get(BarcodeBLL.ParseCampaignID(key));
                if (r != null)
                {
                    Response.Redirect(RedBloodSystem.Url4CampaignDetail + "key=" + r.ID.ToString());
                }
            }
            else if (BarcodeBLL.IsValidOrderCode(key))
            {
                Order r = OrderBLL.Get(BarcodeBLL.ParseOrderID(key));
                if (r != null)
                {
                    Response.Redirect(RedBloodSystem.Url4Order4CR + "key=" + r.ID.ToString());
                }
            }
            else if (key.Length > 3 && key.Substring(0, 3) == "/n:")
            {
                Response.Redirect(RedBloodSystem.Url4FindPeople + "key=" + key.Substring(3).Trim());
            }
            else if (regx.IsMatch(key) && key.Length >= BarcodeBLL.CMNDLength.ToInt())
            {
                People r = PeopleBLL.GetByCMND(key);
                if (r != null)
                {
                    Response.Redirect(RedBloodSystem.Url4PeopleDetail + "key=" + r.ID.ToString());
                }
            }

            txtCode.Text = "";
        }
Пример #2
0
 public static IEnumerable <Donation> Get(int campaignID)
 {
     return(CampaignBLL.Get(campaignID).Donations);
 }
Пример #3
0
 public static List <Donation> GetUnLock(int campaignID)
 {
     return(CampaignBLL.Get(campaignID).CollectedDonations
            .ToList()
            .Where(r => !r.IsTRLocked).ToList());
 }
Пример #4
0
        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");
                }
            }
        }