예제 #1
0
    /// <summary>
    /// 異動處理
    /// </summary>
    private void DoUpdate()
    {
        #region UPDATE
        bool bResult;
        string SessionIDName = "CAM01_GridView1" + PageTimeStamp.Value;

        DataTable dt = ((DataTable)Session[SessionIDName]);

        GridView1.DataSource = dt;
        GridView1.DataBind();

        DataTable dt_new = dt.GetChanges();
        if (dt_new != null)
        {
            CAMModel.AdjustDocketByStoreGroup BCO = new CAMModel.AdjustDocketByStoreGroup(ConntionDB);
            bResult = BCO.AdjustByStoreGroup(Session["UID"].ToString(), dt_new, null);

            if (bResult)
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('資料更新完成');"), true);
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('沒有需更新的資料');"), true);
        }
        #endregion

        #region UPDATE完重置控制項
        btnUpdate.Enabled = false;
        txtOUT_QTY_G.ReadOnly = true;
        txtOUT_QTY_G.CssClass = "readtxtbox";
        txtCOST_G.ReadOnly = true;
        txtCOST_G.CssClass = "readtxtbox";
        txtOUT_COST_DIS_G.ReadOnly = true;
        txtOUT_COST_DIS_G.CssClass = "readtxtbox";
        txtOUT_PRICE_G.ReadOnly = true;
        txtOUT_PRICE_G.CssClass = "readtxtbox";
        for (int k = 0; k <= GridView1.Rows.Count - 1; k++)
        {
            ((TextBox)GridView1.Rows[k].FindControl("txtOUT_QTY")).ReadOnly = true;
            ((TextBox)GridView1.Rows[k].FindControl("txtOUT_QTY")).CssClass = "readtxtbox";
            ((TextBox)GridView1.Rows[k].FindControl("txtCOST")).ReadOnly = true;
            ((TextBox)GridView1.Rows[k].FindControl("txtCOST")).CssClass = "readtxtbox";
            ((TextBox)GridView1.Rows[k].FindControl("txtOUT_COST_DIS")).ReadOnly = true;
            ((TextBox)GridView1.Rows[k].FindControl("txtOUT_COST_DIS")).CssClass = "readtxtbox";
            ((TextBox)GridView1.Rows[k].FindControl("txtOUT_PRICE")).ReadOnly = true;
            ((TextBox)GridView1.Rows[k].FindControl("txtOUT_PRICE")).CssClass = "readtxtbox";
        }
        panUPDATE_SUMMARY.Visible = true;
        LockControl(false);
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, "", btnUpdate, WUI_GMToolbarV.ClickAction.ButtonClick);
        #endregion
    }
예제 #2
0
    /// <summary>
    /// 查詢
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        try
        {
            #region JS註冊
            // 限制只能 key 入負號+數字
            string strJS = "function OnlyNegNumber(obj,len)";
            strJS += " {";
            strJS += "    var tmpCount = 0; ";
            strJS += "    if(obj.value.substr(0,1) == '-')";
            strJS += "    {";
            strJS += "      len++;  ";
            strJS += "    }";
            strJS += "    if(obj.value.length>len)";
            strJS += "    {";
            strJS += "        obj.value = obj.value.substr(0, obj.value.length-1);";
            strJS += "    }";
            strJS += "       for (var tmpI = 0; tmpI < obj.value.length; tmpI++) ";
            strJS += "       {";
            strJS += "           tmpCount = obj.value.charCodeAt(tmpI);";
            strJS += "           if (tmpI == 0)";
            strJS += "           {";
            strJS += "              if(obj.value.substr(tmpI,1) != '-')";
            strJS += "              {";
            strJS += "                 if((tmpCount < 48) || (tmpCount > 57))";
            strJS += "                 {";
            strJS += "                   obj.value = obj.value.substr(0, tmpI);";
            strJS += "                 }";
            strJS += "              }";
            strJS += "           }";
            strJS += "           else";
            strJS += "           {";
            strJS += "              if((tmpCount < 48) || (tmpCount > 57))";
            strJS += "             {";
            strJS += "              obj.value = obj.value.substr(0, tmpI);";
            strJS += "            }";
            strJS += "        }";
            strJS += "      }";
            strJS += " }";

            // 限制只能 key 入數字
            string strJS1 = "function OnlyNegNumber(obj,len)";
            strJS1 += " {";
            strJS1 += "    var tmpCount = 0;";
            strJS1 += "    if(obj.value.length>len)";
            strJS1 += "    {";
            strJS1 += "        obj.value = obj.value.substr(0, obj.value.length-1);";
            strJS1 += "    }";
            strJS1 += "    for (var tmpI = 0; tmpI < obj.value.length; tmpI++) ";
            strJS1 += "    {";
            strJS1 += "         tmpCount = obj.value.charCodeAt(tmpI);";
            strJS1 += "         if((tmpCount < 48) || (tmpCount > 57))";
            strJS1 += "         {";
            strJS1 += "           obj.value = obj.value.substr(0, tmpI);";
            strJS1 += "         }";
            strJS1 += "     }";
            strJS1 += " }";

            //限制只能 key 入數字+小數點
            string strJS2 = "function OnlyNegNumber(obj,len)";
            strJS2 += " {";
            strJS2 += "    var tmpCount = 0;";
            strJS2 += "    var v_cnt=0;  ";
            strJS2 += "    var v_cnt1=0;  ";

            strJS2 += "    for (var tmpI = 0; tmpI < obj.value.length; tmpI++) ";
            strJS2 += "    {";
            strJS2 += "       tmpCount = obj.value.charCodeAt(tmpI);";
            strJS2 += "        if(tmpCount == 46)";
            strJS2 += "        {";
            strJS2 += "          if(tmpI>len)";
            strJS2 += "          {";
            strJS2 += "             obj.value = obj.value.substr(0, tmpI);";
            strJS2 += "          }";
            strJS2 += "          break;";
            strJS2 += "        }";
            strJS2 += "        else if(tmpI == obj.value.length-1)";
            strJS2 += "        {";
            strJS2 += "          if(tmpI>len-1)";
            strJS2 += "          {";
            strJS2 += "             obj.value = obj.value.substr(0, tmpI);";
            strJS2 += "          }";
            strJS2 += "          break;";
            strJS2 += "        }";
            strJS2 += "    }";

            strJS2 += "    for (var tmpI = 0; tmpI < obj.value.length; tmpI++) ";
            strJS2 += "    {";
            strJS2 += "        tmpCount = obj.value.charCodeAt(tmpI);";
            strJS2 += "        if (tmpI == 0)";
            strJS2 += "        {";
            strJS2 += "             if((tmpCount < 48) || (tmpCount > 57))";
            strJS2 += "            {";
            strJS2 += "               obj.value = obj.value.substr(0, tmpI);";
            strJS2 += "            }";
            strJS2 += "        }";
            strJS2 += "        else";
            strJS2 += "        {";
            strJS2 += "           if(((tmpCount < 48) || (tmpCount > 57)) && tmpCount != 46)";
            strJS2 += "          {";
            strJS2 += "           obj.value = obj.value.substr(0, tmpI);";
            strJS2 += "          }";
            strJS2 += "        }";
            strJS2 += "        if (tmpCount == 46)";
            strJS2 += "        {";
            strJS2 += "           v_cnt++;";
            strJS2 += "           v_cnt1++;";
            strJS2 += "        }";
            strJS2 += "        else";
            strJS2 += "        {";
            strJS2 += "           if (v_cnt1 > 0)";
            strJS2 += "           {";
            strJS2 += "              v_cnt1++;";
            strJS2 += "           }";
            strJS2 += "        }";
            strJS2 += "        if (v_cnt > 1)";
            strJS2 += "        {";
            strJS2 += "            obj.value = obj.value.substr(0, tmpI);";
            strJS2 += "        }";
            strJS2 += "        if (v_cnt1 > 3)";
            strJS2 += "        {";
            strJS2 += "            obj.value = obj.value.substr(0, tmpI);";
            strJS2 += "        }";
            strJS2 += "    }";
            strJS2 += " }";

            if (ddlSTAKind.SelectedValue == "3" || ddlSTAKind.SelectedValue == "4" || ddlSTAKind.SelectedValue == "0")
            {
                txtOUT_QTY_G.Attributes.Add("onkeyup", strJS + " OnlyNegNumber(this,6)");
            }
            else
            {
                txtOUT_QTY_G.Attributes.Add("onkeyup", strJS1 + " OnlyNegNumber(this,6)");
            }

            txtCOST_G.Attributes.Add("onkeyup", strJS2 + " OnlyNegNumber(this,6)");
            txtOUT_COST_DIS_G.Attributes.Add("onkeyup", strJS2 + " OnlyNegNumber(this,6)");
            txtOUT_PRICE_G.Attributes.Add("onkeyup", strJS1 + " OnlyNegNumber(this,5)");
            #endregion

            #region 呼叫BCO查詢

            DataTable dt = GetData();

            CAMModel.CAMCommon bco1 = new CAMModel.CAMCommon();
            CAMModel.AdjustDocketByStoreGroup bco = new CAMModel.AdjustDocketByStoreGroup(ConntionDB);

            string strBUS_YM = "";
            string s_RESULT = string.Empty;
            string s_ERR_MSG = string.Empty;

            DataView dv = dt.DefaultView;
            dv.Sort = "BUS_YM";
            DataTable dt1 = dv.ToTable();

            foreach (DataRow dr in dt1.Rows)
            {
                if (dr["BUS_YM"].ToString() != strBUS_YM)
                {
                    ParameterList.Clear();
                    ParameterList.Add(bco1.GetValueSetParameter(dr["BUS_YM"].ToString(), "string", false));//[結帳年月]

                    s_RESULT = string.Empty;
                    s_ERR_MSG = string.Empty;

                    PIC.VDS2G.ACM.PSS.MaintainCheckPSSCloseYN pss_bco = new PIC.VDS2G.ACM.PSS.MaintainCheckPSSCloseYN(ConntionDB);
                    pss_bco.CheckPSSCloseYN(ParameterList, out s_RESULT, out  s_ERR_MSG);

                    //s_RESULT=0,該月份已月結
                    //s_RESULT=1,該月份尚未月結
                    if (s_RESULT == "0")//該月份已月結
                    {
                        DataRow[] dr1 = (DataRow[])dt.Select("BUS_YM='" + dr["BUS_YM"].ToString() + "'");

                        foreach (DataRow dr2 in dr1)
                        {
                            dr2.Delete();
                        }
                    }
                }

                strBUS_YM = dr["BUS_YM"].ToString();
            }

            dt.AcceptChanges();

            #endregion

            #region 查詢完控制項重置
            //抓取本頁初次登記的時間
            string SessionIDName = "CAM01_GridView1" + PageTimeStamp.Value;
            double dblOUT_QTY_OLD = 0;
            double dblCOST_OLD = 0;
            double dblOUT_COST_DIS_OLD = 0;
            double dblOUT_PRICE_OLD = 0;

            Session["SessionID"] = SessionIDName;
            Session[SessionIDName] = dt;
            GridView1.DataSource = dt;
            GridView1.PageIndex = 0;
            GridView1.DataBind();

            txtOUT_QTY_G.Text = "";
            txtCOST_G.Text = "";
            txtOUT_COST_DIS_G.Text = "";
            txtOUT_PRICE_G.Text = "";
            hidFlag.Value = "";

            if (dt.Rows.Count == 0)
            {
                panUPDATE_SUMMARY.Visible = false;
                ErrorMsgLabel.Text = "查無資料";
                panSTORE_GROUP.Visible = false;
                btnUpdate.Enabled = false;
            }
            else
            {
                panUPDATE_SUMMARY.Visible = true;
                panSTORE_GROUP.Visible = true;

                if (RdlKIND1.Checked)
                {
                    btnUpdate.Enabled = CanUpdate;
                }
                else
                {
                    btnUpdate.Enabled = AuthUpdate;
                }

                LockControl(true);

                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$get('ctl00_CPH_PanelQuery').style.display='none';", true);

                if (RdlKIND1.Checked)
                {
                    txtOUT_QTY_G.ReadOnly = false;
                    txtOUT_QTY_G.CssClass = "";
                    txtCOST_G.ReadOnly = false;
                    txtCOST_G.CssClass = "";
                    txtOUT_COST_DIS_G.ReadOnly = false;
                    txtOUT_COST_DIS_G.CssClass = "";
                    txtOUT_PRICE_G.ReadOnly = false;
                    txtOUT_PRICE_G.CssClass = "";
                    for (int k = 0; k <= GridView1.Rows.Count - 1; k++)
                    {
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_QTY")).ReadOnly = true;
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_QTY")).CssClass = "readtxtbox";
                        ((TextBox)GridView1.Rows[k].FindControl("txtCOST")).ReadOnly = true;
                        ((TextBox)GridView1.Rows[k].FindControl("txtCOST")).CssClass = "readtxtbox";
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_COST_DIS")).ReadOnly = true;
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_COST_DIS")).CssClass = "readtxtbox";
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_PRICE")).ReadOnly = true;
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_PRICE")).CssClass = "readtxtbox";
                    }
                }
                else
                {
                    txtOUT_QTY_G.ReadOnly = true;
                    txtOUT_QTY_G.CssClass = "readtxtbox";
                    txtCOST_G.ReadOnly = true;
                    txtCOST_G.CssClass = "readtxtbox";
                    txtOUT_COST_DIS_G.ReadOnly = true;
                    txtOUT_COST_DIS_G.CssClass = "readtxtbox";
                    txtOUT_PRICE_G.ReadOnly = true;
                    txtOUT_PRICE_G.CssClass = "readtxtbox";
                    txtOUT_QTY_G.Text = "";
                    txtCOST_G.Text = "";
                    txtOUT_COST_DIS_G.Text = "";
                    txtOUT_PRICE_G.Text = "";
                    for (int k = 0; k <= GridView1.Rows.Count - 1; k++)
                    {
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_QTY")).ReadOnly = false;
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_QTY")).CssClass = "";
                        ((TextBox)GridView1.Rows[k].FindControl("txtCOST")).ReadOnly = false;
                        ((TextBox)GridView1.Rows[k].FindControl("txtCOST")).CssClass = "";
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_COST_DIS")).ReadOnly = false;
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_COST_DIS")).CssClass = "";
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_PRICE")).ReadOnly = false;
                        ((TextBox)GridView1.Rows[k].FindControl("txtOUT_PRICE")).CssClass = "";
                    }
                }

                #region 原價格合計
                for (int k = 0; k <= dt.Rows.Count - 1; k++)
                {
                    dblOUT_QTY_OLD += double.Parse(dt.Rows[k]["OUT_QTY"].ToString() == "" ? "0" : dt.Rows[k]["OUT_QTY"].ToString());
                    dblCOST_OLD += double.Parse(dt.Rows[k]["COST"].ToString() == "" ? "0" : dt.Rows[k]["COST"].ToString());
                    dblOUT_COST_DIS_OLD += double.Parse(dt.Rows[k]["OUT_COST_DIS"].ToString() == "" ? "0" : dt.Rows[k]["OUT_COST_DIS"].ToString());
                    dblOUT_PRICE_OLD += double.Parse(dt.Rows[k]["OUT_PRICE"].ToString() == "" ? "0" : dt.Rows[k]["OUT_PRICE"].ToString());
                }

                txtOUT_QTY_B.Text = dblOUT_QTY_OLD.ToString();
                txtCOST_B.Text = dblCOST_OLD.ToString();
                txtOUT_COST_DIS_B.Text = dblOUT_COST_DIS_OLD.ToString();
                txtOUT_PRICE_B.Text = dblOUT_PRICE_OLD.ToString();

                txtOUT_QTY_A.Text = "";
                txtCOST_A.Text = "";
                txtOUT_COST_DIS_A.Text = "";
                txtOUT_PRICE_A.Text = "";
                #endregion
            }
            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { Finally_Function(); }
    }
예제 #3
0
 private DataTable GetData()
 {
     CAMModel.CAMCommon bco1 = new CAMModel.CAMCommon();
     CAMModel.AdjustDocketByStoreGroup bco = new CAMModel.AdjustDocketByStoreGroup(ConntionDB);
     DataTable dtResult = new DataTable();
     if (ddlSTAKind.SelectedIndex == 0)
     {
         for (int i = 1; i <= 4; i++)
         {
             ParameterList.Clear();
             ParameterList.Add(bco1.GetValueSetParameter(SLP_BUS_DATE.StartDate, "date", false));
             ParameterList.Add(bco1.GetValueSetParameter(SLP_BUS_DATE.EndDate, "date", false));
             ParameterList.Add(bco1.GetValueSetParameter(i.ToString(), "string", false));
             ParameterList.Add(bco1.GetValueSetParameter(slp_GROUP_NO_S.Text, "string", false));
             ParameterList.Add(bco1.GetValueSetParameter(slp_GROUP_NO_E.Text, "string", false));
             ParameterList.Add(bco1.GetValueSetParameter(SLP_ROUTE_S.Text, "string", false));
             ParameterList.Add(bco1.GetValueSetParameter(SLP_ROUTE_E.Text, "string", false));
             ParameterList.Add(bco1.GetValueSetParameter(slp_STORE.Text, "string", false));
             ParameterList.Add(bco1.GetValueSetParameter(txtOUT_NO.Text, "string", false));
             ParameterList.Add(bco1.GetValueSetParameter(SLP_ITEM.Text, "string", false));
             ParameterList.Add(bco1.GetValueSetParameter(txtPERIOD.Text, "string", false));
             ParameterList.Add(bco1.GetValueSetParameter(Session["UID"].ToString(), "string", false));
             DataTable dt = bco.QueryByStoreGroup(ParameterList);
             if (i == 1)
                 dtResult = dt;
             else
                 dtResult.Merge(dt);
         }
     }
     else
     {
         ParameterList.Clear();
         ParameterList.Add(bco1.GetValueSetParameter(SLP_BUS_DATE.StartDate, "date", false));
         ParameterList.Add(bco1.GetValueSetParameter(SLP_BUS_DATE.EndDate, "date", false));
         ParameterList.Add(bco1.GetValueSetParameter(ddlSTAKind.SelectedValue, "string", false));
         ParameterList.Add(bco1.GetValueSetParameter(slp_GROUP_NO_S.Text, "string", false));
         ParameterList.Add(bco1.GetValueSetParameter(slp_GROUP_NO_E.Text, "string", false));
         ParameterList.Add(bco1.GetValueSetParameter(SLP_ROUTE_S.Text, "string", false));
         ParameterList.Add(bco1.GetValueSetParameter(SLP_ROUTE_E.Text, "string", false));
         ParameterList.Add(bco1.GetValueSetParameter(slp_STORE.Text, "string", false));
         ParameterList.Add(bco1.GetValueSetParameter(txtOUT_NO.Text, "string", false));
         ParameterList.Add(bco1.GetValueSetParameter(SLP_ITEM.Text, "string", false));
         ParameterList.Add(bco1.GetValueSetParameter(txtPERIOD.Text, "string", false));
         ParameterList.Add(bco1.GetValueSetParameter(Session["UID"].ToString(), "string", false));
         dtResult = bco.QueryByStoreGroup(ParameterList);
     }
     dtResult.DefaultView.Sort = "STORE ASC,STAKIND ASC,OUT_NO ASC,ITEM ASC,PERIOD ASC";
     dtResult = dtResult.DefaultView.ToTable();
     return dtResult;
 }