예제 #1
0
    /// <summary>
    /// GridView1_向下鈕事件
    /// </summary>
    protected void btnXRouteDown_Click(object sender, EventArgs e)
    {
        if (GridView1.Rows.Count <= 0)
        {
            return;
        }

        string SessionIDName = "CGD011_" + PageTimeStamp.Value;
        DataTable Dt = null;

        try
        {
            if (Session[SessionIDName] != null)
            {
                Dt = (DataTable)Session[SessionIDName];
            }
            else
            {
                //從DB讀取一空table回來
                CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);
                ParameterList.Clear();
                Dt = BCO.QuerySwitch(CGDModel.MaintainSetRouteOrder.QueryType.Empty, ParameterList);
            }

            string oldCheckPlace = "";//for記錄舊的選取點

            #region 計算目前查詢所得之DataTable的PickOrder欄位最大值(maxPickOrder)是多少

            int maxPickOrder = 0;

            for (int max = 0; max <= Dt.Rows.Count - 1; max++)
            {
                if ((hidSLPDate1.Text.Trim() == Convert.ToDateTime(Dt.Rows[max]["ST_ACCEPT_DATE"].ToString()).ToShortDateString()) && (hidtxtPickBatch.Text.Trim() == Dt.Rows[max]["PICK_BATCH"].ToString().Trim()) && (Dt.Rows[max]["LINE"].ToString().Trim() == "X"))
                {
                    if (Convert.ToInt32(Dt.Rows[max]["PICK_ORDER"].ToString()) > maxPickOrder)
                    {
                        maxPickOrder = Convert.ToInt32(Dt.Rows[max]["PICK_ORDER"].ToString());
                    }
                }

            }

            #endregion

            for (int i = GridView1.Rows.Count - 1; i >= 0; i--)
            {
                if (((CheckBox)(GridView1.Rows[i].FindControl("CheckBox1"))).Checked == true)
                {
                    oldCheckPlace += Convert.ToString(i) + ",";

                    for (int j = 0; j <= Dt.Rows.Count - 1; j++)
                    {
                        int oldPICK_ORDER = 0;
                        int newPICK_ORDER = 0;

                        if ((((Label)(GridView1.Rows[i].FindControl("Label3"))).Text == Dt.Rows[j]["ROUTE"].ToString()) && (hidSLPDate1.Text.Trim() == Convert.ToDateTime(Dt.Rows[j]["ST_ACCEPT_DATE"].ToString()).ToShortDateString()) && (hidtxtPickBatch.Text.Trim() == Dt.Rows[j]["PICK_BATCH"].ToString().Trim()))
                        {
                            oldPICK_ORDER = Convert.ToInt32(Dt.Rows[j]["PICK_ORDER"].ToString());

                            string found = "";

                            for (int l = oldPICK_ORDER + 1; l <= maxPickOrder; l++)
                            {
                                if (found == "")
                                {
                                    for (int k = 0; k <= Dt.Rows.Count - 1; k++)
                                    {
                                        if ((Convert.ToString(Convert.ToInt32(Dt.Rows[k]["PICK_ORDER"].ToString())) == Convert.ToString(l)) && (hidSLPDate1.Text.Trim() == Convert.ToDateTime(Dt.Rows[k]["ST_ACCEPT_DATE"].ToString()).ToShortDateString()) && (hidtxtPickBatch.Text.Trim() == Dt.Rows[k]["PICK_BATCH"].ToString().Trim()) && (Dt.Rows[k]["LINE"].ToString().Trim() == "X"))
                                        {
                                            newPICK_ORDER = Convert.ToInt32(Dt.Rows[k]["PICK_ORDER"].ToString());

                                            string _oldPICK_ORDER = Convert.ToString(oldPICK_ORDER);
                                            string _newPICK_ORDER = Convert.ToString(newPICK_ORDER);

                                            if (_oldPICK_ORDER.Length == 1)
                                            {
                                                _oldPICK_ORDER = "00" + _oldPICK_ORDER;
                                            }
                                            else if (_oldPICK_ORDER.Length == 2)
                                            {
                                                _oldPICK_ORDER = "0" + _oldPICK_ORDER;
                                            }

                                            if (_newPICK_ORDER.Length == 1)
                                            {
                                                _newPICK_ORDER = "00" + _newPICK_ORDER;
                                            }
                                            else if (_newPICK_ORDER.Length == 2)
                                            {
                                                _newPICK_ORDER = "0" + _newPICK_ORDER;
                                            }

                                            Dt.Rows[k]["PICK_ORDER"] = _oldPICK_ORDER;
                                            Dt.Rows[j]["PICK_ORDER"] = _newPICK_ORDER;

                                            found = "Y";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }


            Session[SessionIDName] = Dt;


            DataTable tempDT1 = Dt.Copy();
            string SessionIDName1 = "CGD011_1_" + PageTimeStamp.Value;
            Session[SessionIDName1] = tempDT1;
            DataView DV1 = tempDT1.DefaultView;
            DV1.RowFilter = "LINE = 'X'";
            DV1.Sort = "PICK_ORDER ASC";
            GridView1.DataSource = DV1;
            GridView1.PageIndex = 0;
            GridView1.DataBind();

            //依已記錄下的選取點重新勾選回去

            string[] strAryArg = oldCheckPlace.Split(",".ToCharArray());

            for (int i = 0; i <= strAryArg.Length - 1; i++)
            {
                int tempI = 0;

                if ((strAryArg[i].ToString() != "") && (strAryArg[i].ToString() != Convert.ToString(GridView1.Rows.Count - 1)))
                {
                    tempI = Convert.ToInt32(strAryArg[i].ToString());
                    ((CheckBox)(GridView1.Rows[tempI + 1].FindControl("CheckBox1"))).Checked = true;
                }
                if (strAryArg[i].ToString() == Convert.ToString(GridView1.Rows.Count - 1))
                {
                    tempI = Convert.ToInt32(strAryArg[i].ToString());
                    ((CheckBox)(GridView1.Rows[tempI].FindControl("CheckBox1"))).Checked = true;
                }
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
예제 #2
0
    /// <summary>
    /// GridView1_換線鈕事件
    /// </summary>
    protected void btnXChangeLine_Click(object sender, EventArgs e)
    {
        if (GridView1.Rows.Count <= 0)
        {
            return;
        }

        if (ddlXChangeLine.SelectedItem.Text == "")
        {
            ErrorMsgLabel.Text = "路線未選擇";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 路線未選擇 ');", true);

            return;
        }
        else if (ddlXChangeLine.SelectedItem.Text == "X")
        {
            ErrorMsgLabel.Text = "請選舉與原路線不同之路線";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 請選舉與原路線不同之路線 ');", true);

            return;
        }

        try
        {
            string SessionIDName = "CGD011_" + PageTimeStamp.Value;
            DataTable Dt = null;

            if (Session[SessionIDName] != null)
            {
                Dt = (DataTable)Session[SessionIDName];
            }
            else if (Dt.Rows.Count == 0)
            {
                //從DB讀取一空table回來
                CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);
                ParameterList.Clear();
                Dt = BCO.QuerySwitch(CGDModel.MaintainSetRouteOrder.QueryType.Empty, ParameterList);
            }
            else
            {
                //從DB讀取一空table回來
                CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);
                ParameterList.Clear();
                Dt = BCO.QuerySwitch(CGDModel.MaintainSetRouteOrder.QueryType.Empty, ParameterList);

            }

            for (int i = GridView1.Rows.Count - 1; i >= 0; i--)
            {
                if (((CheckBox)(GridView1.Rows[i].FindControl("CheckBox1"))).Checked == true)
                {
                    for (int j = 0; j <= Dt.Rows.Count - 1; j++)
                    {
                        if ((((Label)(GridView1.Rows[i].FindControl("Label3"))).Text == Dt.Rows[j]["ROUTE"].ToString()) && (Convert.ToDateTime(hidSLPDate1.Text.Trim()).ToShortDateString() == Convert.ToDateTime(Dt.Rows[j]["ST_ACCEPT_DATE"].ToString()).ToShortDateString()) && (hidtxtPickBatch.Text.Trim() == Dt.Rows[j]["PICK_BATCH"].ToString().Trim()))
                        {
                            int tempID = 0;
                            DataView dv = new DataView();
                            dv.Table = Dt.Copy();
                            dv.RowFilter = "LINE ='" + ddlXChangeLine.SelectedItem.Text + "'";
                            dv.Sort = "PICK_ORDER ASC";
                            DataTable tempDT = dv.ToTable();
                            if (tempDT.Rows.Count != 0)
                            {
                                tempID = Convert.ToInt32(tempDT.Rows[tempDT.Rows.Count - 1]["PICK_ORDER"].ToString());
                            }

                            Dt.Rows[j]["LINE"] = ddlXChangeLine.SelectedItem.Text;

                            #region 將tempID轉換為3碼之newPICK_ORDER

                            string newPICK_ORDER = Convert.ToString(tempID + 1);

                            if (newPICK_ORDER.Length == 1)
                            {
                                newPICK_ORDER = "00" + newPICK_ORDER;
                            }
                            else if (newPICK_ORDER.Length == 2)
                            {
                                newPICK_ORDER = "0" + newPICK_ORDER;
                            }

                            #endregion

                            Dt.Rows[j]["PICK_ORDER"] = newPICK_ORDER;
                        }
                    }
                }
            }


            Session[SessionIDName] = Dt;


            DataTable tempDT1 = Dt.Copy();
            DataTable tempDT2 = Dt.Copy();
            DataTable tempDT3 = Dt.Copy();

            string SessionIDName1 = "CGD011_1_" + PageTimeStamp.Value;
            string SessionIDName2 = "CGD011_2_" + PageTimeStamp.Value;
            string SessionIDName3 = "CGD011_3_" + PageTimeStamp.Value;

            Session[SessionIDName1] = tempDT1;
            Session[SessionIDName2] = tempDT2;
            Session[SessionIDName3] = tempDT3;

            DataView DV1 = tempDT1.DefaultView;
            DataView DV2 = tempDT2.DefaultView;
            DataView DV3 = tempDT3.DefaultView;

            DV1.RowFilter = "LINE = 'X'";
            DV2.RowFilter = "LINE = 'Y'";
            DV3.RowFilter = "LINE = 'Z'";

            DV1.Sort = "PICK_ORDER ASC";
            DV2.Sort = "PICK_ORDER ASC";
            DV3.Sort = "PICK_ORDER ASC";

            GridView1.DataSource = DV1;
            GridView2.DataSource = DV2;
            GridView3.DataSource = DV3;

            //GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            //GridView2.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            //GridView3.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);

            GridView1.PageIndex = 0;
            GridView2.PageIndex = 0;
            GridView3.PageIndex = 0;

            GridView1.DataBind();
            GridView2.DataBind();
            GridView3.DataBind();

            #region 計算總店數

            DataTable exchange1 = DV1.ToTable();
            DataTable exchange2 = DV2.ToTable();
            DataTable exchange3 = DV3.ToTable();


            int totalStoreX = 0;
            for (int i = 0; i <= exchange1.Rows.Count - 1; i++)
            {
                if (exchange1.Rows[i][16].ToString() != "")
                {
                    totalStoreX += Convert.ToInt32(exchange1.Rows[i][16].ToString());
                }
            }

            lblTotalX.Text = "總計店數:" + Convert.ToString(totalStoreX);


            int totalStoreY = 0;
            for (int i = 0; i <= exchange2.Rows.Count - 1; i++)
            {
                if (exchange2.Rows[i][16].ToString() != "")
                {
                    totalStoreY += Convert.ToInt32(exchange2.Rows[i][16].ToString());
                }
            }

            lblTotalY.Text = "總計店數:" + Convert.ToString(totalStoreY);


            int totalStoreZ = 0;
            for (int i = 0; i <= exchange3.Rows.Count - 1; i++)
            {
                if (exchange3.Rows[i][16].ToString() != "")
                {
                    totalStoreZ += Convert.ToInt32(exchange3.Rows[i][16].ToString());
                }
            }

            lblTotalZ.Text = "總計店數:" + Convert.ToString(totalStoreZ);


            #endregion

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
예제 #3
0
    /// <summary>
    /// databind 繫結查詢資料到GridView1,2,3
    /// </summary>
    private void databind()
    {
        //抓取本頁初次登記的時間
        string SessionIDName = "CGD011_" + PageTimeStamp.Value;
        string SessionIDName1 = "CGD011_1_" + PageTimeStamp.Value;
        string SessionIDName2 = "CGD011_2_" + PageTimeStamp.Value;
        string SessionIDName3 = "CGD011_3_" + PageTimeStamp.Value;

        CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);

        DataTable Dt;

        if (Session[SessionIDName] != null)
        {
            Dt = (DataTable)Session[SessionIDName];
        }
        else
        {
            ParameterList.Clear();

            ParameterList.Add(this.hidSLPDate1.Text.Trim());
            ParameterList.Add(this.hidtxtPickBatch.Text.Trim());

            Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryRouteOrder, ParameterList);
        }

        if (Dt.Rows.Count == 0)
        {
            CrystalReportViewer1.Visible = false;

            if (showNoDataMessage == "Y")
                ErrorMsgLabel.Text = "查無資料";
                //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 查無資料 ');", true);

            txtRouteADD.Text = "";
            txtRouteSort.Text = "";
            Panel1.Visible = false;
            Panel2.Visible = false;

            lblTotalX.Text = "總計店數:";
            lblTotalY.Text = "總計店數:";
            lblTotalZ.Text = "總計店數:";
        }


        Session[SessionIDName] = Dt;

        DataTable tempDT1 = Dt.Copy();
        DataTable tempDT2 = Dt.Copy();
        DataTable tempDT3 = Dt.Copy();

        Session[SessionIDName1] = tempDT1;
        Session[SessionIDName2] = tempDT2;
        Session[SessionIDName3] = tempDT3;

        DataView DV1 = tempDT1.DefaultView;
        DataView DV2 = tempDT2.DefaultView;
        DataView DV3 = tempDT3.DefaultView;

        DV1.RowFilter = "LINE = 'X'";
        DV2.RowFilter = "LINE = 'Y'";
        DV3.RowFilter = "LINE = 'Z'";

        DV1.Sort = "PICK_ORDER ASC";
        DV2.Sort = "PICK_ORDER ASC";
        DV3.Sort = "PICK_ORDER ASC";

        GridView1.DataSource = DV1;
        GridView2.DataSource = DV2;
        GridView3.DataSource = DV3;

        //GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        //GridView2.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        //GridView3.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);

        GridView1.PageIndex = 0;
        GridView2.PageIndex = 0;
        GridView3.PageIndex = 0;

        GridView1.DataBind();
        GridView2.DataBind();
        GridView3.DataBind();

        #region 計算總店數

        DataTable exchange1 = DV1.ToTable();
        DataTable exchange2 = DV2.ToTable();
        DataTable exchange3 = DV3.ToTable();


        int totalStoreX = 0;
        for (int i = 0; i <= exchange1.Rows.Count - 1; i++)
        {
            if (exchange1.Rows[i][16].ToString() != "")
            {
                totalStoreX += Convert.ToInt32(exchange1.Rows[i][16].ToString());
            }
        }

        lblTotalX.Text = "總計店數:" + Convert.ToString(totalStoreX);


        int totalStoreY = 0;
        for (int i = 0; i <= exchange2.Rows.Count - 1; i++)
        {
            if (exchange2.Rows[i][16].ToString() != "")
            {
                totalStoreY += Convert.ToInt32(exchange2.Rows[i][16].ToString());
            }
        }

        lblTotalY.Text = "總計店數:" + Convert.ToString(totalStoreY);


        int totalStoreZ = 0;
        for (int i = 0; i <= exchange3.Rows.Count - 1; i++)
        {
            if (exchange3.Rows[i][16].ToString() != "")
            {
                totalStoreZ += Convert.ToInt32(exchange3.Rows[i][16].ToString());
            }
        }

        lblTotalZ.Text = "總計店數:" + Convert.ToString(totalStoreZ);


        #endregion
    }
예제 #4
0
    /// <summary>
    /// 檢查路線履歷是否已過期
    /// </summary>
    private string CheckRoute()
    {
        CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);

        ParameterList.Clear();

        ParameterList.Add(SLP_SLPDate1.Text.Trim());
        ParameterList.Add(txtRouteADD.Text.Trim());

        return BCO.CheckRoute(ParameterList);
    }
예제 #5
0
    /// <summary>
    /// 插入鈕
    /// </summary>
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        hidtxtPickBatch.Text = txtPickBatch.Text;

        if (SLP_SLPDate1.Text != "")
        {
            hidSLPDate1.Text = Convert.ToDateTime(SLP_SLPDate1.Text).ToShortDateString();
        }

        #region 檢查輸入值


        if (ddlLineADD.SelectedItem.Text == "")
        {
            ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert('[理貨線]不得為空白');", true);

            return;
        }

        if (txtRouteADD.Text.Trim() == "")
        {
            ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert('[路線]不得為空白');", true);

            return;
        }

        TextBox tmpBox = (TextBox)txtRouteADD.FindControl("TextBoxName");

        if (tmpRouteName == "查無資料")
        {
            ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert('所輸入之[路線]不正確');", true);

            return;
        }

        string checkResult = CheckRoute();
        if (checkResult != "1")
        {
            ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert(' 查無所輸入之[路線]之履歷,或該[路線]之履歷已過期 ');", true);

            return;
        }


        #endregion

        string SessionIDName = "CGD011_" + PageTimeStamp.Value;
        DataTable Dt = null;

        try
        {
            if (Session[SessionIDName] != null)
            {
                Dt = (DataTable)Session[SessionIDName];
            }
            else
            {
                //從DB讀取一空table回來
                CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);
                ParameterList.Clear();
                Dt = BCO.QuerySwitch(CGDModel.MaintainSetRouteOrder.QueryType.Empty, ParameterList);
            }

            tempID = 0;

            DataView tempDT = new DataView();
            tempDT.Table = Dt.Copy();
            tempDT.Sort = "ID ASC";
            if (Dt.Rows.Count != 0)
            {
                tempID = Convert.ToInt32(tempDT[tempDT.Count - 1]["ID"].ToString());
            }

            DataRow dRow = Dt.NewRow();

            //ID和CODE暫自訂, 真正寫入CO時會重取
            int v_ID = tempID + 1;
            int v_CODE = tempID + 1;

            dRow["ID"] = v_ID;
            dRow["CODE"] = v_CODE;

            dRow["CREATEDATE"] = DateTime.Now;
            dRow["UPDATEDATE"] = DateTime.Now;
            dRow["CREATEUID"] = Session["UID"].ToString();
            dRow["UPDATEUID"] = Session["UID"].ToString();
            dRow["STATUS"] = "0";
            dRow["ENABLE"] = "1";
            if (Dt.Columns.Contains("NAME") != null)
            {
                dRow["NAME"] = ddlLineADD.SelectedItem.Text + "-" + txtRouteADD.Text;
            }
            dRow["DPS_CODE"] = "A";
            dRow["ST_ACCEPT_DATE"] = Convert.ToDateTime(hidSLPDate1.Text);
            dRow["PICK_BATCH"] = hidtxtPickBatch.Text;
            dRow["LINE"] = ddlLineADD.SelectedItem.Text;

            #region 取路線名

            TextBox _tmpRouteName = (TextBox)txtRouteADD.FindControl("TextBoxName");
            tmpRouteName = Request[_tmpRouteName.UniqueID].ToString();

            #endregion

            dRow["ROUTE_NAME"] = tmpRouteName;
            dRow["STORE_CNT"] = "0";

            string repeat = "";
            int tempPickOrder = 0;
            if (txtRouteSort.Text.Trim() == "") //使用者無輸入序號
            {
                #region 找出該線最後一號()


                tempPickOrder = 0;
                DataView dv = new DataView();
                dv.Table = Dt.Copy();
                dv.RowFilter = "LINE ='" + ddlLineADD.SelectedItem.Text + "'";
                dv.Sort = "PICK_ORDER ASC";
                DataTable tempDt = dv.ToTable();
                if (tempDt.Rows.Count != 0)
                {
                    tempPickOrder = Convert.ToInt32(tempDt.Rows[tempDt.Rows.Count - 1]["PICK_ORDER"].ToString());
                }
                else
                {
                    tempPickOrder = 0;
                }


                #endregion

                tempPickOrder += 1;

                string _tempPickOrder = Convert.ToString(tempPickOrder);

                if (_tempPickOrder.Length == 1)
                {
                    _tempPickOrder = "00" + _tempPickOrder;
                }
                else if (_tempPickOrder.Length == 2)
                {
                    _tempPickOrder = "0" + _tempPickOrder;
                }


                dRow["PICK_ORDER"] = _tempPickOrder;
            }
            else
            {
                #region Check使用者所輸入之序號是否有重複


                tempPickOrder = 0;
                DataView dv = new DataView();
                dv.Table = Dt.Copy();
                dv.RowFilter = "LINE ='" + ddlLineADD.SelectedItem.Text + "'";
                dv.Sort = "PICK_ORDER ASC";
                DataTable tempDt = dv.ToTable();
                for (int i = 0; i <= tempDt.Rows.Count - 1; i++)
                {
                    if (tempDt.Rows[i].RowState != DataRowState.Deleted)
                    {
                        if (tempDt.Rows[i]["PICK_ORDER"].ToString() == txtRouteSort.Text.Trim())
                        {
                            repeat = "Y";
                        }
                    }
                }


                #endregion

                if (repeat == "Y")
                {
                    ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert('所輸入之序號已重複');", true);

                    return;
                }
                else
                {
                    dRow["PICK_ORDER"] = txtRouteSort.Text.Trim();
                }
            }

            #region Check使用者所輸入之路線是否有重複

            tempPickOrder = 0;
            DataView dv2 = new DataView();
            dv2.Table = Dt.Copy();
            //dv2.RowFilter = "LINE ='" + ddlLineADD.SelectedItem.Text + "'";
            //dv2.Sort = "PICK_ORDER ASC";
            DataTable tempDt2 = dv2.ToTable();
            for (int i = 0; i <= tempDt2.Rows.Count - 1; i++)
            {
                if (tempDt2.Rows[i].RowState != DataRowState.Deleted)
                {
                    if (tempDt2.Rows[i]["ROUTE"].ToString() == txtRouteADD.Text.Trim())
                    {
                        repeat = "Y";
                    }
                }
            }

            if (repeat == "Y")
            {
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert('所輸入之路線已重複');", true);

                return;
            }
            else
            {
                dRow["ROUTE"] = txtRouteADD.Text.Trim();
            }

            #endregion


            Dt.Rows.Add(dRow);


            ddlLineADD.SelectedIndex = 0;
            txtRouteADD.Text = "";
            txtRouteSort.Text = "";
            Panel1.Visible = false;


            Session[SessionIDName] = Dt;


            DataTable tempDT1 = Dt.Copy();
            DataTable tempDT2 = Dt.Copy();
            DataTable tempDT3 = Dt.Copy();

            string SessionIDName1 = "CGD011_1_" + PageTimeStamp.Value;
            string SessionIDName2 = "CGD011_2_" + PageTimeStamp.Value;
            string SessionIDName3 = "CGD011_3_" + PageTimeStamp.Value;

            Session[SessionIDName1] = tempDT1;
            Session[SessionIDName2] = tempDT2;
            Session[SessionIDName3] = tempDT3;

            DataView DV1 = tempDT1.DefaultView;
            DataView DV2 = tempDT2.DefaultView;
            DataView DV3 = tempDT3.DefaultView;

            DV1.RowFilter = "LINE = 'X'";
            DV2.RowFilter = "LINE = 'Y'";
            DV3.RowFilter = "LINE = 'Z'";

            DV1.Sort = "PICK_ORDER ASC";
            DV2.Sort = "PICK_ORDER ASC";
            DV3.Sort = "PICK_ORDER ASC";

            GridView1.DataSource = DV1;
            GridView2.DataSource = DV2;
            GridView3.DataSource = DV3;

            //GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            //GridView2.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            //GridView3.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);

            GridView1.PageIndex = 0;
            GridView2.PageIndex = 0;
            GridView3.PageIndex = 0;

            GridView1.DataBind();
            GridView2.DataBind();
            GridView3.DataBind();

            Panel2.Visible = true;

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
예제 #6
0
    /// <summary>
    /// 複製鈕(複製視窗內的)
    /// </summary>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region 輸入檢查

        if (SLP_CopyFromDate.Text == "")
        {
            ErrorMsgLabel.Text = "舊[門市進貨日]欄位不得空白";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD021.aspx", "alert(' 舊[門市進貨日]欄位不得空白 ');", true);
            return;
        }

        if (txtPickBatchCopyFrom.Text == "")
        {
            ErrorMsgLabel.Text = "舊[理貨批次]欄位不得空白";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD021.aspx", "alert(' 舊[理貨批次]欄位不得空白 ');", true);
            return;
        }

        if (SLP_CopyToDate.Text == "")
        {
            ErrorMsgLabel.Text = "新[門市進貨日]欄位不得空白";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD021.aspx", "alert(' 新[門市進貨日]欄位不得空白 ');", true);
            return;
        }

        if (Convert.ToDateTime(SLP_CopyToDate.Text) <= DateTime.Now)
        {
            ErrorMsgLabel.Text = "新[門市進貨日]欄位不得小於等於系統日";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD021.aspx", "alert(' 新[門市進貨日]欄位不得小於等於系統日 ');", true);
            return;
        }

        if (txtPickBatchCopyTo.Text == "")
        {
            ErrorMsgLabel.Text = "新[理貨批次]欄位不得空白";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD021.aspx", "alert(' 新[理貨批次]欄位不得空白 ');", true);
            return;
        }

        #endregion

        System.IO.TextReader tr;

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

        try
        {
            CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);
            string strWhere = "";

            // 檢查新日期是否有資料-----------------------------------------------------------------------------------------
            #region  checking


            DataTable DtCheckNew;
            ParameterList.Clear();

            ParameterList.Add(this.SLP_CopyToDate.Text.Trim());
            ParameterList.Add(this.txtPickBatchCopyTo.Text.Trim());

            DtCheckNew = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryRouteOrder, ParameterList);

            if (DtCheckNew.Rows.Count > 0)
            {
                ErrorMsgLabel.Text = "輸入的新門市進貨日已有資料";

                //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 輸入的新門市進貨日已有資料 ');", true);
                return;
            }


            #endregion

            // 檢查舊日期是否有資料 , 如有資料則進行複製--------------------------------------------------------------------
            #region  checking


            DataTable DtCheckOld;
            ParameterList.Clear();

            ParameterList.Add(this.SLP_CopyFromDate.Text.Trim());
            ParameterList.Add(this.txtPickBatchCopyFrom.Text.Trim());

            DtCheckOld = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryRouteOrder, ParameterList);

            if (DtCheckOld.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "輸入的舊門市進貨日沒有資料可以複製";

                //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 輸入的舊門市進貨日沒有資料可以複製 ');", true);
                return;
            }
            else
            {
                for (int i = 0; i <= DtCheckOld.Rows.Count - 1; i++)
                {
                    ParameterList.Clear();
                    ParameterListDel.Clear();

                    ParameterList.Add(DtCheckOld.Rows[i]["NAME"]);
                    ParameterList.Add(DtCheckOld.Rows[i]["CREATEDATE"]);
                    ParameterList.Add(DtCheckOld.Rows[i]["CREATEUID"]);
                    ParameterList.Add(System.DateTime.Now);
                    ParameterList.Add(Session["UID"].ToString());
                    ParameterList.Add(DtCheckOld.Rows[i]["STATUS"]);
                    ParameterList.Add(DtCheckOld.Rows[i]["ENABLE"]);
                    ParameterList.Add(DtCheckOld.Rows[i]["DPS_CODE"]);
                    ParameterList.Add(Convert.ToDateTime(this.SLP_CopyToDate.Text.Trim()));
                    ParameterList.Add(this.txtPickBatchCopyTo.Text.Trim());
                    ParameterList.Add(DtCheckOld.Rows[i]["LINE"]);
                    ParameterList.Add(DtCheckOld.Rows[i]["PICK_ORDER"]);
                    ParameterList.Add(DtCheckOld.Rows[i]["ROUTE"]);
                    ParameterList.Add(DtCheckOld.Rows[i]["STORE_CNT"]);

                    BCO.InsertRouteOrder(ParameterList, DBT);
                }
                DBT.Commit();//交易成功
            }


            #endregion

            ErrorMsgLabel.Text = "複製完畢";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 複製完畢 ');", true);
        }
        catch (Exception ex)
        {
            DBT.Rollback();//交易失敗

            ErrorMsgLabel.Text = ex.Message;
        }

        btnCloseCopy_Click(null, null);
    }
예제 #7
0
    /// <summary>
    /// 列印鈕
    /// </summary>
    protected void btnPrintReport_Click(object sender, EventArgs e)
    {
        if (VerifyFormData() == true)
        {
            try
            {
                ErrorMsgLabel.Text = "";
                this.hid_PageStatus.Value = "PRINT";

                CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);

                DataTable Dt;
                ParameterList.Clear();

                ParameterList.Add(this.SLP_SLPDate1.Text.Trim());
                ParameterList.Add(this.txtPickBatch.Text.Trim());

                Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryRouteOrder, ParameterList);

                if (Dt.Rows.Count == 0)
                {
                    this.hid_PageStatus.Value = "QUERY";
                    ErrorMsgLabel.Text = "查無資料";

                    //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 查無資料 ');", true);

                    txtRouteADD.Text = "";
                    txtRouteSort.Text = "";
                    Panel1.Visible = false;
                    Panel2.Visible = false;

                    //CrystalReportViewer1.Visible = false;

                    return;
                }
                else
                {

                    #region 顯示報表

                    string s_FileName = "";      //設定輸出檔名
                    string s_rptFilePath = "";   //設定報表路徑

                    s_rptFilePath = Server.MapPath("./REPORT/CGD011.rpt");
                    s_FileName = HttpUtility.UrlEncode("理貨線順序設定.PDF", System.Text.Encoding.UTF8);


                    LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF");

                    #endregion

                }
                //預覽報表
                // ShowReport(Dt);
            }
            catch (Exception ex)
            {
                ErrorMsgLabel.Text = ex.Message;
            }
            finally { }
        }
    }
예제 #8
0
    /// <summary>
    /// 店數計算鈕
    /// </summary>
    protected void btnCount_Click(object sender, EventArgs e)
    {
        string SessionIDName = "CGD011_" + PageTimeStamp.Value;
        DataTable Dt = null;

        if (Session[SessionIDName] != null)
        {
            Dt = (DataTable)Session[SessionIDName];
        }

        if (Dt == null)
        {
            ErrorMsgLabel.Text = "請先查詢資料";

            return;
        }

        if (Dt.Rows.Count == 0)
        {
            ErrorMsgLabel.Text = "請先查詢資料";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 請先查詢資料 ');", true);

            return;
        }

        try
        {
            CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);

            for (int i = 0; i <= Dt.Rows.Count - 1; i++)
            {
                ParameterList.Clear();

                ParameterList.Add(Convert.ToDateTime(Dt.Rows[i]["ST_ACCEPT_DATE"].ToString()).ToShortDateString());
                ParameterList.Add(Dt.Rows[i]["PICK_BATCH"].ToString());
                ParameterList.Add(Dt.Rows[i]["ROUTE"].ToString());

                DataTable Dt2 = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.CountStore, ParameterList);

                Dt.Rows[i]["STORE_CNT"] = Dt2.Rows[0][0].ToString().Trim();
            }

            Session[SessionIDName] = Dt;

            //將temp資料重新bind一次至GridView1,2,3
            if (Dt != null)
            {
                DataTable tempDT1 = Dt.Copy();
                DataTable tempDT2 = Dt.Copy();
                DataTable tempDT3 = Dt.Copy();

                string SessionIDName1 = "CGD011_1_" + PageTimeStamp.Value;
                string SessionIDName2 = "CGD011_2_" + PageTimeStamp.Value;
                string SessionIDName3 = "CGD011_3_" + PageTimeStamp.Value;

                Session[SessionIDName1] = tempDT1;
                Session[SessionIDName2] = tempDT2;
                Session[SessionIDName3] = tempDT3;

                DataView DV1 = tempDT1.DefaultView;
                DataView DV2 = tempDT2.DefaultView;
                DataView DV3 = tempDT3.DefaultView;

                DV1.RowFilter = "LINE = 'X'";
                DV2.RowFilter = "LINE = 'Y'";
                DV3.RowFilter = "LINE = 'Z'";

                DV1.Sort = "PICK_ORDER ASC";
                DV2.Sort = "PICK_ORDER ASC";
                DV3.Sort = "PICK_ORDER ASC";

                GridView1.DataSource = DV1;
                GridView2.DataSource = DV2;
                GridView3.DataSource = DV3;

                //GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
                //GridView2.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
                //GridView3.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);

                GridView1.PageIndex = 0;
                GridView2.PageIndex = 0;
                GridView3.PageIndex = 0;

                GridView1.DataBind();
                GridView2.DataBind();
                GridView3.DataBind();

                #region 計算總店數



                int totalStoreX = 0;
                for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
                {
                    totalStoreX += Convert.ToInt32(((Label)(GridView1.Rows[i].FindControl("Label5"))).Text);
                }

                lblTotalX.Text = "總計店數:" + Convert.ToString(totalStoreX);

                int totalStoreY = 0;
                for (int i = 0; i <= GridView2.Rows.Count - 1; i++)
                {
                    totalStoreY += Convert.ToInt32(((Label)(GridView2.Rows[i].FindControl("Label5"))).Text);
                }

                lblTotalY.Text = "總計店數:" + Convert.ToString(totalStoreY);

                int totalStoreZ = 0;
                for (int i = 0; i <= GridView3.Rows.Count - 1; i++)
                {
                    totalStoreZ += Convert.ToInt32(((Label)(GridView3.Rows[i].FindControl("Label5"))).Text);
                }

                lblTotalZ.Text = "總計店數:" + Convert.ToString(totalStoreZ);


                #endregion
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
예제 #9
0
    /// <summary>
    /// 匯出確定鈕
    /// </summary>
    protected void btnExportSubmit_Click(object sender, EventArgs e)
    {
        #region 檢查輸入值


        if (txtExportPath.Text.Trim() == "")
        {
            ErrorMsgLabel.Text = "[匯出路徑]欄位不得空白";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' [匯出路徑]欄位不得空白 ');", true);
            return;
        }

        if (txtExportCount.Text.Trim() == "0")
        {
            ErrorMsgLabel.Text = "無資料可匯出";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 無資料可匯出 ');", true);
            return;
        }


        #endregion

        try
        {
            //---讀取資料
            CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);

            DataTable Dt;
            ParameterList.Clear();

            ParameterList.Add(SLP_SLPDate1.Text.Trim());
            ParameterList.Add(txtPickBatch.Text.Trim());

            Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.ExpRoute, ParameterList);

            if (Dt.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "無資料可匯出";

                //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 無資料可匯出 ');", true);
                return;
            }


            //---輸出至文字檔
            System.Text.StringBuilder sb_Out_String = new System.Text.StringBuilder();
            Response.Clear();
            Response.Buffer = true;
            Response.Charset = "BIG5";
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(txtExportPath.Text.Trim()));
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");
            Response.ContentType = "application/ms-txt";
            this.EnableViewState = false;

            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);


            foreach (DataRow dRow in Dt.Rows)
            {
                sb_Out_String.Remove(0, sb_Out_String.Length);

                sb_Out_String.Append(dRow["DATA"].ToString());

                Response.Write(sb_Out_String.ToString());

                Response.Write(oHtmlTextWriter.NewLine);
            }

            Response.End();

            ErrorMsgLabel.Text = "匯出完畢";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 匯出完畢 ');", true);
        }

        catch (System.UnauthorizedAccessException a)
        {
            ErrorMsgLabel.Text = "匯出失敗,對該路徑無寫入權限";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 匯出失敗,對該路徑無寫入權限 ');", true);
        }
        catch (System.IO.DirectoryNotFoundException b)
        {
            ErrorMsgLabel.Text = "匯出失敗,請確認儲存路徑正確";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 匯出失敗,請確認儲存路徑正確 ');", true);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
예제 #10
0
    /// <summary>
    /// 匯出鈕
    /// </summary>
    protected void btnExport_Click(object sender, EventArgs e)
    {
        if (VerifyFormData() == true)
        {
            DataTable Dt = null;

            try
            {
                CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);

                ParameterList.Clear();

                ParameterList.Add(this.SLP_SLPDate1.Text.Trim());
                ParameterList.Add(this.txtPickBatch.Text.Trim());

                Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryRouteOrder, ParameterList);
            }
            catch (Exception ex)
            {
                ErrorMsgLabel.Text = ex.Message;
            }
            finally { }

            txtExportPath.Text = @"P:\DPS\理貨優先順序.TXT";
            txtExportCount.Text = Convert.ToString(Dt.Rows.Count);

            panExport.Visible = true;
        }
    }
예제 #11
0
    /// <summary>
    /// 確定鈕(匯入視窗)
    /// </summary>
    protected void btnPanImportSubmit_Click(object sender, EventArgs e)
    {
        #region 檢查輸入值


        if (ddlRouteImport.SelectedItem.Text == "")
        {
            ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert('請先選擇理貨路線');", true);

            return;
        }


        #endregion

        DataTable Dt = null;
        DataTable DtImport = null;
        DataView tempDT = new DataView();

        try
        {
            //從DB讀取匯入資料
            string SessionIDNameM = "CGD011_" + PageTimeStamp.Value;
            string SessionIDName = "CGD011_ImportDB_" + PageTimeStamp.Value;

            CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);


            ParameterList.Clear();
            ParameterList.Add(hidSLPDate1.Text);
            ParameterList.Add(hidtxtPickBatch.Text);

            DtImport = BCO.QuerySwitch(CGDModel.MaintainSetRouteOrder.QueryType.ImpRoute, ParameterList);


            if (Session[SessionIDNameM] != null)
            {
                Dt = (DataTable)Session[SessionIDNameM];
            }
            else
            {
                ParameterList.Clear();
                Dt = BCO.QuerySwitch(CGDModel.MaintainSetRouteOrder.QueryType.Empty, ParameterList);
            }


            tempID = 0;
            tempDT.Table = Dt.Copy();
            tempDT.Sort = "ID ASC";
            if (Dt.Rows.Count != 0)
            {
                tempID = Convert.ToInt32(tempDT[tempDT.Count - 1]["ID"].ToString());
            }


            for (int M = 0; M <= DtImport.Rows.Count - 1; M++)
            {
                DataRow dRow = Dt.NewRow();

                //ID和CODE暫自訂, 真正寫入CO時會重取
                int v_ID = tempID + 1;
                int v_CODE = tempID + 1;

                dRow["ID"] = v_ID;
                dRow["CODE"] = v_CODE;

                dRow["CREATEDATE"] = DateTime.Now;
                dRow["UPDATEDATE"] = DateTime.Now;
                dRow["CREATEUID"] = Session["UID"].ToString();
                dRow["UPDATEUID"] = Session["UID"].ToString();
                dRow["STATUS"] = "1";
                dRow["ENABLE"] = "1";

                dRow["NAME"] = "";
                dRow["DPS_CODE"] = "A";
                dRow["ST_ACCEPT_DATE"] = hidSLPDate1.Text;
                dRow["PICK_BATCH"] = hidtxtPickBatch.Text;
                dRow["LINE"] = ddlRouteImport.SelectedItem.Text;
                dRow["ROUTE_NAME"] = DtImport.Rows[M]["ROUTE_NAME"].ToString();
                dRow["STORE_CNT"] = 0;

                string repeat = "";
                int tempPickOrder = 0;

                #region 找出該線最後一號


                tempPickOrder = 0;
                DataView dv = new DataView();
                dv.Table = Dt.Copy();
                dv.RowFilter = "LINE ='" + ddlRouteImport.SelectedItem.Text + "'";
                dv.Sort = "PICK_ORDER ASC";
                DataTable tempDt = dv.ToTable();
                if (tempDt.Rows.Count != 0)
                {
                    tempPickOrder = Convert.ToInt32(tempDt.Rows[tempDt.Rows.Count - 1]["PICK_ORDER"].ToString());
                }
                else
                {
                    tempPickOrder = 0;
                }


                #endregion

                tempPickOrder += 1;

                string _tempPickOrder = Convert.ToString(tempPickOrder);

                if (_tempPickOrder.Length == 1)
                {
                    _tempPickOrder = "00" + _tempPickOrder;
                }
                else if (_tempPickOrder.Length == 2)
                {
                    _tempPickOrder = "0" + _tempPickOrder;
                }

                dRow["PICK_ORDER"] = _tempPickOrder;


                #region Check使用者所輸入之路線是否有重複


                for (int i = 0; i <= Dt.Rows.Count - 1; i++)
                {
                    if (Dt.Rows[i]["ROUTE"].ToString() == DtImport.Rows[M]["ROUTE"].ToString().Trim())
                    {
                        repeat = "Y";
                    }
                }

                if (repeat == "Y")
                {
                    ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert('欲匯入之路線已重複');", true);

                    return;
                }
                else
                {
                    dRow["ROUTE"] = DtImport.Rows[M]["ROUTE"].ToString();
                }


                #endregion


                Dt.Rows.Add(dRow);
            }


            Session[SessionIDNameM] = Dt;


            DataTable tempDT1 = Dt.Copy();
            DataTable tempDT2 = Dt.Copy();
            DataTable tempDT3 = Dt.Copy();

            string SessionIDName1 = "CGD011_1_" + PageTimeStamp.Value;
            string SessionIDName2 = "CGD011_2_" + PageTimeStamp.Value;
            string SessionIDName3 = "CGD011_3_" + PageTimeStamp.Value;

            Session[SessionIDName1] = tempDT1;
            Session[SessionIDName2] = tempDT2;
            Session[SessionIDName3] = tempDT3;

            DataView DV1 = tempDT1.DefaultView;
            DataView DV2 = tempDT2.DefaultView;
            DataView DV3 = tempDT3.DefaultView;

            DV1.RowFilter = "LINE = 'X'";
            DV2.RowFilter = "LINE = 'Y'";
            DV3.RowFilter = "LINE = 'Z'";

            DV1.Sort = "PICK_ORDER ASC";
            DV2.Sort = "PICK_ORDER ASC";
            DV3.Sort = "PICK_ORDER ASC";

            GridView1.DataSource = DV1;
            GridView2.DataSource = DV2;
            GridView3.DataSource = DV3;

            //GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            //GridView2.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            //GridView3.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);

            GridView1.PageIndex = 0;
            GridView2.PageIndex = 0;
            GridView3.PageIndex = 0;

            GridView1.DataBind();
            GridView2.DataBind();
            GridView3.DataBind();

            Panel2.Visible = true;

            ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert('匯入完畢');", true);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
예제 #12
0
    /// <summary>
    /// 匯入鈕(開啟匯入視窗)
    /// </summary>
    protected void btnImport_Click(object sender, EventArgs e)
    {
        if (VerifyFormData() == true)
        {
            try
            {
                this.hidSLPDate1.Text = this.SLP_SLPDate1.Text.Trim();
                this.hidtxtPickBatch.Text = this.txtPickBatch.Text.Trim();

                if (Convert.ToDateTime(hidSLPDate1.Text) <= DateTime.Now)
                {
                    ErrorMsgLabel.Text = "[門市進貨日]小於等於系統日時無法執行匯入功能";

                    //ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "A", "alert('[門市進貨日]小於等於系統日時無法執行匯入功能');", true);

                    return;
                }

                // 檢查新日期是否有資料-----------------------------------------------------------------------------------------
                DataTable DtCheckNew;

                CGDModel.MaintainSetRouteOrder BCO = new CGDModel.MaintainSetRouteOrder(ConntionDB);


                ParameterList.Clear();

                ParameterList.Add(this.hidSLPDate1.Text.Trim());
                ParameterList.Add(this.hidtxtPickBatch.Text.Trim());

                DtCheckNew = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryRouteOrder, ParameterList);

                if (DtCheckNew.Rows.Count > 0)
                {
                    ErrorMsgLabel.Text = "所輸入的門市進貨日已有資料";

                    //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 所輸入的門市進貨日已有資料 ');", true);

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

            panImport.Visible = true;
            ddlRouteImport.SelectedIndex = 0;
        }
    }
예제 #13
0
    /// <summary>
    /// 儲存鈕
    /// </summary>
    protected void btnSave_Click1(object sender, EventArgs e)
    {
        string SessionIDName = "CGD011_" + PageTimeStamp.Value;

        DataTable Dt = null;

        DataTable DT_Add = null;
        DataTable DT_Mod = null;
        DataTable DT_Del = null;

        if (Session[SessionIDName] != null)
        {
            Dt = (DataTable)Session[SessionIDName];

            DT_Add = Dt.GetChanges(DataRowState.Added);
            DT_Mod = Dt.GetChanges(DataRowState.Modified);
            DT_Del = Dt.GetChanges(DataRowState.Deleted);
        }
        else
        {
            ErrorMsgLabel.Text = "目前無資料異動";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 目前無資料異動 ');", true);
            return;
        }

        if (DT_Add == null && DT_Mod == null && DT_Del == null)
        {
            ErrorMsgLabel.Text = "目前無資料異動";

            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 目前無資料異動 ');", true);
            return;
        }

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



        try
        {
            //刪除----------------------------------------------------------------------------------------------------------
            if (DT_Del != null)
            {
                foreach (DataRow dRow in DT_Del.Rows)
                {
                    ParameterList.Clear();

                    ParameterList.Add(dRow["PICK_BATCH", DataRowVersion.Original].ToString());
                    ParameterList.Add(Convert.ToDateTime(dRow["ST_ACCEPT_DATE", DataRowVersion.Original].ToString()).ToShortDateString());
                    ParameterList.Add(dRow["ROUTE", DataRowVersion.Original].ToString());
                    ParameterList.Add(Convert.ToDateTime(dRow["UPDATEDATE", DataRowVersion.Original].ToString()));
                    ParameterList.Add(dRow["UPDATEUID", DataRowVersion.Original].ToString());

                    string MSG = BCO.DeleteRouteOrder(ParameterList, DBT);

                    if (MSG == "NODATA")
                    {
                        throw new Exception("DB_NODATA");
                    }
                }
            }

            //新增----------------------------------------------------------------------------------------------------------
            if (DT_Add != null)
            {
                foreach (DataRow dRow in DT_Add.Rows)
                {
                    ParameterList.Clear();

                    if (DT_Add.Columns.Contains("NAME").ToString() == "True")
                    {
                        ParameterList.Add(dRow["NAME"]);
                    }
                    else
                    {
                        ParameterList.Add(dRow["LINE"].ToString() + "-" + dRow["ROUTE"].ToString());
                    }
                    ParameterList.Add(dRow["CREATEDATE"]);
                    ParameterList.Add(dRow["CREATEUID"]);
                    ParameterList.Add(dRow["UPDATEDATE"]);
                    ParameterList.Add(dRow["UPDATEUID"]);
                    if (DT_Add.Columns.Contains("STATUS").ToString() == "True")
                    {
                        ParameterList.Add(dRow["STATUS"]);
                    }
                    else
                    {
                        ParameterList.Add(0);
                    }
                    ParameterList.Add(dRow["ENABLE"]);
                    ParameterList.Add(dRow["DPS_CODE"]);
                    ParameterList.Add(Convert.ToDateTime(dRow["ST_ACCEPT_DATE"]).ToShortDateString());
                    ParameterList.Add(dRow["PICK_BATCH"]);
                    ParameterList.Add(dRow["LINE"]);
                    ParameterList.Add(dRow["PICK_ORDER"]);
                    ParameterList.Add(dRow["ROUTE"]);
                    ParameterList.Add(dRow["STORE_CNT"]);


                    BCO.InsertRouteOrder(ParameterList, DBT);
                }
            }

            //修改----------------------------------------------------------------------------------------------------------
            if (DT_Mod != null)
            {
                foreach (DataRow dRow in DT_Mod.Rows)
                {
                    ParameterList.Clear();

                    ParameterList.Add(dRow["UPDATEUID", DataRowVersion.Current].ToString());
                    ParameterList.Add(dRow["NAME", DataRowVersion.Current].ToString());
                    ParameterList.Add(dRow["DPS_CODE", DataRowVersion.Current].ToString());
                    ParameterList.Add(dRow["ST_ACCEPT_DATE", DataRowVersion.Current]);
                    ParameterList.Add(dRow["PICK_BATCH", DataRowVersion.Current].ToString());
                    ParameterList.Add(dRow["LINE", DataRowVersion.Current].ToString());
                    ParameterList.Add(dRow["PICK_ORDER", DataRowVersion.Current].ToString());
                    ParameterList.Add(dRow["ROUTE", DataRowVersion.Current].ToString());
                    ParameterList.Add(Convert.ToInt32(dRow["STORE_CNT", DataRowVersion.Current].ToString()));

                    ParameterList.Add(Convert.ToDateTime(dRow["CREATEDATE", DataRowVersion.Original].ToString()));
                    ParameterList.Add(dRow["CREATEUID", DataRowVersion.Original].ToString());
                    ParameterList.Add(Convert.ToDateTime(dRow["UPDATEDATE", DataRowVersion.Original].ToString()));
                    ParameterList.Add(dRow["UPDATEUID", DataRowVersion.Original].ToString());
                    ParameterList.Add(Convert.ToInt16(dRow["STATUS", DataRowVersion.Original].ToString()));
                    ParameterList.Add(Convert.ToInt16(dRow["ENABLE", DataRowVersion.Original].ToString()));
                    ParameterList.Add(dRow["NAME", DataRowVersion.Original].ToString());
                    ParameterList.Add(dRow["DPS_CODE", DataRowVersion.Original].ToString());
                    ParameterList.Add(dRow["ST_ACCEPT_DATE", DataRowVersion.Original].ToString());
                    ParameterList.Add(dRow["PICK_BATCH", DataRowVersion.Original].ToString());
                    ParameterList.Add(dRow["LINE", DataRowVersion.Original].ToString());
                    ParameterList.Add(dRow["PICK_ORDER", DataRowVersion.Original].ToString());
                    ParameterList.Add(dRow["ROUTE", DataRowVersion.Original].ToString());
                    ParameterList.Add(Convert.ToInt32(dRow["STORE_CNT", DataRowVersion.Original].ToString()));

                    string MSG = BCO.UpdateRouteOrder(ParameterList, DBT);

                    if (MSG == "NODATA")
                    {
                        throw new Exception("DB_NODATA");
                    }
                }
            }

            DBT.Commit();//交易成功

            btnQuery_Click(null, null);

            ErrorMsgLabel.Text = "儲存完畢";
            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD011.aspx", "alert(' 儲存完畢 ');", true);
        }
        catch (Exception ex)
        {
            DBT.Rollback();//交易失敗

            if (ex.Message.IndexOf("違反必須為唯一的限制條件") > 0)
            {
                ErrorMsgLabel.Text = "新增之站所已重複";

                //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD281.aspx", "alert(' 新增之站所已重複 ');", true);
                return;
            }

            if (ex.Message.IndexOf("NODATA") > 0)
            {
                ErrorMsgLabel.Text = "原資料已異動過,請重新查詢資料後再作處理";

                //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD281.aspx", "alert(' 原資料已異動過,請重新查詢資料後再作處理 ');", true);
                return;
            }

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