Beispiel #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 = "";
        }
Beispiel #2
0
        private static Guid?ImportPeople(RedBloodDataContext db, People outerP)
        {
            //Importing people
            if (outerP == null || db == null)
            {
                return(null);
            }

            People innerP = PeopleBLL.GetByID(outerP.ID);

            if (innerP == null)
            {
                People newP = new People();

                newP.Name    = outerP.Name;
                newP.DOB     = outerP.DOB;
                newP.DOBYear = outerP.DOBYear;
                newP.CMND    = outerP.CMND;
                newP.SexID   = outerP.SexID;

                GeoBLL.Insert(
                    outerP.ResidentGeo1 != null ? outerP.ResidentGeo1.Name : ""
                    , outerP.ResidentGeo2 != null ? outerP.ResidentGeo2.Name : ""
                    , outerP.ResidentGeo3 != null ? outerP.ResidentGeo3.Name : "");

                newP.ResidentAddress = outerP.ResidentAddress;
                newP.SetResidentGeo3(outerP.FullResidentalGeo);

                if (outerP.EnableMailingAddress.HasValue &&
                    outerP.EnableMailingAddress.Value)
                {
                    GeoBLL.Insert(
                        outerP.MailingGeo1 != null ? outerP.MailingGeo1.Name : ""
                        , outerP.MailingGeo2 != null ? outerP.MailingGeo2.Name : ""
                        , outerP.MailingGeo3 != null ? outerP.MailingGeo3.Name : "");

                    newP.MailingAddress = outerP.MailingAddress;
                    newP.SetMailingGeo3(outerP.FullMaillingGeo);

                    newP.EnableMailingAddress = outerP.EnableMailingAddress;
                }

                newP.Job   = outerP.Job;
                newP.Email = outerP.Email;
                newP.Phone = outerP.Phone;
                newP.Note  = outerP.Note;

                db.Peoples.InsertOnSubmit(newP);
                db.SubmitChanges();

                return(newP.ID);
            }
            else
            {
                return(innerP.ID);
            }
        }
        private static Guid? ImportPeople(RedBloodDataContext db, People outerP)
        {
            //Importing people
            if (outerP == null || db == null) return null;

            PeopleBLL bll = new PeopleBLL();

            People innerP = db.Peoples.Where(r => r.ID == outerP.ID).FirstOrDefault();

            //People innerP = bll.GetByID(outerP.ID);

            if (innerP == null)
            {
                People newP = new People();

                newP.Name = outerP.Name;
                newP.DOB = outerP.DOB;
                newP.DOBYear = outerP.DOBYear;
                newP.CMND = outerP.CMND;
                newP.SexID = outerP.SexID;

                GeoBLL.Insert(
                    outerP.ResidentGeo1 != null ? outerP.ResidentGeo1.Name : ""
                    , outerP.ResidentGeo2 != null ? outerP.ResidentGeo2.Name : ""
                    , outerP.ResidentGeo3 != null ? outerP.ResidentGeo3.Name : "");

                newP.ResidentAddress = outerP.ResidentAddress;
                newP.SetResidentGeo3(outerP.FullResidentalGeo);

                if (outerP.EnableMailingAddress.HasValue
                    && outerP.EnableMailingAddress.Value)
                {
                    GeoBLL.Insert(
                    outerP.MailingGeo1 != null ? outerP.MailingGeo1.Name : ""
                    , outerP.MailingGeo2 != null ? outerP.MailingGeo2.Name : ""
                    , outerP.MailingGeo3 != null ? outerP.MailingGeo3.Name : "");

                    newP.MailingAddress = outerP.MailingAddress;
                    newP.SetMailingGeo3(outerP.FullMaillingGeo);

                    newP.EnableMailingAddress = outerP.EnableMailingAddress;
                }

                newP.Job = outerP.Job;
                newP.Email = outerP.Email;
                newP.Phone = outerP.Phone;
                newP.Note = outerP.Note;

                db.Peoples.InsertOnSubmit(newP);
                db.SubmitChanges();

                return newP.ID;
            }
            else
            {
                innerP.CMND = outerP.CMND;
                innerP.DOB = outerP.DOB;
                innerP.DOBYear = outerP.DOBYear;
                innerP.Email = outerP.Email;
                innerP.EnableMailingAddress = outerP.EnableMailingAddress;
                innerP.Job = outerP.Job;
                innerP.MailingAddress = outerP.MailingAddress;
                innerP.ResidentAddress = outerP.ResidentAddress;

                try
                {
                    innerP.MailingGeoID1 = outerP.MailingGeoID1;
                    innerP.MailingGeoID2 = outerP.MailingGeoID2;
                    innerP.MailingGeoID3 = outerP.MailingGeoID3;

                    innerP.ResidentGeoID1 = outerP.ResidentGeoID1;
                    innerP.ResidentGeoID2 = outerP.ResidentGeoID2;

                    //if (outerP.ResidentGeo2 != null
                    //    && innerP.ResidentGeoID2 == new Guid("bebb4f9b-e54f-4abe-b634-b6441245cec2")
                    //    && outerP.ResidentGeo2.Name == "Phú Riềng")
                    //{
                    //    innerP.ResidentGeoID2 = new Guid("C61F5AC0-702E-4EDA-BB54-0904115F618B");
                    //}

                    innerP.ResidentGeoID3 = outerP.ResidentGeoID3;

                }
                catch (Exception)
                {

                }

                innerP.Name = outerP.Name;
                innerP.Note = outerP.Note;
                innerP.Phone = outerP.Phone;

                innerP.SexID = outerP.SexID;

                db.SubmitChanges();

                return innerP.ID;
            }
        }