Exemple #1
0
    /// <summary>
    /// 執行按鈕
    /// </summary>
    protected void btnRun_Click(object sender, EventArgs e)
    {
        DataBind();

        if (VerifyFormData())
        {
            #region 

            CGDModel.CGDCommon BCOCommon = new CGDModel.CGDCommon();
            System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();

            try
            {
                DataSet dataSet;
                CGDModel.ProcessResetBatchAdj BCO = new CGDModel.ProcessResetBatchAdj(ConntionDB);
                dataSet = ((DataSet)Session[PAGE_DT_01 + PageTimeStamp.Value.ToString()]);

                if (optOperation.SelectedValue == "1" || optOperation.SelectedValue == "2")
                {
                    foreach (DataRow dr in dataSet.Tables[0].Rows)
                    {
                        if (dr["item_no"].ToString().Trim() != "")
                        {
                            string[] chainsSelected = dr["chain"].ToString().Split(new Char[] { '^' });

                            foreach (string chain in chainsSelected)
                            {
                                if (chain.Trim() != "")
                                {
                                    ParameterList.Clear();

                                    ParameterList.Add(slpdStAcceptDate.Text.Trim());
                                    ParameterList.Add(txtPickBatch.Text.Trim());
                                    ParameterList.Add(dr["item_no"].ToString().Trim());
                                    ParameterList.Add(dr["period_no"].ToString().Trim());

                                    string outQty = BCO.QueryItemOutQty(ParameterList);

                                    if (outQty == "")
                                    {
                                        DBT.Rollback();
                                        ErrorMsgLabel.Text = "資料不存在於門市進貨檔,執行中止。";
                                        return;
                                    }
                                    else
                                    {
                                        ParameterList.Clear();
                                        ParameterList.Add(Convert.ToInt16(optOperation.SelectedValue));
                                        ParameterList.Add(slpdStAcceptDate.Text.Trim());
                                        ParameterList.Add(txtPickBatch.Text.Trim());
                                        ParameterList.Add(dr["item_no"].ToString().Trim());
                                        ParameterList.Add(dr["period_no"].ToString().Trim());
                                        ParameterList.Add(chain.Trim());
                                        ParameterList.Add(Session["UID"].ToString());

                                        BCO.ProcessBatchSelect(ParameterList, DBT);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (optOperation.SelectedValue == "3" || optOperation.SelectedValue == "4")
                {
                    foreach (DataRow dr in dataSet.Tables[0].Rows)
                    {
                        if (dr["item_no"].ToString().Trim() != "")
                        {
                            ParameterList.Clear();

                            ParameterList.Add(slpdStAcceptDate.Text.Trim());
                            ParameterList.Add(txtPickBatch.Text.Trim());
                            ParameterList.Add(dr["item_no"].ToString().Trim());
                            ParameterList.Add(dr["period_no"].ToString().Trim());

                            string outQty = BCO.QueryItemOutQty(ParameterList);

                            if (outQty == "")
                            {
                                DBT.Rollback();
                                ErrorMsgLabel.Text = "資料不存在於門市進貨檔,執行中止。";
                                //ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert(' " + "[門市進貨日]      = " + slpdStAcceptDate.Text.Trim() + "\\n" + " [理貨批次]          = " + txtPickBatch.Text.Trim() + "\\n" + " [品號/虛擬品號] = " + dr["item_no"].ToString().Trim() + "\\n" + " [期別]                  = " + dr["period_no"].ToString().Trim() + "\\n" + "\\n" + "之資料不存在於門市進貨檔,執行中止。 ');", true);
                                return;
                            }
                            else if ((Convert.ToInt16(outQty) > 0) && (optOperation.SelectedValue == "4"))
                            {
                                DBT.Rollback();
                                ErrorMsgLabel.Text = "此商品期別數量未刪單,不可執行恢復作業,執行中止。";
                                //ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert(' " + "[門市進貨日]      = " + slpdStAcceptDate.Text.Trim() + "\\n" + " [理貨批次]          = " + txtPickBatch.Text.Trim() + "\\n" + " [品號/虛擬品號] = " + dr["item_no"].ToString().Trim() + "\\n" + " [期別]                  = " + dr["period_no"].ToString().Trim() + "\\n" + "\\n" + "此商品期別數量未刪單,不可執行恢復作業,執行中止。 ');", true);
                                return;
                            }
                            else if ((Convert.ToInt16(outQty) == 0) && (optOperation.SelectedValue == "3"))
                            {
                                DBT.Rollback();
                                ErrorMsgLabel.Text = "此商品期別數量已歸0,不可執行刪單作業,執行中止。";
                                //ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert(' " + "[門市進貨日]      = " + slpdStAcceptDate.Text.Trim() + "\\n" + " [理貨批次]          = " + txtPickBatch.Text.Trim() + "\\n" + " [品號/虛擬品號] = " + dr["item_no"].ToString().Trim() + "\\n" + " [期別]                  = " + dr["period_no"].ToString().Trim() + "\\n" + "\\n" + "此商品期別數量已歸0,不可執行刪單作業,執行中止。 ');", true);
                                return;
                            }
                            else
                            {
                                ParameterList.Clear();
                                ParameterList.Add(Convert.ToInt16(optOperation.SelectedValue));
                                ParameterList.Add(slpdStAcceptDate.Text.Trim());
                                ParameterList.Add(txtPickBatch.Text.Trim());
                                ParameterList.Add(dr["item_no"].ToString().Trim());
                                ParameterList.Add(dr["period_no"].ToString().Trim());
                                ParameterList.Add(Session["UID"].ToString());

                                BCO.ProcessBatchAdj(ParameterList, DBT);
                            }
                        }
                    }
                }
                else if (optOperation.SelectedValue == "5")
                {
                    foreach (DataRow dr in dataSet.Tables[0].Rows)
                    {
                        if (dr["item_no"].ToString().Trim() != "")
                        {
                            string[] chainsSelected = dr["chain"].ToString().Split(new Char[] { '^' });

                            foreach (string chain in chainsSelected)
                            {
                                if (chain.Trim() != "")
                                {
                                    ParameterList.Clear();

                                    ParameterList.Add(slpdStAcceptDate.Text.Trim());
                                    ParameterList.Add(txtPickBatch.Text.Trim());
                                    ParameterList.Add(dr["item_no"].ToString().Trim());
                                    ParameterList.Add(dr["period_no"].ToString().Trim());

                                    string outQty = BCO.QueryItemOutQty(ParameterList);

                                    if (outQty == "")
                                    {
                                        DBT.Rollback();
                                        ErrorMsgLabel.Text = "資料不存在於門市進貨檔,執行中止。";
                                        //ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert(' " + "[門市進貨日]      = " + slpdStAcceptDate.Text.Trim() + "\\n" + " [理貨批次]          = " + txtPickBatch.Text.Trim() + "\\n" + " [品號/虛擬品號] = " + dr["item_no"].ToString().Trim() + "\\n" + " [期別]                  = " + dr["period_no"].ToString().Trim() + "\\n" + "\\n" + "之資料不存在於門市進貨檔,執行中止。 ');", true);
                                        return;
                                    }
                                    else
                                    {
                                        ParameterList.Clear();
                                        ParameterList.Add(slpdStAcceptDate.Text.Trim());
                                        ParameterList.Add(txtPickBatch.Text.Trim());
                                        ParameterList.Add(txtModifiedPickBatch.Text);
                                        ParameterList.Add(dr["item_no"].ToString().Trim());
                                        ParameterList.Add(dr["period_no"].ToString().Trim());
                                        ParameterList.Add(chain.Trim());
                                        ParameterList.Add(Session["UID"].ToString());

                                        BCO.ProcessPickBatch(ParameterList, DBT);
                                    }
                                }
                            }
                        }
                    }
                }

                DBT.Commit();
            }
            catch (Exception ex)
            {
                DBT.Rollback();//交易失敗

                ErrorMsgLabel.Text = ex.Message;
            }
            finally { }

            #endregion

            ErrorMsgLabel.Text = "執行完畢";
        }
    }
Exemple #2
0
    /// <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 { }
        }
    }
Exemple #3
0
    /// <summary>
    /// 將變更後的內部變量this.CallBackValue返回給前台JavaScript方法ReceiveServerData(string Value)。
    /// </summary>
    /// <returns></returns>
    string ICallbackEventHandler.GetCallbackResult()
    {
        string outQty = "";
        string errMsg = "";

        if (CallBackValue != string.Empty)
        {
            string[] s_Client_String = System.Text.RegularExpressions.Regex.Split(CallBackValue, ";", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            ParameterList.Clear();
            ParameterList.Add(s_Client_String[1]);
            ParameterList.Add(s_Client_String[2]);
            ParameterList.Add(s_Client_String[3]);
            ParameterList.Add(s_Client_String[4]);

            CGDModel.ProcessResetBatchAdj BCO = new CGDModel.ProcessResetBatchAdj(ConntionDB);
            outQty = BCO.QueryItemOutQty(ParameterList);
            if (outQty == "0")
            {
                switch (optOperation.SelectedIndex)
                {
                    case 0:
                        errMsg = "此商品期別數量已歸0,不可執行刪單作業";
                        break;

                    case 1:
                        errMsg = "此商品期別數量未刪單,不可執行恢復作業";
                        break;
                    default:
                        errMsg = "此商品期別不存在門市進貨檔";
                        break;
                }
            }
            else
            {
                DataSet ds = (DataSet)Session[PAGE_DT_01 + PageTimeStamp.Value.ToString()];

                for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                {
                    if (ds.Tables[0].Rows[i]["id"].ToString() == s_Client_String[6].ToString())
                    {
                        ds.Tables[0].Rows[i]["qty"] = outQty;
                    }
                }

                Session[PAGE_DT_01 + PageTimeStamp.Value.ToString()] = ds;

                //grdItem.DataSource = ds;
                //grdItem.DataBind();

            }


            CallBackValue = s_Client_String[0] + ";" + s_Client_String[5] + ";" + outQty + ";" + errMsg;
        }
        return CallBackValue;
    }