Пример #1
0
        /// <summary>
        /// 原js改寫
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void txt_VerifyCheck_NO_TextChanged(object sender, EventArgs e)
        {
            try
            {
                lbl_Message.Text = "";
                CheckFormat CF = new CheckFormat();
                LB_Product_Id1.ClearSelection();
                LB_Product_Id2.ClearSelection();
                //全過
                if (txt_VerifyCheck_NO.Text == "2")
                {
                    int total = LB_Product_Id1.Items.Count;
                    for (int i = 0; i < total; i++)
                    {
                        LB_Product_Id2.Items.Insert(0, LB_Product_Id1.Items[0]);
                        LB_Product_Id1.Items.Remove(LB_Product_Id1.Items[0]);
                    }
                }
                //還原一筆
                else if (txt_VerifyCheck_NO.Text == "0")
                {
                    if (LB_Product_Id2.Items.Count > 0)
                    {
                        LB_Product_Id1.Items.Insert(0, LB_Product_Id2.Items[0]);
                        LB_Product_Id2.Items.Remove(LB_Product_Id2.Items[0]);
                    }
                }
                else if (Regex.IsMatch(txt_VerifyCheck_NO.Text, "^\\d{8}$"))
                {
                    bool find = false;
                    for (int i = 0; i < LB_Product_Id1.Items.Count; i++)
                    {
                        if (LB_Product_Id1.Items[i].Value.Split(',')[0] == txt_VerifyCheck_NO.Text)
                        {
                            LB_Product_Id2.Items.Insert(0, LB_Product_Id1.Items[i]);
                            LB_Product_Id1.Items.Remove(LB_Product_Id1.Items[i]);

                            find = true;
                            break;
                        }
                    }

                    //如果不在清單中 顯示(多出)
                    if (!find)
                    {
                        lbl_Message.Text = "這個商品不是這張傳票的!";
                    }
                }
                //如果輸入的是儲位barcode 跳至差異清單
                else if (CF.CheckID(txt_VerifyCheck_NO.Text.Trim(), CheckFormat.FormatName.Storage))
                {
                    string       storage     = txt_VerifyCheck_NO.Text.Trim();
                    var          listLeft    = new List <string>();
                    var          listRight   = new List <string>();
                    int          areaId      = int.Parse(ViewState["areaId"].ToString());
                    var          flowType    = ViewState["flowType"].ToString();
                    var          importType  = ViewState["importType"].ToString();
                    var          ticketType  = ViewState["ticketType"].ToString();
                    ShelfProcess sp          = new ShelfProcess();
                    var          shelf       = sp.GetSearchStorage(storage, areaId);
                    var          storageType = EnumData.StorageType.標準暫存儲位;
                    //if (_flowType == (int)EnumData.FlowType.門市調回)
                    //{
                    //    storageType = EnumData.StorageType.調回暫存儲位;
                    //}
                    //else if (_flowType == (int)EnumData.FlowType.換貨)
                    //{
                    //    storageType = EnumData.StorageType.換貨暫存儲位;
                    //}
                    //else if (_flowType == (int)EnumData.FlowType.台組進貨)
                    //{
                    //    storageType = EnumData.StorageType.海運暫存儲位;
                    //}

                    if (shelf.Type != (int)storageType)
                    {
                        lbl_Message.Text = "這個儲位不屬於" + storageType.ToString() + "!";
                        return;
                    }

                    //串多少& 缺少的字串
                    for (int i = 0; i < LB_Product_Id1.Items.Count; i++)
                    {
                        listLeft.Add(LB_Product_Id1.Items[i].Text.Split('_')[0]);
                    }
                    var productDatas = new List <ImportClass.ProductData>();
                    for (int i = 0; i < LB_Product_Id2.Items.Count; i++)
                    {
                        var productData = new ImportClass.ProductData();
                        productData.Id       = LB_Product_Id2.Items[i].Value.Split(',')[4];
                        productData.Name     = LB_Product_Id2.Items[i].Text.Split('_')[0];
                        productData.Quantity = int.Parse(LB_Product_Id2.Items[i].Value.Split(',')[3]);
                        productData.Ticket   = LB_Product_Id2.Items[i].Value.Split(',')[1];
                        productDatas.Add(productData);

                        listRight.Add(LB_Product_Id2.Items[i].Text.Split('_')[0]);
                    }

                    if (listLeft.Any())
                    {
                        lbl_Message.Text        = "以下產品尚未驗完:" + string.Join(",", listLeft.Count);
                        txt_VerifyCheck_NO.Text = "";
                        return;
                    }

                    if (!listRight.Any())
                    {
                        lbl_Message.Text = "還沒驗到貨!請再次確認!";
                        return;
                    }

                    Session["ProductDatas"] = productDatas;
                    Session["storage"]      = storage;
                    Session["flowType"]     = flowType;
                    Session["pagekey"]      = lblbox.Text;
                    //------------------------------------------------------
                    //箱號驗貨
                    var url = "DiffList.aspx?storage=" + storage + "&ticketType=" + ticketType + "&flowType=" + flowType + "&pagekey=" + lblbox.Text + "&areaId=" + areaId + "&importType=" + importType;

                    //Response.Redirect(url);
                    Page.RegisterClientScriptBlock("checkinput", @"<script>window.open('" + url + "','_self');</script>");

                    txt_VerifyCheck_NO.Enabled = false;
                }
                else
                {
                    lbl_Message.Text = "這個商品不是這張傳票的!";
                }

                txt_VerifyCheck_NO.Text = "";

                //更新數量
                CheckNumToLabel();

                txt_VerifyCheck_NO.Focus();
            }
            catch (Exception ex)
            {
                Response.Write("系統發生錯誤 " + ex.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// 輸入txtbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void txt_VerifyCheck_NO_TextChanged(object sender, EventArgs e)
        {
            lbl_Message.Text = "";

            var          store  = int.Parse(ViewState["store"].ToString());
            var          areaId = int.Parse(ViewState["areaId"].ToString());
            ShelfProcess sp     = new ShelfProcess();
            CheckFormat  CF     = new CheckFormat();

            LB_Product_Id1.ClearSelection();
            LB_Product_Id2.ClearSelection();
            var 傳票ID = lbl_ticket_id.Text.Trim();

            //全過
            if (txt_VerifyCheck_NO.Text == "2")
            {
                int total = LB_Product_Id1.Items.Count;
                for (int i = 0; i < total; i++)
                {
                    LB_Product_Id2.Items.Insert(0, LB_Product_Id1.Items[0]);
                    LB_Product_Id1.Items.Remove(LB_Product_Id1.Items[0]);
                }
            }

            //還原一筆
            else if (txt_VerifyCheck_NO.Text == "0")
            {
                if (LB_Product_Id2.Items.Count > 0)
                {
                    LB_Product_Id1.Items.Insert(0, LB_Product_Id2.Items[0]);
                    LB_Product_Id2.Items.Remove(LB_Product_Id2.Items[0]);
                }
            }

            //確認
            else if (txt_VerifyCheck_NO.Text == "1")
            {
                if (LB_Product_Id1.Items.Count != 0)
                {
                    lbl_Message.Text = "部分商品未驗!";
                    return;
                }
                else if (string.IsNullOrEmpty(傳票ID))
                {
                    lbl_Message.Text = "傳票不可為空!";
                    return;
                }
                else
                {
                    var shipDa = new POS_Library.ShopPos.ShipOutDA();
                    var msg    = shipDa.LeaveWithVerify(int.Parse(傳票ID), account, store, DateTime.Now, areaId);
                    if (msg.Result == "1")
                    {
                        lbl_Message.Text           = "驗貨完成!";
                        txt_VerifyCheck_NO.Enabled = false;
                    }
                    else
                    {
                        lbl_Message.Text = msg.Reason;
                    }
                }
            }

            //產品編號
            else if (Regex.IsMatch(txt_VerifyCheck_NO.Text, "^\\d{8}$"))
            {
                bool find = false;

                for (int i = 0; i < LB_Product_Id1.Items.Count; i++)
                {
                    //if (LB_Product_Id1.Items[i].Value == txt_VerifyCheck_NO.Text)
                    //{
                    //lbl_Message.Text = LB_Product_Id1.Items[i].Value.Split(',')[4];
                    if (LB_Product_Id1.Items[i].Value.Split(',')[0] == txt_VerifyCheck_NO.Text)
                    {
                        LB_Product_Id2.Items.Insert(0, LB_Product_Id1.Items[i]);
                        LB_Product_Id1.Items.Remove(LB_Product_Id1.Items[i]);
                        find = true;
                        break;
                    }
                }

                if (!find)
                {
                    lbl_Message.Text = "這個商品不是這張傳票的!";

                    //LB_Product_Id2.Items.Insert(0, new ListItem(sp.GetProductNum(txt_VerifyCheck_NO.Text) + "(多出)", txt_VerifyCheck_NO.Text));
                }
            }
            else if (CF.CheckID(txt_VerifyCheck_NO.Text, CheckFormat.FormatName.Storage))
            {
                if (LB_Product_Id1.Items.Count == 0)
                {
                    int?type = sp.CheckStorage(txt_VerifyCheck_NO.Text, areaId);

                    if (type == 6 || type == 7)
                    {
                        string product = "";

                        for (int i = 0; i < LB_Product_Id2.Items.Count; i++)
                        {
                            product  = string.IsNullOrEmpty(product) ? product : product + ",";
                            product += LB_Product_Id2.Items[i].Text;
                        }

                        //Response.Redirect("~/DiffList.aspx?product=" + product + "&ticketId=" + lbl_ticket_id.Text + "&storage=" + txt_VerifyCheck_NO.Text.Trim());
                    }
                    else
                    {
                        lbl_Message.Text = "僅可為暫存儲位或不良暫存儲位!";
                    }
                }
                else
                {
                    lbl_Message.Text = "尚有產品未驗!";
                }
            }
            else
            {
                lbl_Message.Text = "這個商品不是這張傳票的!";
            }

            txt_VerifyCheck_NO.Text = "";
            txt_VerifyCheck_NO.Focus();
        }