Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int orgID = Request.Params["key"].ToInt();

            if (orgID != 0)
            {
                OrderID = orgID;
            }
        }
        else
        {
            string code = Master.TextBoxCode.Text.Trim();
            Master.TextBoxCode.Text = "";

            if (BarcodeBLL.IsValidDINCode(code))
            {
                LoadCurrentDIN(BarcodeBLL.ParseDIN(code));
            }
            else if (BarcodeBLL.IsValidOrderCode(code))
            {
                OrderID = BarcodeBLL.ParseOrderID(code);
            }
            else if (BarcodeBLL.IsValidProductCode(code))
            {
                AddPack(BarcodeBLL.ParseProductCode(code));
            }
            else if (BarcodeBLL.IsValidPeopleCode(code))
            {
                //People1.Code = code;
            }
            else if (code.Length >= 9)
            {
                //People1.Code = code;
            }
        }
    }
Exemplo n.º 2
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.Url4PackDetail + "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());
            }
        }
        //TODO: Search by name
        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 = "";
    }