protected void txt_Shelf_TextChanged(object sender, EventArgs e) { try { lbl_Message.Text = ""; var sp = new ShelfProcess(); var input = txt_Shelf.Text.Trim(); int?shelfType = sp.CheckStorage(input, _areaId); if (shelfType != (int)Utility.StorageType.補貨儲位 && shelfType != (int)Utility.StorageType.展售儲位) { lbl_Message.Text = "此儲位只能為補貨/展售儲位!"; gv_product_id.Visible = false; btnPrintShelf.Visible = false; } else { var shipDa = new POS_Library.ShopPos.ShipInDA(); int xx = 1; var BLList = shipDa.GetShelfDetails(input).Select(x => new { 序號 = xx++, 產品編號 = x.ProductId, 產品條碼 = x.Barcode, 數量 = x.Quantity, 價格 = x.Price }).ToList(); if (BLList.Any()) { gv_product_id.DataSource = BLList; gv_product_id.DataBind(); for (var i = 0; i < BLList.Count; i++) { GridViewRow row = gv_product_id.Rows[i]; row.Cells[0].Text = BLList[i].序號.ToString(); row.Cells[1].Text = BLList[i].產品編號; row.Cells[2].Text = BLList[i].產品條碼; DropDownList ddl = row.Cells[3].FindControl("DDL_Quantity") as DropDownList; ddl.SelectedValue = BLList[i].數量; row.Cells[4].Text = BLList[i].價格; } gv_product_id.Visible = true; btnPrintShelf.Visible = true; } } } catch (Exception ex) { lbl_Message.Text = "請輸入正確的資訊!"; gv_product_id.Visible = false; btnPrintShelf.Visible = false; } }
/// <summary> /// default /// </summary> /// <param name="儲位"></param> protected void SetInventory(string 輸入) { try { string str_input = 輸入.Trim(); //儲位條碼 if (CF.CheckID(str_input, CheckFormat.FormatName.Storage)) { Session["ShelfList"] = null; lbl_CurrentNum.Text = "0"; int?shelfType = sp.CheckStorage(str_input, _areaId); if (shelfType == null) { lbl_Message.Text = str_input + " 不存在,請設定!"; lblInventoryLog.Text = ""; return; } var strShelf = CF.CheckShelfType(shelfType.Value, "", (int)POS_Library.ShopPos.EnumData.MergeType.盤點); if (string.IsNullOrEmpty(strShelf)) { //檢查來源儲位是否有檢貨中 var ckTemp = SeachShelf(str_input); if (ckTemp) { return; } #region 查盤點紀錄 var storagelog = sp.GetInventoryLog(str_input, _areaId); if (storagelog != null) { lblInventoryLog.Text = string.Format("上次盤點時間:{0},盤點者:{1}", storagelog.Date.ToString("yyyy-MM-dd HH:mm:ss"), storagelog.Auditor); } #endregion 查盤點紀錄 lbl_Storage_NO.Text = str_input; txt_Input.Text = ""; txt_Input.Focus(); lbl_Product.Text = ""; #region 目前儲位內容 var 目前儲位內容 = sp.GetNowStorageDetail(str_input, _areaId); if (!目前儲位內容.Any()) { lbl_Message.Text = "空儲位"; if (CB_EmptyCantDo.Checked) { btn_Submit.Enabled = false; lbl_Message.Text = "空儲位不可使用盤點功能!"; } return; } else { Session["ShelfList"] = 目前儲位內容; } #endregion 目前儲位內容 lbl_Storage_NO_Type.Text = CF.TypeToName(sp.CheckStorage(str_input, _areaId)); //可按盤點完成 btn_Submit.Enabled = true; } else { lbl_Message.Text = strShelf; return; } } else if (string.IsNullOrEmpty(lbl_Storage_NO.Text)) { lbl_Message.Text = "請先刷儲位條碼!"; } else { if (!string.IsNullOrEmpty(str_input)) { #region 檢查條碼、產品編號 //產編、條碼都可吃 string productName = string.Empty; if (CF.CheckID(str_input, CheckFormat.FormatName.Product)) { productName = sp.GetProductNum(str_input); } else { string ttt = sp.GetProductBarcode(str_input); if (!string.IsNullOrEmpty(ttt)) { productName = str_input; } } if (string.IsNullOrEmpty(productName)) { lbl_Message.Text = "產品條碼錯誤!"; return; } #endregion 檢查條碼、產品編號 //沒輸入就當做1個 int qua = (txt_Num.Text == "" || txt_Num.Text == "1") ? 1 : int.Parse(txt_Num.Text); //儲位內容不為空,一筆一筆過濾 if (Session["ShelfList"] != null) { List <ShelfConfig> list = Session["ShelfList"] as List <ShelfConfig>; //輸入數量幾個就跑幾次 for (int i = 0; i < qua; i++) { bool result = false; foreach (var data in list) { if (data.ProductNumber == productName) { lbl_Product.Text = productName + "<br />" + lbl_Product.Text; //算目前件數 AddCurrentNum(); if (--data.Quantity == 0) { list.Remove(data); } result = true; break; } } if (!result) { lbl_Product.Text = productName + " (多出)<br />" + lbl_Product.Text; //算目前件數 AddCurrentNum(); } } lbl_Message.Text = ""; } else { //儲位內容為空,全部都是多出的 //輸入數量幾個就跑幾次 for (int i = 0; i < qua; i++) { lbl_Product.Text = productName + " (多出)<br />" + lbl_Product.Text; //算目前件數 AddCurrentNum(); } } } } txt_Num.Text = ""; txt_Input.Text = ""; txt_Input.Focus(); } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
protected void txt_Input_TextChanged(object sender, EventArgs e) { ShelfProcess sp = new ShelfProcess(); string str_input = txt_Input.Text.Trim(); //檢查儲位條碼 if (CF.CheckID(str_input, CheckFormat.FormatName.Storage)) { int?shelfType = sp.CheckStorage(str_input, _areaId); if (shelfType == null) { lbl_Message.Text = str_input + " 不存在,請設定!"; return; } //第一次一定要刷入儲位,檢查來源儲位是否已填入 if (string.IsNullOrEmpty(lbl_FromStorage_NO.Text)) { //檢查來源,不可為入庫暫存檢查 + 不良 + 打消 var fromType = shelfType.Value; ViewState["fromType"] = fromType; var strShelf = CF.CheckShelfType(fromType, "", (int)EnumData.MergeType.移動儲位); if (string.IsNullOrEmpty(strShelf)) { Session["ShelfList"] = sp.GetStorageConfig(str_input, _areaId); lbl_FromStorage_NO.Text = str_input; lbl_FromStage_NO_Type.Text = CF.TypeToName(shelfType); lbl_Message.Text = ""; } else { lbl_Message.Text = strShelf; return; } } else { if (str_input == lbl_FromStorage_NO.Text) { lbl_Message.Text = "不能和自己合併!"; } //輸入目的儲位,不可為入庫暫存檢查 string From, Target; From = lbl_FromStorage_NO.Text; Target = str_input; //檢查目的不可為暫存,可為打消、不良 var fromType = int.Parse(ViewState["fromType"].ToString()); var targetType = shelfType.Value; var strShelf = CF.CheckShelfType(fromType, targetType.ToString(), (int)EnumData.MergeType.移動儲位); if (string.IsNullOrEmpty(strShelf)) { lbl_TargetStorage_NO.Text = str_input; lbl_TargetStorage_NO_Type.Text = CF.TypeToName(shelfType); btn_Submit.Visible = true; } else { lbl_Message.Text = strShelf; return; } } } else if (string.IsNullOrEmpty(lbl_FromStorage_NO.Text)) { lbl_Message.Text = "請先刷儲位條碼!"; } else { //產編/條碼都可吃(2013-0426新增)------------ String temp = ""; if (CF.CheckID(str_input, CheckFormat.FormatName.Product)) { temp = sp.GetProductNum(str_input); } else { String ttt = sp.GetProductBarcode(str_input); if (!String.IsNullOrEmpty(ttt)) { temp = str_input; } } string productName = temp; if (!string.IsNullOrEmpty(productName)) { List <ShelfConfig> list = Session["ShelfList"] as List <ShelfConfig>; var 撿貨未確認 = sp.GetTempStorageDetail(lbl_FromStorage_NO.Text, productName, _areaId); if (list != null && list.Count > 0) { #region 判斷內容數量與輸入數量 //取內容數量與輸入數量 int qua = (txt_Num.Text == "" || txt_Num.Text == "1") ? 1 : int.Parse(txt_Num.Text.Trim()); int NowProductNum = list.Where(x => x.ProductNumber == productName).Sum(x => x.Quantity); //數量夠 = true bool Numresult = (qua <= NowProductNum) ? true : false; #endregion 判斷內容數量與輸入數量 //如果夠就扣數 if (Numresult) { bool result = false; #region 輸入數量幾個就跑幾次(2013-0124修改) //輸入數量幾個就跑幾次(2013-0121修改) for (int i = 0; i < qua; i++) { result = false; foreach (var data in list) { if (data.ProductNumber == productName) { lbl_Product.Text = productName + "<br />" + lbl_Product.Text; //算目前件數 lbl_CurrentNum.Text = (int.Parse(lbl_CurrentNum.Text) + 1).ToString(); if (--data.Quantity == 0) { list.Remove(data); } lbl_Message.Text = ""; result = true; break; } } if (!result) { lbl_Message.Text = "儲位無此商品!1"; } } //處理完再塞回去(2014-0110新增) Session["ShelfList"] = list; #endregion 輸入數量幾個就跑幾次(2013-0124修改) #region ●顯示可再移,未確認數量 lbl_Message.Text = "此產品可再移:" + (NowProductNum - qua) + " , 撿貨中:" + 撿貨未確認.Count; #endregion ●顯示可再移,未確認數量 } else { lbl_Message.Text = "此商品剩餘數量為(" + NowProductNum + ")!" + " , 撿貨中:" + 撿貨未確認.Count; } } else { if (撿貨未確認.Count > 0) { lbl_Message.Text = "此商品剩餘數量為(0)!" + " , 撿貨中:" + 撿貨未確認.Count; } else { lbl_Message.Text = "儲位無商品!3"; } } } else { lbl_Message.Text = "產品條碼錯誤!4"; } } txt_Num.Text = ""; txt_Input.Text = ""; txt_Input.Focus(); }
/// <summary> /// 送出 確認移動產品 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_Submit_Click(object sender, EventArgs e) { try { string str_From = lbl_FromStorage_NO.Text; string str_Target = lbl_TargetStorage_NO.Text; int? fromShelfType = sp.CheckStorage(str_From, _areaId); if (fromShelfType == null) { lbl_Message.Text = str_From + " 不存在 請設定!"; } String[] productList = lbl_Product.Text.Split('<'); List <String> productL = new List <String>(); foreach (var data in productList) { var newData = data.Replace("br />", ""); if (newData != "") { productL.Add(newData); } } if (productL.Count > 0) { //此功能不會是入庫 //但可能是無效儲位入有效儲位 var isImport = false; result = sp.MergeStorage(str_From, str_Target, productL, account, _areaId, isImport); if (result.Result == "1") { lbl_Message.Text = result.Reason + " " + str_Target + " 上 " + productL.Count + " 件"; lbl_Product.Text = ""; lbl_CurrentNum.Text = "0"; lbl_FromStorage_NO.Text = (CB_LockFrom.Checked) ? lbl_FromStorage_NO.Text : ""; lbl_FromStage_NO_Type.Text = (CB_LockFrom.Checked) ? lbl_FromStage_NO_Type.Text : ""; lbl_TargetStorage_NO.Text = ""; lbl_TargetStorage_NO_Type.Text = ""; btn_Submit.Visible = false; Session["ShelfList"] = null; //鎖定的話要重讀(2013-0515新增) if (CB_LockFrom.Checked) { Session["ShelfList"] = sp.GetStorageConfig(lbl_FromStorage_NO.Text, _areaId); } } else { lbl_Product.Text = ""; lbl_Message.Text = "失敗! 請檢查<br >【" + str_From + "," + str_Target + "】<br >儲位內容是否正確!<br >" + result.Reason; } } else { lbl_Message.Text = "未刷任何產品!"; } } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// txt改變(刷條碼) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void txt_Input_TextChanged(object sender, EventArgs e) { try { string str_input = txt_Input.Text.Trim(); //檢查儲位條碼 if (CF.CheckID(str_input, CheckFormat.FormatName.Storage)) { #region 儲位條碼 int?shelfType = sp.CheckStorage(str_input, _areaId); if (shelfType == null) { lbl_Message.Text = str_input + " 不存在,請設定!"; } else { //第一次一定要刷入儲位,檢查來源儲位是否已填入 if (string.IsNullOrEmpty(lbl_TargetStorage_NO.Text)) { var fromType = shelfType.Value; var strShelf = CF.CheckShelfType(fromType, "", (int)POS_Library.ShopPos.EnumData.MergeType.問題上架); if (!string.IsNullOrEmpty(strShelf)) { lbl_Message.Text = strShelf; return; } else { var shelfDetail = sp.GetStorageConfig(str_input, _areaId); if (shelfDetail == null) { lbl_Message.Text = "空儲位"; } else { lbl_Message.Text = ""; } lbl_TargetStorage_NO.Text = str_input; lbl_TargetStorage_NO_Type.Text = CF.TypeToName(shelfType); } } else { lbl_Message.Text = "儲位已輸入!"; } } #endregion 儲位條碼 } else if (string.IsNullOrEmpty(lbl_TargetStorage_NO.Text)) { lbl_Message.Text = "請先刷儲位條碼!"; } else { #region 產品編號 string temp = ""; if (CF.CheckID(str_input, CheckFormat.FormatName.Product)) { temp = sp.GetProductNum(str_input); } else { string ttt = sp.GetProductBarcode(str_input); if (!string.IsNullOrEmpty(ttt)) { temp = str_input; } } string productName = temp; if (!string.IsNullOrEmpty(productName)) { #region 輸入數量幾個就跑幾次(2013-0121修改) //沒輸入就當做1個 int qua = (txt_Num.Text == "" || txt_Num.Text == "1") ? 1 : int.Parse(txt_Num.Text.Trim()); //輸入數量幾個就跑幾次(2013-0121修改) for (int i = 0; i < qua; i++) { hide_ProductBarcode.Value += str_input + ","; if (lbl_Product.Text != "") { lbl_Product.Text = productName + "<br />" + lbl_Product.Text; } else { lbl_Product.Text = productName; } //算目前件數 lbl_CurrentNum.Text = (int.Parse(lbl_CurrentNum.Text) + 1).ToString(); } #endregion 輸入數量幾個就跑幾次(2013-0121修改) } else { lbl_Message.Text = "產品條碼錯誤!"; } #endregion 產品編號 } txt_Num.Text = ""; txt_Input.Text = ""; txt_Input.Focus(); } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// txt改變(刷條碼) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void txt_Input_TextChanged(object sender, EventArgs e) { try { string str_input = txt_Input.Text.Trim(); //檢查儲位條碼 if (CF.CheckID(str_input, CheckFormat.FormatName.Storage)) { #region 儲位條碼 int?shelfType = sp.CheckStorage(str_input, _areaId); if (shelfType == null) { lbl_Message.Text = str_input + " 不存在,請設定!"; } else { //第一次一定要刷入儲位,檢查來源儲位是否已填入 if (string.IsNullOrEmpty(lbl_FromStorage_NO.Text)) { var fromType = shelfType.Value; ViewState["fromType"] = fromType; var strShelf = CF.CheckShelfType(fromType, "", (int)POS_Library.ShopPos.EnumData.MergeType.合併儲位); if (string.IsNullOrEmpty(strShelf)) { //檢查來源儲位是否有檢貨中 var ckTemp = SeachShelf(str_input); if (ckTemp) { return; } //新增內容明細(2013-0308新增)---------------------------- list = sp.GetSearchProduct(str_input, _areaId); lbl_Info.Text = ""; lbl_FromStorage_NO.Text = str_input; lbl_FromStage_NO_Type.Text = CF.TypeToName(fromType); lbl_Message.Text = ""; if (list.Count > 0) { //需顯示內容 if (CB_Info.Checked == true) { //轉給label lbl_Info.Text = ResultToInfoList(list); } CountNum(list); lbl_Volume.Text = countv; } else { lbl_Info.Text = "空儲位"; lbl_Volume.Text = "(0 件)"; } //------------------------------------------------------- } else { lbl_Message.Text = strShelf; return; } } else { if (str_input == lbl_FromStorage_NO.Text) { lbl_Message.Text = "不能和自己合併!"; } //輸入目的儲位 //確認來源及目標符合規定 var fromType = int.Parse(ViewState["fromType"].ToString()); var targetType = shelfType.Value; var strShelf = CF.CheckShelfType(fromType, targetType.ToString(), (int)POS_Library.ShopPos.EnumData.MergeType.合併儲位); if (!string.IsNullOrEmpty(strShelf)) { lbl_Message.Text = strShelf; return; } lbl_TargetStorage_NO.Text = str_input; lbl_TargetStorage_NO_Type.Text = CF.TypeToName(shelfType); btn_Submit.Visible = true; } } #endregion 儲位條碼 } else if (string.IsNullOrEmpty(lbl_FromStorage_NO.Text)) { lbl_Message.Text = "請先刷儲位條碼!"; } txt_Input.Text = ""; } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <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(); }
/// <summary> /// txt改變(刷條碼) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void txt_Input_TextChanged(object sender, EventArgs e) { try { lbl_Message.Text = ""; String str_input = txt_Input.Text.Trim(); if (CF.CheckID(str_input, CheckFormat.FormatName.Storage)) { lbl_Info.Text = ""; lbl_Log.Text = ""; lbl_Storage_NO.Text = ""; lbl_Storage_NO_Type.Text = ""; lbl_Volume.Text = ""; if (sp.CheckStorage(str_input, _areaId) == null) { lbl_Message.Text = str_input + " 不存在 請設定!"; } else { list = sp.GetSearchProduct(str_input, _areaId).OrderBy(x => x.ProductNumber).ToList(); lbl_Storage_NO.Text = str_input; lbl_Storage_NO_Type.Text = CF.TypeToName(sp.CheckStorage(str_input, _areaId)); if (list.Count > 0) { //轉給label lbl_Info.Text = ResultToInfoList(list); lbl_Volume.Text = countv; } else { lbl_Info.Text = "空儲位"; //lbl_Volume.Text = "0 / " + sp.GetMaxVolume(str_input, int_treasurytype); } //顯示log if (CB_Log.Checked == true) { var loglist = sp.GetStorageLog(str_input, _areaId); lbl_Log.Text = ResultToLogList((loglist == null) ? loglist : loglist.Where(x => (CB_BOTLog.Checked) ? true : (x.LogAccount != "_BOT_" && x.StorageDetailTypeId != 4)).ToList(), str_input); } else { lbl_Log.Text = ""; } } } else { lbl_Message.Text = "請輸入儲位條碼!"; } txt_Input.Text = ""; txt_Input.Focus(); } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }