示例#1
0
    protected void btnSet_Click(object sender, EventArgs e)
    {
        try
        {
            lblBlueMsg.Text = "";
            this.ErrorMsgLabel.Text = "";
            #region 檢查條件
            string s_CheckPage = CheckPage(sender);

            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;
                return;
            }
            #endregion

            #region 傳入參數
            DataTable dtA = new DataTable();
            DataTable dtB = new DataTable();


            string SessionIDNameA = Session["SessionIDA"].ToString();
            dtA = (DataTable)Session[SessionIDNameA];

            string SessionIDNameB = Session["SessionIDB"].ToString();
            dtB = (DataTable)Session[SessionIDNameB];

            //先檢核是否有勾選
            string sIsChk = "N";
            if (dtA != null)
            {
                for (int i = 0; i < dtA.Rows.Count; i++)
                {
                    if (dtA.Rows[i]["CHK"].ToString() == "1")//check box有勾選的資料
                    {
                        sIsChk = "Y";
                        break;
                    }
                }
            }

            if (dtB != null && sIsChk == "N")
            {
                for (int i = 0; i < dtB.Rows.Count; i++)
                {
                    if (dtB.Rows[i]["CHK"].ToString() == "1")//check box有勾選的資料
                    {
                        sIsChk = "Y";
                        break;
                    }
                }
            }

            if (sIsChk == "N")
            {
                this.ErrorMsgLabel.Text = "至少勾選一個品項";
                SetClinetFocus(((TextBox)((ASP.wui_slp_slp_numberupdown_ascx)this.SLP_YearMonth1.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode")).ClientID);
                return;
            }

            //取得已做設定的資料
            string SessionVAM052A = "VAM052_print_A" + PageTimeStamp.Value;
            string SessionVAM052B = "VAM052_print_B" + PageTimeStamp.Value;
            DataTable dtA_P = new DataTable();
            DataTable dtB_P = new DataTable();
            dtA_P = (DataTable)Session[SessionVAM052A];
            dtB_P = (DataTable)Session[SessionVAM052B];

            //紀錄未設定的資料
            DataTable dtA2 = this.MakeDTForA();

            DataTable dtB2 = this.MakeDTForB();
            #endregion


            #region 檢核資料
            DataTable dtChkVendor;
            BCO.ProcessVAMSKUClose bco = new BCO.ProcessVAMSKUClose(ConntionDB);
            DbTransaction transaction = bco.GetTransaction();
            bco.CheckVendorTotalAmt(dtA, dtB, this.SLP_YearMonth1.Text.Trim(), Request["ED"].ToString(), transaction, out dtChkVendor);
            #endregion

            DataTable dtChk = DT_Filter(dtChkVendor, "CAL='N'"); //對帳單金額 < 0 不結帳的廠商
            DataTable dtChkCal = DT_Filter(dtChkVendor, "CAL='Y'"); //對帳單金額 < 0 要結帳的廠商
            string V_MSG = "";

            //單品結帳金額<0 不結帳的廠商
            if (dtChk.Rows.Count > 0)
            {
                //處理錯誤訊息(三家廠商一列)
                V_MSG = "單品結帳金額 < 0 :<br>";
                int iCount = 0;
                for (int i = 0; i < dtChk.Rows.Count; i++)
                {
                    V_MSG += dtChk.Rows[i]["VENDOR"].ToString() + dtChk.Rows[i]["VENDOR_NAME"].ToString() + "---";
                    if (iCount < 2)
                    {
                        iCount++;
                    }
                    else
                    {
                        iCount = 0;
                        V_MSG += "<br>";
                    }

                }
            }

            string strBlueMsg = string.Empty;
            //單品結帳金額<0 有結帳的廠商
            if (dtChkCal.Rows.Count > 0)
            {
                strBlueMsg = "產生負數款結帳資料廠商 :<br>";
                int iCount = 0;
                for (int i = 0; i < dtChkCal.Rows.Count; i++)
                {
                    strBlueMsg += dtChkCal.Rows[i]["VENDOR"].ToString() + dtChkCal.Rows[i]["VENDOR_NAME"].ToString() + "---";
                    if (iCount < 2)
                    {
                        iCount++;
                    }
                    else
                    {
                        iCount = 0;
                        strBlueMsg += "<br>";
                    }
                }
                strBlueMsg += "<br>";
            }


            //彙總要做設定的資料
            DataTable dtC = this.MakeDTForC();
            string sCanSet = "Y";
            if (dtA != null)
            {
                if (dtA.Rows.Count > 0)
                {

                    for (int i = 0; i < dtA.Rows.Count; i++)
                    {
                        if (dtA.Rows[i]["CHK"].ToString() == "1")//check box有勾選的資料
                        {
                            //判斷是否為單品結帳金額<0的廠商(sCanSet == "Y"可以做設定)
                            sCanSet = "Y";
                            for (int j = 0; j < dtChk.Rows.Count; j++)
                            {
                                if (dtA.Rows[i]["VENDOR"].ToString() == dtChk.Rows[j]["VENDOR"].ToString())
                                {
                                    sCanSet = "N";
                                    break;
                                }
                            }

                            if (sCanSet == "Y")
                            {
                                //將可以做設定的資料新增至drC
                                DataRow drC = dtC.NewRow();
                                drC["SOURCE_DATE_S"] = this.hidSOURCE_DATE_S.Value;
                                drC["SOURCE_DATE_E"] = this.hidSOURCE_DATE_E.Value;
                                drC["OLD_CLOSE_MONTH"] = this.GetValueSetParameter(dtA.Rows[i]["CLOSE_MONTH"].ToString(), "string", false);
                                drC["VENDOR"] = this.GetValueSetParameter(dtA.Rows[i]["VENDOR"].ToString(), "string", false);
                                drC["ITEM"] = this.GetValueSetParameter(dtA.Rows[i]["ITEM"].ToString(), "string", false);
                                drC["PERIOD"] = this.GetValueSetParameter(dtA.Rows[i]["PERIOD"].ToString(), "string", false);
                                drC["NEW_CLOSE_MONTH"] = this.GetValueSetParameter(this.SLP_YearMonth1.Text.Trim(), "string", false);
                                drC["UPDATEUID"] = Session["UID"].ToString();
                                drC["UPDATEDATE"] = System.DateTime.Now;
                                drC["RETURN_NO"] = "SET";
                                dtC.Rows.Add(drC);
                                DataRow drA_P = dtA_P.NewRow();
                                for (int k = 0; k < dtA_P.Columns.Count; k++)
                                    drA_P[k] = dtA.Rows[i][k].ToString();
                                dtA_P.Rows.Add(drA_P);

                            }
                            else
                            {
                                DataRow drA2 = dtA2.NewRow();
                                for (int k = 0; k < dtA2.Columns.Count; k++)
                                    drA2[k] = dtA.Rows[i][k].ToString();
                                dtA2.Rows.Add(drA2);
                            }
                        }
                        else
                        {
                            DataRow drA2 = dtA2.NewRow();
                            for (int k = 0; k < dtA2.Columns.Count; k++)
                                drA2[k] = dtA.Rows[i][k].ToString();
                            dtA2.Rows.Add(drA2);
                        }
                    }
                }
            }

            if (dtB != null)
            {
                if (dtB.Rows.Count > 0)
                {
                    for (int i = 0; i < dtB.Rows.Count; i++)
                    {
                        if (dtB.Rows[i]["CHK"].ToString() == "1")//check box有勾選的資料
                        {
                            //判斷是否為單品結帳金額<0的廠商(sCanSet == "Y"可以做設定)
                            sCanSet = "Y";
                            for (int j = 0; j < dtChk.Rows.Count; j++)
                            {
                                if (dtB.Rows[i]["VENDOR"].ToString() == dtChk.Rows[j]["VENDOR"].ToString())
                                {
                                    sCanSet = "N";
                                    break;
                                }
                            }

                            if (sCanSet == "Y")
                            {
                                //將可以做設定的資料新增至drC
                                DataRow drC = dtC.NewRow();
                                drC["SOURCE_DATE_S"] = this.hidSOURCE_DATE_S.Value;
                                drC["SOURCE_DATE_E"] = this.hidSOURCE_DATE_E.Value;
                                drC["OLD_CLOSE_MONTH"] = this.GetValueSetParameter(dtB.Rows[i]["CLOSE_MONTH"].ToString(), "string", false);
                                drC["VENDOR"] = this.GetValueSetParameter(dtB.Rows[i]["VENDOR"].ToString(), "string", false);
                                drC["ITEM"] = this.GetValueSetParameter(dtB.Rows[i]["ITEM"].ToString(), "string", false);
                                drC["PERIOD"] = this.GetValueSetParameter(dtB.Rows[i]["PERIOD"].ToString(), "string", false);
                                drC["NEW_CLOSE_MONTH"] = this.GetValueSetParameter(this.SLP_YearMonth1.Text.Trim(), "string", false);
                                drC["UPDATEUID"] = Session["UID"].ToString();
                                drC["UPDATEDATE"] = System.DateTime.Now;
                                drC["RETURN_NO"] = this.GetValueSetParameter(dtB.Rows[i]["RETURN_NO"].ToString(), "string", false);
                                dtC.Rows.Add(drC);
                                DataRow drB_P = dtB_P.NewRow();
                                for (int k = 0; k < dtB_P.Columns.Count; k++)
                                    drB_P[k] = dtB.Rows[i][k].ToString();
                                dtB_P.Rows.Add(drB_P);
                            }
                            else
                            {
                                DataRow drB2 = dtB2.NewRow();
                                for (int k = 0; k < dtB2.Columns.Count; k++)
                                    drB2[k] = dtB.Rows[i][k].ToString();
                                dtB2.Rows.Add(drB2);
                            }
                        }
                        else
                        {
                            DataRow drB2 = dtB2.NewRow();
                            for (int k = 0; k < dtB2.Columns.Count; k++)
                                drB2[k] = dtB.Rows[i][k].ToString();
                            dtB2.Rows.Add(drB2);
                        }
                    }
                }
            }
            bco.SetSKUCloseMark(dtC, null);


            Session[SessionIDNameA] = dtA2;
            Session[SessionIDNameB] = dtB2;
            Session[SessionVAM052A] = dtA_P;
            Session[SessionVAM052B] = dtB_P;

            this.GridView1.Visible = true;
            this.GridView1.DataSource = dtA2;
            this.GridView1.PageSize = 30;
            this.GridView1.PageIndex = 0;
            this.GridView1.DataBind();
            if (dtA != null)
                this.Label5.Text = "總筆數:" + dtA2.Rows.Count.ToString() + "筆";

            this.GridView2.Visible = true;
            this.GridView2.DataSource = dtB2;
            this.GridView2.PageSize = 30;
            this.GridView2.PageIndex = 0;
            this.GridView2.DataBind();
            if (dtB != null)
                this.Label6.Text = "總筆數:" + dtB2.Rows.Count.ToString() + "筆";

            this.LinkButton1.Enabled = true;
            V_MSG += "<br>------------------------------------------------------------<br>";
            V_MSG += "結帳年月" + this.SLP_YearMonth1.Text.Trim() + "單品註記完成。查看本次註記報表";
            this.lblBlueMsg.Text = strBlueMsg;
            this.ErrorMsgLabel.Text = V_MSG;
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.lblBlueMsg.Text = "";
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
示例#2
0
    protected void btnUnSet_Click(object sender, EventArgs e)
    {
        try
        {
            this.ErrorMsgLabel.Text = "";
            #region
            if (Convert.ToDateTime(this.Label7.Text.ToString().Substring(0, 4) + "/" + this.Label7.Text.ToString().Substring(4, 2) + "/02").AddMonths(1) <= System.DateTime.Now ||
                Convert.ToDateTime(this.Label7.Text.ToString().Substring(7, 4) + "/" + this.Label7.Text.ToString().Substring(11, 2) + "/02").AddMonths(1) <= System.DateTime.Now)
            {
                ErrorMsgLabel.Text = " 指定[結帳年月區間]已超過解除期限,勿再處理!!";
                return;
            }
            #endregion

            #region 傳入參數
            DataTable dtA = new DataTable();
            DataTable dtB = new DataTable();

            string SessionIDNameA = Session["SessionIDA"].ToString();
            dtA = (DataTable)Session[SessionIDNameA];



            string SessionIDNameB = Session["SessionIDB"].ToString();
            dtB = (DataTable)Session[SessionIDNameB];

            //先檢核是否有勾選
            string sIsChk = "N";
            if (dtA != null)
            {
                for (int i = 0; i < dtA.Rows.Count; i++)
                {
                    if (dtA.Rows[i]["CHK"].ToString() == "1")//check box有勾選的資料
                    {
                        sIsChk = "Y";
                        break;
                    }
                }
            }

            if (dtB != null && sIsChk == "N")
            {
                for (int i = 0; i < dtB.Rows.Count; i++)
                {
                    if (dtB.Rows[i]["CHK"].ToString() == "1")//check box有勾選的資料
                    {
                        sIsChk = "Y";
                        break;
                    }
                }
            }

            if (sIsChk == "N")
            {
                this.ErrorMsgLabel.Text = "至少勾選一個品項";
                //SetClinetFocus(((TextBox)((ASP.wui_slp_slp_numberupdown_ascx)this.SLP_YearMonth1.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode")).ClientID);
                return;
            }

            //取得已做設定的資料
            string SessionVAM052A = "VAM052_print_A" + PageTimeStamp.Value;
            string SessionVAM052B = "VAM052_print_B" + PageTimeStamp.Value;
            DataTable dtA_P = new DataTable();
            DataTable dtB_P = new DataTable();
            dtA_P = (DataTable)Session[SessionVAM052A];
            dtB_P = (DataTable)Session[SessionVAM052B];


            DataTable dtA2 = this.MakeDTForA();

            DataTable dtB2 = this.MakeDTForB();

            #endregion

            BCO.ProcessVAMSKUClose bco = new BCO.ProcessVAMSKUClose(ConntionDB);

            DataTable dtC = this.MakeDTForC();
            if (dtA != null)
            {
                if (dtA.Rows.Count > 0)
                {
                    for (int i = 0; i < dtA.Rows.Count; i++)
                    {
                        if (dtA.Rows[i]["CHK"].ToString() == "1")
                        {
                            DataRow drC = dtC.NewRow();
                            drC["SOURCE_DATE_S"] = this.GetValueSetParameter("", "string", false);
                            drC["SOURCE_DATE_E"] = this.GetValueSetParameter("", "string", false);
                            drC["OLD_CLOSE_MONTH"] = this.GetValueSetParameter(dtA.Rows[i]["CLOSE_MONTH"].ToString(), "string", false);
                            drC["VENDOR"] = this.GetValueSetParameter(dtA.Rows[i]["VENDOR"].ToString(), "string", false);
                            drC["ITEM"] = this.GetValueSetParameter(dtA.Rows[i]["ITEM"].ToString(), "string", false);
                            drC["PERIOD"] = this.GetValueSetParameter(dtA.Rows[i]["PERIOD"].ToString(), "string", false);
                            drC["NEW_CLOSE_MONTH"] = this.GetValueSetParameter(this.SLP_YearMonth1.Text.Trim(), "string", false);
                            drC["UPDATEUID"] = Session["UID"].ToString();
                            drC["UPDATEDATE"] = System.DateTime.Now;
                            drC["RETURN_NO"] = "UNSET";
                            dtC.Rows.Add(drC);
                            DataRow drA_P = dtA_P.NewRow();
                            for (int k = 0; k < dtA_P.Columns.Count; k++)
                                drA_P[k] = dtA.Rows[i][k].ToString();
                            dtA_P.Rows.Add(drA_P);
                        }
                        else
                        {
                            DataRow drA2 = dtA2.NewRow();
                            for (int k = 0; k < dtA2.Columns.Count; k++)
                                drA2[k] = dtA.Rows[i][k].ToString();
                            dtA2.Rows.Add(drA2);
                        }
                    }
                }
            }

            if (dtB != null)
            {
                if (dtB.Rows.Count > 0)
                {
                    int iBCount = dtB.Rows.Count;
                    for (int i = 0; i < iBCount; i++)
                    {
                        if (dtB.Rows[i]["CHK"].ToString() == "1")
                        {
                            DataRow drC = dtC.NewRow();
                            drC["SOURCE_DATE_S"] = this.GetValueSetParameter("", "string", false);
                            drC["SOURCE_DATE_E"] = this.GetValueSetParameter("", "string", false);
                            drC["OLD_CLOSE_MONTH"] = this.GetValueSetParameter(dtB.Rows[i]["CLOSE_MONTH"].ToString(), "string", false);
                            drC["VENDOR"] = this.GetValueSetParameter(dtB.Rows[i]["VENDOR"].ToString(), "string", false);
                            drC["ITEM"] = this.GetValueSetParameter(dtB.Rows[i]["ITEM"].ToString(), "string", false);
                            drC["PERIOD"] = this.GetValueSetParameter(dtB.Rows[i]["PERIOD"].ToString(), "string", false);
                            drC["NEW_CLOSE_MONTH"] = this.GetValueSetParameter(this.SLP_YearMonth1.Text.Trim(), "string", false);
                            drC["UPDATEUID"] = Session["UID"].ToString();
                            drC["UPDATEDATE"] = System.DateTime.Now;
                            drC["RETURN_NO"] = this.GetValueSetParameter(dtB.Rows[i]["RETURN_NO"].ToString(), "string", false);
                            dtC.Rows.Add(drC);
                            DataRow drB_P = dtB_P.NewRow();
                            for (int k = 0; k < dtB_P.Columns.Count; k++)
                                drB_P[k] = dtB.Rows[i][k].ToString();
                            dtB_P.Rows.Add(drB_P);
                        }
                        else
                        {
                            DataRow drB2 = dtB2.NewRow();
                            for (int k = 0; k < dtB2.Columns.Count; k++)
                                drB2[k] = dtB.Rows[i][k].ToString();
                            dtB2.Rows.Add(drB2);
                        }
                    }
                }
            }
            bco.SetSKUCloseMark(dtC, null);
            Session[SessionIDNameA] = dtA2;
            Session[SessionIDNameB] = dtB2;
            Session[SessionVAM052A] = dtA_P;
            Session[SessionVAM052B] = dtB_P;

            this.GridView1.Visible = true;
            this.GridView1.DataSource = dtA2;
            this.GridView1.PageSize = 30;
            this.GridView1.PageIndex = 0;
            this.GridView1.DataBind();
            if (dtA != null)
                this.Label5.Text = "總筆數:" + dtA2.Rows.Count.ToString() + "筆";

            this.GridView2.Visible = true;
            this.GridView2.DataSource = dtB2;
            this.GridView2.PageSize = 30;
            this.GridView2.PageIndex = 0;
            this.GridView2.DataBind();
            if (dtB != null)
                this.Label6.Text = "總筆數:" + dtB2.Rows.Count.ToString() + "筆";

            this.LinkButton1.Enabled = true;

            this.ErrorMsgLabel.Text = "選取單品註記解除完成。查看本次註記報表";
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
示例#3
0
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        try
        {
            #region 檢查條件

            string s_CheckPage = CheckPage(sender);

            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;
                return;
            }
            #endregion
            if (this.rdoType2.Checked == true)
            {
                if (this.SLP_SLPDateRange1.StartDate.ToString() != "" || this.SLP_SLPDateRange1.EndDate.ToString() != "")
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "VAM051", "alert('您輸入處理日期起日、處理日期迄日條件將忽略不列入查詢');", true);

                }
            }
            //Session["Rpt_DataA" + PageTimeStamp.Value] = null;
            //Session["Rpt_DataB" + PageTimeStamp.Value] = null;
            //Session["Rpt_DataC" + PageTimeStamp.Value] = null;
            //Session["Rpt_DataD" + PageTimeStamp.Value] = null;
            #region 傳入參數
            ParameterList.Clear();
            if (this.rdoType1.Checked == true)
                ParameterList = this.GetParameter(0);
            else if (this.rdoType2.Checked == true)
                ParameterList = this.GetParameter(1);
            else
                ParameterList = this.GetParameter(2);
            #endregion
            DataTable dtA = new DataTable();
            DataTable dtB = new DataTable();

            #region 取得資料

            BCO.ProcessVAMSKUClose bco = new BCO.ProcessVAMSKUClose(ConntionDB);
            dtA = bco.QueryAllSKUClose(ParameterList);
            dtB = bco.QueryReturnSKUClose(ParameterList);
            #endregion

            if (dtA.Rows.Count == 0 && dtB.Rows.Count == 0)
            {
                this.Panel3.Visible = false;
                this.Panel1.Visible = false;
                this.GridView1.Visible = false;
                this.GridView2.Visible = false;
                this.ErrorMsgLabel.Text = "查無資料";
                //this.btnTran.Enabled = false;
                return;
            }
            else
            {

                this.Panel3.Visible = true;
                this.Panel1.Visible = true;

                string SessionIDNameA = "VAM051A_gv_ItemInfo" + PageTimeStamp.Value;
                Session["SessionIDA"] = SessionIDNameA;
                string SessionIDNameB = "VAM051B_gv_ItemInfo" + PageTimeStamp.Value;
                Session["SessionIDB"] = SessionIDNameB;
                //if (dtA.Rows.Count > 0)
                //{
                Session[SessionIDNameA] = dtA;
                //}
                //else
                //{ 

                //}
                //if (dtB.Rows.Count > 0)
                //{
                Session[SessionIDNameB] = dtB;
                //}
                //else
                //{
                //    Session[SessionIDNameB] = null;
                //}

                if (this.rdoType1.Checked == true)
                {
                    //this.btnTran.Enabled = true;
                    this.GridView1.Visible = true;
                    this.GridView1.DataSource = dtA;
                    this.GridView1.PageSize = 30;
                    this.GridView1.PageIndex = 0;
                    this.GridView1.DataBind();
                    this.Label5.Text = "    總筆數:" + dtA.Rows.Count.ToString() + "筆";

                    this.GridView2.Visible = true;
                    this.GridView2.DataSource = dtB;
                    this.GridView2.PageSize = 30;
                    this.GridView2.PageIndex = 0;
                    this.GridView2.DataBind();
                    this.Label6.Text = "    總筆數:" + dtB.Rows.Count.ToString() + "筆";
                    //this.btnTran.Enabled = true;
                }
                else
                {
                    if (this.rdoType2.Checked == true)
                    {
                        //Response.Redirect("VAM052.aspx?Code=VAM05&BD=" + this.SLP_SLPDateRange1.StartDate.ToString() + "&ED=" + this.SLP_SLPDateRange1.EndDate.ToString() + "&V_TYPE=1");
                        Response.Redirect("VAM052.aspx?Code=VAM05&BD=" + this.SLP_SLPDateRange1.StartDate.ToString() + this.SLP_SLPDateRange1.EndDate.ToString() + "&ED=" + this.SLP_YearMonth1.Text + "-" + this.SLP_YearMonth2.Text + "&V_TYPE=1");
                    }
                    else
                    {
                        Response.Redirect("VAM052.aspx?Code=VAM05&BD=" + this.SLP_SLPDateRange1.StartDate.ToString() + "&ED=" + this.SLP_SLPDateRange1.EndDate.ToString() + "&V_TYPE=2");
                    }
                }

            }

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