/// <summary>
    /// 編輯參照商品資料
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gv_Result_RowEditing(object sender, GridViewEditEventArgs e)
    {
        #region
        currentGvMode = CurrentGridviewMode.Modify;

        gv_Result.EditIndex = e.NewEditIndex;
        gv_Result.DataSource = dtSetChainRef;
        gv_Result.DataBind();


        hiddenFocusCtrlID.Value = ((TextBox)gv_Result.Rows[e.NewEditIndex].FindControl("txt_ITEM")).ClientID;

        btn_AddNewItemRef.Enabled = false;

        #endregion
    }
    /// <summary>
    /// 更新參照商品資料
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gv_Result_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        #region
        ErrorMsgLabel.Text = "";

        if (IsValid) //驗證通過
        {

            //品號
            string Edit_Item = ((TextBox)gv_Result.Rows[e.RowIndex].Cells[0].FindControl("txt_ITEM")).Text;
            //品名
            string Edit_ItemName = ((HtmlInputHidden)gv_Result.Rows[e.RowIndex].Cells[1].FindControl("RItemName_EditHidden")).Value;
            //期別
            string Edit_Period = ((TextBox)gv_Result.Rows[e.RowIndex].Cells[2].FindControl("txt_PERIOD")).Text;
            //進貨
            string Edit_AcceptQty = ((HtmlInputHidden)gv_Result.Rows[e.RowIndex].Cells[3].FindControl("STACCEPTQTY_EditHidden")).Value;
            //退貨
            string Edit_BackQty = ((HtmlInputHidden)gv_Result.Rows[e.RowIndex].Cells[4].FindControl("BACKWARDQTY_EditHidden")).Value;
            //實績
            string Edit_RealRevenu = ((HtmlInputHidden)gv_Result.Rows[e.RowIndex].Cells[5].FindControl("REALMERIT_EditHidden")).Value;
            //實銷率
            string Edit_RealSaleRate = ((HtmlInputHidden)gv_Result.Rows[e.RowIndex].Cells[6].FindControl("REALSALESRATE_EditHidden")).Value;
            //參照比率
            string Edit_ReferRate = ((TextBox)gv_Result.Rows[e.RowIndex].Cells[7].FindControl("txt_REFER_RATE")).Text;

            DataTable Dt = dtSetChainRef;

            Dt.Rows[e.RowIndex]["CHANNO"] = CHANNO;
            Dt.Rows[e.RowIndex]["ITEM"] = Edit_Item;
            Dt.Rows[e.RowIndex]["ITEM_NAME"] = Edit_ItemName;
            Dt.Rows[e.RowIndex]["PERIOD"] = Edit_Period;
            Dt.Rows[e.RowIndex]["ACCEPT_QTY"] = Edit_AcceptQty;
            Dt.Rows[e.RowIndex]["BACK_QTY"] = Edit_BackQty;
            Dt.Rows[e.RowIndex]["REAL_REVENU"] = Edit_RealRevenu;
            Dt.Rows[e.RowIndex]["REAL_SALERATE"] = Edit_RealSaleRate;
            Dt.Rows[e.RowIndex]["REFER_RATE"] = Edit_ReferRate;

            #region 品號期別重複檢查

            bool CheckData = false;

            for (int i = 0; i < gv_Result.Rows.Count; i++)
            {
                if (i != gv_Result.EditIndex) //不是修改列
                {
                    if ((((Label)gv_Result.Rows[i].Cells[0].FindControl("lbl_ITEM")).Text == Edit_Item) &&
                        (((Label)gv_Result.Rows[i].Cells[0].FindControl("lbl_PERIOD")).Text == Edit_Period)
                       )
                    {
                        CheckData = true;
                        break;
                    }
                }
            }

            #endregion

            if (CheckData) //驗證失敗
            {
                #region 驗證失敗 重新設定Label 的值(JS Label回Server 會掉)

                ((HtmlGenericControl)gv_Result.Rows[e.RowIndex].Cells[9].FindControl("Vaild_EditSaveDuplicate")).Style["display"] = "block";
                //重新設定Label 的值(JS Label回Server 會掉)
                ((Label)gv_Result.Rows[e.RowIndex].Cells[1].FindControl("lbl_Edit_ITEM_NAME")).Text = Edit_ItemName;
                ((Label)gv_Result.Rows[e.RowIndex].Cells[2].FindControl("lbl_ACCEPT_QTY")).Text = Edit_AcceptQty;
                ((Label)gv_Result.Rows[e.RowIndex].Cells[3].FindControl("lbl_BACK_QTY")).Text = Edit_BackQty;
                ((Label)gv_Result.Rows[e.RowIndex].Cells[4].FindControl("lbl_REAL_REVENU")).Text = Edit_RealRevenu;
                ((Label)gv_Result.Rows[e.RowIndex].Cells[5].FindControl("lbl_REAL_SALERATE")).Text = Edit_RealSaleRate;

                #endregion
            }
            else //驗證通過
            {
                #region 驗證通過處理

                ((HtmlGenericControl)gv_Result.Rows[e.RowIndex].Cells[9].FindControl("Vaild_EditSaveDuplicate")).Style["display"] = "none";

                dtSetChainRef = Dt;

                gv_Result.EditIndex = -1;
                gv_Result.DataSource = dtSetChainRef;
                gv_Result.DataBind();

                #region 紀錄參照比率加總值

                int ReferRate_SumValue = 0;
                for (int x = 0; x < Dt.Rows.Count; x++)
                {
                    ReferRate_SumValue += int.Parse(Dt.Rows[x]["REFER_RATE"].ToString());
                }

                GVSumHidden.Value = ReferRate_SumValue.ToString();

                #endregion

                #region 先移除所有相關通路 在加入新資料

                string NEWDataSessionIDAndName = "ALO11NEWStoreChainReferData_" + PrePageTimeStamp;

                //RemoveNewData();

                if (Session[NEWDataSessionIDAndName] != null)
                {
                    //DataTable ProcessDt = (DataTable)Session[NEWDataSessionIDAndName];
                    //ProcessDt.Merge(Dt);


                    DataTable ProcessDt = ((DataTable)Session[NEWDataSessionIDAndName]).Copy();
                    DataRow[] drRows = ProcessDt.Select("CHANNO='" + CHANNO + "'");

                    foreach (DataRow dr in drRows)
                    {
                        ProcessDt.Rows.Remove(dr);
                    }

                    ProcessDt.Merge(Dt);
                    Session[NEWDataSessionIDAndName] = ProcessDt.Copy();

                }
                else
                {
                    Session[NEWDataSessionIDAndName] = Dt.Copy();
                }

                #endregion

                currentGvMode = CurrentGridviewMode.Read;

                btn_AddNewItemRef.Enabled = true;

                #endregion
            }
        }
        #endregion
    }
    /// <summary>
    /// 取消參照商品資料
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gv_Result_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        #region
        if (currentGvMode == CurrentGridviewMode.Insert)
        {
            dtSetChainRef.Rows.Remove(dtSetChainRef.Rows[dtSetChainRef.Rows.Count - 1]);
        }

        gv_Result.EditIndex = -1;
        gv_Result.DataSource = dtSetChainRef;
        gv_Result.DataBind();


        currentGvMode = CurrentGridviewMode.Read;

        btn_AddNewItemRef.Enabled = true;

        #endregion
    }
    /// <summary>
    /// 網頁起始函式
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        #region
        ErrorMsgLabel.Text = "";
        SettingRequestParameter();

        if (!IsPostBack)
        {            
            MakeTempDataTable();
            currentGvMode = CurrentGridviewMode.Read;
            GetDisChanRefer();            
        }

        //btn_Cancel.Attributes["onclick"] += string.Format("if($get('{0}').value.trim()!='100'){1}", GVSumHidden.ClientID, "{alert('參照比率必須為100%!');return false;}");

        #endregion
    }
 /// <summary>
 /// 新增參照品項
 /// </summary>
 private void AddNewRow()
 {
     #region
     try
     {
         DataTable dt = dtSetChainRef;
         DataRow dr;
         if (dt != null)
         {
             dr = dt.NewRow();
             dt.Rows.Add(dr);
             dtSetChainRef = dt;
             currentGvMode = CurrentGridviewMode.Insert;
         }
     }
     catch (Exception ex)
     {
         ErrorMsgLabel.Text = ex.Message;
     }
     #endregion
 }
Beispiel #6
0
    /// <summary>
    /// 取消事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GridView_Detail_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        try
        {
            currentGvMode = CurrentGridviewMode.View;//2010/04/14 added : for check detail's interval

            ErrorMsgLabel.Text = "";

            string DetailTmpSessionIDAndName = "ALO113AddistDetailTmp_" + PageTimeStamp.Value;
            DataTable Dt = (DataTable)Session[DetailTmpSessionIDAndName];

            Dt.Rows.RemoveAt(e.RowIndex);

            GridView_Detail.EditIndex = -1;
            GridView_Detail.DataSource = Dt;
            GridView_Detail.DataBind();

            PageControlStatus(FormStatus.DetailView);
            UpdatePanel_ALOMain.Update();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = "明細取消儲存發生錯誤!錯誤訊息:" + ex.Message;
        }
        finally
        {
            UpdatePanel_ErrorMessage.Update();
        }
    }
Beispiel #7
0
    /// <summary>
    /// 檢查RANK_LEVEL是否已經存在
    /// </summary>
    /// <param name="currentDt"></param>
    /// <param name="i64Index"></param>
    /// <param name="strRankLevel"></param>
    /// <param name="currentGVMode"></param>
    /// <returns></returns>
    private bool CheckRankLevelIsExisted(DataTable currentDt, Int64 i64Index, string strRankLevel, CurrentGridviewMode currentGVMode)
    {
        #region
        bool bResult = true;

        if (currentGVMode == CurrentGridviewMode.Insert)
        {
            for (Int32 i = 0; i <= currentDt.Rows.Count - 1; i++)
            {
                if (currentDt.Rows[i]["RANK_LEVEL"].ToString().Trim() == strRankLevel)
                {
                    bResult = false;
                    break;
                }
            }
        }
        else if (currentGVMode == CurrentGridviewMode.Modify)
        {
            for (Int32 i = 0; i <= currentDt.Rows.Count - 1; i++)
            {
                if (currentDt.Rows[i]["RANK_LEVEL"].ToString().Trim() == strRankLevel)
                {
                    bResult = false;

                    if (currentDt.Rows[i]["ID"].ToString().Trim() == i64Index.ToString().Trim())
                    {
                        bResult = true;
                        break;
                    }
                }
            }
        }

        if (!bResult)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("alert('{0}');", "等級區分不可重複設定"), true);
        }


        return bResult;

        #endregion
    } 
Beispiel #8
0
    /// <summary>
    /// 更新儲存事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GridView_Detail_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";

            if (IsValid)
            {
                string DetailTmpSessionIDAndName = "ALO113AddistDetailTmp_" + PageTimeStamp.Value;
                DataTable Dt = (DataTable)Session[DetailTmpSessionIDAndName];
                Label ErrorLabel = (Label)GridView_Detail.Rows[e.RowIndex].Cells[5].FindControl("DetailError_Label");
                string START_RANKQTY = ((TextBox)GridView_Detail.Rows[e.RowIndex].Cells[1].FindControl("STARTRANKQTY_TxtBox")).Text;
                string END_RANKQTY = ((TextBox)GridView_Detail.Rows[e.RowIndex].Cells[2].FindControl("ENDRANKQTY_TxtBox")).Text;
                string ADJ_QTY = ((TextBox)GridView_Detail.Rows[e.RowIndex].Cells[3].FindControl("ADJQTY_TxtBox")).Text;

                ErrorLabel.Text = "";
                ErrorLabel.Visible = false;

                //for (int x = 0; x < Dt.Rows.Count; x++)
                //{
                //    if ((Dt.Rows[x]["ASSIST_CODE"].ToString() == SelectCondition.Value) &&
                //         (Dt.Rows[x]["START_RANKQTY"].ToString() == START_RANKQTY) &&
                //         (Dt.Rows[x]["END_RANKQTY"].ToString() == END_RANKQTY) &&
                //         (Dt.Rows[x]["ADJ_QTY"].ToString() == ADJ_QTY)
                //        )
                //    {
                //        ErrorLabel.Text = "本數起迄區間不可與存在資料重複!!";
                //        ErrorLabel.Visible = true;
                //        break;
                //    }
                //}
                Int32 iSTART_RANKQTY = 0, iEND_RANKQTY = 0;
                Int32.TryParse(START_RANKQTY, out iSTART_RANKQTY);
                Int32.TryParse(END_RANKQTY, out iEND_RANKQTY);

                //if (ErrorLabel.Text == "") //本數驗證過
                if (CheckDetailDataIntervalIsValid(iSTART_RANKQTY, iEND_RANKQTY))
                {
                    #region
                    //配本序號
                    Dt.Rows[e.RowIndex]["DIS_NO"] = Request.QueryString["DIS_NO"];
                    //商品
                    Dt.Rows[e.RowIndex]["ITEM"] = Request.QueryString["ITEM"];
                    //期別
                    Dt.Rows[e.RowIndex]["PERIOD"] = Request.QueryString["PERIOD"];
                    //本數起
                    Dt.Rows[e.RowIndex]["START_RANKQTY"] = START_RANKQTY;
                    //本數迄
                    Dt.Rows[e.RowIndex]["END_RANKQTY"] = END_RANKQTY;
                    //更新時間
                    Dt.Rows[e.RowIndex]["UPDATEDATE"] = DateTime.Now;
                    //更新日期
                    Dt.Rows[e.RowIndex]["UPDATEUID"] = Session["UID"].ToString();
                    //加減本數
                    Dt.Rows[e.RowIndex]["ADJ_QTY"] = ADJ_QTY;
                    //通路
                    switch (StoreChainRadioButtonList.SelectedIndex)
                    {
                        case 0:
                            Dt.Rows[e.RowIndex]["CHAN_NO"] = "0";
                            break;
                        case 1:
                            Dt.Rows[e.RowIndex]["CHAN_NO"] = SLP_StoreChain1.Text;
                            break;
                    }

                    Session[DetailTmpSessionIDAndName] = Dt;

                    currentGvMode = CurrentGridviewMode.View;//2010/04/14 added : for check detail's interval

                    GridView_Detail.EditIndex = -1;
                    GridView_Detail.DataSource = Dt;
                    GridView_Detail.DataBind();

                    PageControlStatus(FormStatus.DetailView);
                    UpdatePanel_ALOMain.Update();
                    #endregion
                }
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = "明細更新儲存發生錯誤!錯誤訊息:" + ex.Message;
        }
        finally
        {
            UpdatePanel_ErrorMessage.Update();
        }
    }
Beispiel #9
0
    /// <summary>
    /// 修改事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GridView_Detail_RowEditing(object sender, GridViewEditEventArgs e)
    {
        try
        {
            currentGvMode = CurrentGridviewMode.Modify;//2010/04/14 added : for check detail's interval

            string DetailTmpSessionIDAndName = "ALO113AddistDetailTmp_" + PageTimeStamp.Value;
            DataTable Dt = (DataTable)Session[DetailTmpSessionIDAndName];

            iDetailEditingRowIndex = e.NewEditIndex;//2010/04/14 added : for check detail's interval

            GridView_Detail.EditIndex = e.NewEditIndex;
            GridView_Detail.DataSource = Dt;
            GridView_Detail.DataBind();

            PageControlStatus(FormStatus.DetailEdit);
            UpdatePanel_ALOMain.Update();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = "明細修改發生錯誤!錯誤訊息:" + ex.Message;
        }
        finally
        {
            UpdatePanel_ErrorMessage.Update();
        }
    }
Beispiel #10
0
    /// <summary>
    /// 新增明細
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AddDetailBtn_Click(object sender, EventArgs e)
    {
        try
        {

            currentGvMode = CurrentGridviewMode.Insert;//2010/04/14 added : for check detail's interval

            ErrorMsgLabel.Text = "";

            string DetailTmpSessionIDAndName = "ALO113AddistDetailTmp_" + PageTimeStamp.Value;
            DataTable Dt = (DataTable)Session[DetailTmpSessionIDAndName];

            DataRow Dr = Dt.NewRow();
            Dr["ASSIST_CODE"] = s_AssistCode;
            Dt.Rows.Add(Dr);

            Session[DetailTmpSessionIDAndName] = Dt;

            GridView_Detail.EditIndex = Dt.Rows.Count - 1;
            GridView_Detail.DataSource = Dt;
            GridView_Detail.DataBind();

            PageControlStatus(FormStatus.DetailAdd);

            UpdatePanel_ALOMain.Update();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = "新增名細發生錯誤!錯誤訊息:" + ex.Message;
        }
        finally
        {
            UpdatePanel_ErrorMessage.Update();
        }
    }
Beispiel #11
0
    /// <summary>
    /// 配量<前期POS或前期實銷-設定本數事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void QTYLessThanPreSaleSettingQtyBtn_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";

            s_AssistCode = "08";

            DetailGV_Bind(s_AssistCode);
            PageControlStatus(FormStatus.DetailView);

            currentGvMode = CurrentGridviewMode.View;//2010/04/14 added : for check detail's interval

            UpdatePanel_ALOMain.Update();
            UpdatePanel_DetailTab.Update();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            UpdatePanel_ErrorMessage.Update();
        }
    }
Beispiel #12
0
    /// <summary>
    /// 網頁載入事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            ResultMsgLabel.Text = "";

            AuthorityControls(this);

            if (!IsPostBack)
            {
                #region
                PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}",
                                                    DateTime.Now.Year.ToString(),
                                                    DateTime.Now.Month.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Day.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Hour.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Minute.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Second.ToString().PadLeft(2, '0')
                                                    );

                Initialization_Component();

                currentGvMode = CurrentGridviewMode.View;//2010/04/14 added : for check detail's interval

                ToolBarInit();
                //抓取資料
                GetPageData();
                //預設UI
                PageControlStatus(FormStatus.AllQuery);

                SetUIByCheckBoxChecked();//2010/04/15 added 
                #endregion
            }

            //設定TimeOut時間
            ((ScriptManager)Page.Controls[0].Controls[3].FindControl("ScriptManager1")).AsyncPostBackTimeout = 600;

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }