/// <summary> /// 期別 的TextChanged事件 /// </summary> protected void txtPeriod_TextChanged(object sender, EventArgs e) { TextBox tmpTxtBox = sender as TextBox; GridViewRow gr = (tmpTxtBox.BindingContainer as GridViewRow); int i = gr.RowIndex; string _splItemNO = ((TextBox)grdItem.Rows[i].FindControl("splItemNO")).Text.Trim(); string _splItemNO_Gift = ""; TextBox _splItemName = ((TextBox)grdItem.Rows[i].FindControl("splItemName")); string _Period = ((TextBox)grdItem.Rows[i].FindControl("txtPeriod")).Text.Trim(); string itemName = ""; string outQty = ""; string errMsg = ""; if (_splItemNO != "") { //檢查品號/虛擬品號是否重複 for (int j = 0; j <= grdItem.Rows.Count - 1; j++) { if (j != i) { if ((((TextBox)grdItem.Rows[j].FindControl("splItemNO")).Text.Trim() == ((TextBox)grdItem.Rows[i].FindControl("splItemNO")).Text.Trim()) && (((TextBox)grdItem.Rows[j].FindControl("txtPeriod")).Text.Trim() == ((TextBox)grdItem.Rows[i].FindControl("txtPeriod")).Text.Trim())) { DataSet dataSet = (DataSet)Session[PAGE_DT_01 + PageTimeStamp.Value.ToString()]; DataRow dataRow = dataSet.Tables[0].Rows.Find(Convert.ToInt32(((Label)grdItem.Rows[i].FindControl("lblId")).Text)); dataRow["item_no"] = ""; dataRow["item_name"] = ""; dataRow["period_no"] = ""; dataRow["qty"] = ""; dataRow["chain"] = ""; ((TextBox)grdItem.Rows[i].FindControl("splItemNO")).Text = ""; ((TextBox)grdItem.Rows[i].FindControl("splItemName")).Text = ""; ((TextBox)grdItem.Rows[i].FindControl("txtPeriod")).Text = ""; ((Label)grdItem.Rows[i].FindControl("lblQty")).Text = ""; ErrorMsgLabel.Text = "所輸入之[品號/虛擬品號][期別]已重複"; //ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert(' 所輸入之[品號/虛擬品號][期別]已重複 ');", true); return; } } } try { CGDModel.ProcessResetBatchAdj BCO = new CGDModel.ProcessResetBatchAdj(ConntionDB); //如品號/虛擬品號大於6碼 if ((((TextBox)grdItem.Rows[i].FindControl("splItemNO")).Text.Trim().Length > 6) && (((TextBox)grdItem.Rows[i].FindControl("txtPeriod")).Text.Trim() != "")) { //if (_splItemNO.IndexOf("-") <= 0) //{ // _splItemNO_Gift = _splItemNO.Substring(0, 6) + "-" + _splItemNO.Substring(6); //} //else //{ _splItemNO_Gift = _splItemNO; //} //----先查主品號 //_splItemNO = _splItemNO.Substring(0, 6); //ParameterList.Clear(); //ParameterList.Add(_splItemNO); //itemName = BCO.QueryItemName(ParameterList); //if (itemName == "") //{ // _splItemName.Text = "查無資料"; //} //else //{ // _splItemName.Text = itemName; //} //----查贈品號 ParameterList.Clear(); ParameterList.Add(_splItemNO_Gift); ParameterList.Add(_Period); itemName = BCO.QueryGiftName(ParameterList); if (itemName == "") { _splItemName.Text = "查無資料"; } else { _splItemName.Text = itemName; } } else { if (_splItemNO.Length > 6) { _splItemNO = _splItemNO.Substring(0, 6); } ParameterList.Clear(); ParameterList.Add(_splItemNO); itemName = BCO.QueryItemName(ParameterList); if (itemName == "") { _splItemName.Text = "查無資料"; } else { _splItemName.Text = itemName; } } //查數量 ParameterList.Clear(); ParameterList.Add(slpdStAcceptDate.Text.Trim()); ParameterList.Add(txtPickBatch.Text.Trim()); //if (((TextBox)grdItem.Rows[i].FindControl("splItemNO")).Text.Trim().Length > 6) //{ // ParameterList.Add(((TextBox)grdItem.Rows[i].FindControl("splItemNO")).Text.Trim().Substring(0, 6)); //} //else //{ // ParameterList.Add(((TextBox)grdItem.Rows[i].FindControl("splItemNO")).Text.Trim()); //} ParameterList.Add(((TextBox)grdItem.Rows[i].FindControl("splItemNO")).Text.Trim()); ParameterList.Add(((TextBox)grdItem.Rows[i].FindControl("txtPeriod")).Text.Trim()); outQty = BCO.QueryItemOutQty(ParameterList); if (outQty == "") { errMsg = "此商品期別不存在門市進貨檔"; ErrorMsgLabel.Text = "此商品期別不存在門市進貨檔"; ((Label)grdItem.Rows[i].FindControl("lblQty")).Text = ""; return; } if (outQty == "0") { switch (optOperation.SelectedIndex) { case 0: errMsg = "此商品期別數量已歸0,不可執行刪單作業"; ErrorMsgLabel.Text = "此商品期別數量已歸0,不可執行刪單作業"; break; } ((Label)grdItem.Rows[i].FindControl("lblQty")).Text = outQty; return; } if (Convert.ToInt16(outQty) > 0) { switch (optOperation.SelectedIndex) { case 1: errMsg = "此商品期別數量未刪單,不可執行恢復作業"; ErrorMsgLabel.Text = "此商品期別數量未刪單,不可執行恢復作業"; break; } ((Label)grdItem.Rows[i].FindControl("lblQty")).Text = outQty; return; } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } } }
/// <summary> /// 品號 的TextChanged事件 /// </summary> protected void splItemNO_TextChanged(object sender, EventArgs e) { TextBox tmpTxtBox = sender as TextBox; GridViewRow gr = (tmpTxtBox.BindingContainer as GridViewRow); int i = gr.RowIndex; string _splItemNO = ((TextBox)grdItem.Rows[i].FindControl("splItemNO")).Text.Trim(); TextBox _splItemName = ((TextBox)grdItem.Rows[i].FindControl("splItemName")); string _Period = ((TextBox)grdItem.Rows[i].FindControl("txtPeriod")).Text.Trim(); string itemName = ""; try { if (_splItemNO.Length > 6) { _splItemNO = _splItemNO.Substring(0, 6); } CGDModel.ProcessResetBatchAdj BCO = new CGDModel.ProcessResetBatchAdj(ConntionDB); ParameterList.Clear(); ParameterList.Add(_splItemNO); itemName = BCO.QueryItemName(ParameterList); if (itemName == "") { _splItemName.Text = "查無資料"; } else { _splItemName.Text = itemName; } if (_Period != "") txtPeriod_TextChanged(sender, null); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } }