Exemplo n.º 1
0
    private void dataget(FormViewMode fvm)
    {
        if (fvm == FormViewMode.ReadOnly || fvm == FormViewMode.Edit)
        {

            #region 取得 Master 和 Detail 的資料

            CRMModel.MaintainChainMessage BCO = new CRMModel.MaintainChainMessage(ConnectionDB);
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            ParameterList.Add(Request.QueryString["ID"]);

            DataTable dt_Master = new DataTable();
            DataTable dt_Detail = new DataTable();

            dt_Master = BCO.QuerySwitch(CRMModel.MaintainChainMessage.QueryType.CRM122_Query_Master_By_ID, ParameterList);
            dt_Detail = BCO.QuerySwitch(CRMModel.MaintainChainMessage.QueryType.CRM122_Query_Detail_By_ID, ParameterList);

            #endregion

            #region 使用XML放置到前端資料

            xml_MasterOLDData.InnerHtml = dt_Master.DataSet.GetXml();
            xml_DetailOLDData.InnerHtml = dt_Detail.DataSet.GetXml();

            #endregion

            FormView1.DataSource = dt_Master;
            FormView1.DataBind();

        }

    }
Exemplo n.º 2
0
    protected void Edit_SaveButton_Click(object sender, EventArgs e)
    {
        #region 驗證控制項

        int i_Check_gvcheckbox = 0;

        System.Text.StringBuilder stb = new System.Text.StringBuilder();

        TextBox txt_Msg = ((TextBox)FormView1.FindControl("Edit_txt_Msg"));
        DropDownList dp_Msg = (DropDownList)((ASP.sys_slp_slp_enumbase_ascx)FormView1.FindControl("Edit_slp_Msg")).FindControl("D1");
        RadioButtonList rd_Is_Allchan = ((RadioButtonList)FormView1.FindControl("Edit_rdbl_Is_Allchan"));
        GridView gv_Edit = ((GridView)FormView1.FindControl("Edit_GridView"));

        if (txt_Msg.Text.Length <= 0)
        {
            stb.Append("\"訊息內容\"為必填欄位!\\r\\n");
        }
        else
        {
            if (dp_Msg.SelectedValue == "0")
            { //訊息類別=進貨
                if (txt_Msg.Text.Length > 200)
                {
                    stb.Append("\"訊息類別\"為\"進貨\"時,\"訊息內容\"只可輸入200個中文字!\\r\\n");
                }
            }
            else if (dp_Msg.SelectedValue == "1")
            { //訊息類別=退貨


                if (txt_Msg.Text.Length > 40)
                {
                    stb.Append("\"訊息類別\"為\"退貨\"時,\"訊息內容\"只可輸入40個中文字!\\r\\n");
                }
            }
        }

        if (rd_Is_Allchan.SelectedValue == "0")
        { //通路設定=個別通路
            for (int i = 0; i < gv_Edit.Rows.Count; i++)
            {
                if (((CheckBox)gv_Edit.Rows[i].FindControl("Edit_chb_Code")).Checked)
                {
                    i_Check_gvcheckbox += 1;
                }
            }

            if (i_Check_gvcheckbox <= 0)
            {
                stb.Append("\"通路設定\"為\"個別通路\"時,請選擇通路代號!\\r\\n");
            }
        }

        #endregion

        if (stb.ToString() != string.Empty)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(((UpdatePanel)FormView1.FindControl("up_Edit2")), this.GetType(), "CRM122", "alert('" + stb.ToString() + "')", true);
            return;
        }
        else
        {
            #region 編輯狀態


            if (FormView1.CurrentMode == FormViewMode.Edit)
            {
                int res = 0;
                ArrayList ParameterList = new ArrayList();//20091117

                try
                {
                    #region 取得 DETAIL 的 TABLE 資料

                    #region 使用XML轉回DataSet,取得Detail的原始資料


                    //Detail 的資料

                    DataSet ds_Detail = new DataSet();
                    System.IO.StringReader sr_Detail = new System.IO.StringReader(xml_DetailOLDData.InnerHtml);
                    ds_Detail.ReadXml(sr_Detail);
                    DataTable dt_Detail;

                    if (ds_Detail.Tables.Count == 0)
                    {
                        CRMModel.MaintainChainMessage BCO_Detail = new CRMModel.MaintainChainMessage(ConnectionDB);
                        dt_Detail = BCO_Detail.QuerySwitch(CRMModel.MaintainChainMessage.QueryType.CRM122_DETL_Schema, ParameterList).Copy();
                    }
                    else
                    { dt_Detail = ds_Detail.Tables[0]; }

                    #endregion

                    #region 新增一個欄位,記錄狀態


                    DataColumn dColum = new DataColumn();
                    dColum.ColumnName = "STATUS";
                    dColum.DataType = System.Type.GetType("System.String");
                    dt_Detail.Columns.Add(dColum);

                    #endregion

                    #region 比對Detail檔與GridView的資料,如果Detail有GridView沒有,則註記該筆資料被使用者刪除


                    foreach (DataRow dRow in dt_Detail.Rows)
                    {
                        foreach (GridViewRow gView in gv_Edit.Rows)//畫面上使用者選的通路
                        {
                            CheckBox chb_Code = ((CheckBox)gView.FindControl("Edit_chb_Code"));

                            if (chb_Code.Text == dRow["CHAN_NO"].ToString())
                            {
                                if (chb_Code.Checked == false)//如果使用者沒有勾選該筆資料,則將該筆資料從ds_Detail中移除
                                {
                                    dRow["STATUS"] = "DELETE";
                                }
                            }

                        }
                    }

                    #endregion

                    #region 比對GridView與Detail檔的資料,如果GridView有Detail沒有,則新增該筆資料進入Detail,且註記該筆資料被使用者新增


                    foreach (GridViewRow gView in gv_Edit.Rows)//畫面上使用者選的通路
                    {
                        CheckBox chb_Code = ((CheckBox)gView.FindControl("Edit_chb_Code"));

                        if (chb_Code.Checked == true)
                        {
                            DataView dv_Detail = new DataView();
                            dv_Detail.Table = dt_Detail.Copy();

                            dv_Detail.RowFilter = "CHAN_NO = '" + chb_Code.Text + "'";

                            if (dv_Detail.Count == 0)
                            {
                                DataRow dRow_new = (DataRow)dt_Detail.NewRow();

                                dRow_new["PID"] = Request["ID"];
                                dRow_new["CREATEDATE"] = DateTime.Now;
                                dRow_new["CREATEUID"] = Session["UID"].ToString();
                                dRow_new["UPDATEDATE"] = DateTime.Now;
                                dRow_new["UPDATEUID"] = Session["UID"].ToString();
                                dRow_new["CHAN_NO"] = chb_Code.Text;
                                dRow_new["STATUS"] = "ADD";

                                dt_Detail.Rows.Add(dRow_new);
                            }
                        }
                    }

                    #endregion

                    #endregion

                    #region 取得 MASTER 更新資料

                    DateTime v_UPDATEDATE = DateTime.Now;
                    string v_MSG = ((TextBox)FormView1.FindControl("Edit_txt_Msg")).Text.Trim();//訊息內容
                    int v_IS_ALLCHAN = int.Parse(((RadioButtonList)FormView1.FindControl("Edit_rdbl_Is_Allchan")).SelectedItem.Value);//通路類別

                    #endregion

                    #region 取得 MASTER 的原始資料


                    #region 使用XML轉回DataSet

                    DataSet ds_Master = new DataSet();
                    System.IO.StringReader sr_Master = new System.IO.StringReader(xml_MasterOLDData.InnerHtml);
                    ds_Master.ReadXml(sr_Master);

                    #endregion

                    if (ds_Master.Tables[0].Rows.Count == 0)
                    {
                        throw new Exception("抓取不到舊值,更新失敗!");
                    }

                    #endregion

                    #region 加入更新條件

                    ParameterList.Clear();

                    //舊值
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["ID"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["CODE"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["NAME"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["CREATEDATE"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["CREATEUID"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["UPDATEDATE"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["UPDATEUID"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["ENABLE"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["MSG_TYPE"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["BUSDATE"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["MSG"]);
                    ParameterList.Add(ds_Master.Tables[0].Rows[0]["IS_ALLCHAN"]);

                    //需要更新值
                    ParameterList.Add(v_MSG);
                    ParameterList.Add(v_IS_ALLCHAN);
                    ParameterList.Add(v_UPDATEDATE);
                    ParameterList.Add(Session["UID"].ToString());

                    #endregion

                    #region UPDATE 資料至資料庫

                    CRMModel.MaintainChainMessage BCO = new CRMModel.MaintainChainMessage(ConnectionDB);
                    BCO.UpdateMasterAndDetail(ParameterList, null, dt_Detail);

                    #endregion

                    string sId = Request["ID"].ToString();
                    string sCount = Request["COUNT"].ToString();

                    System.Web.UI.ScriptManager.RegisterStartupScript(((UpdatePanel)FormView1.FindControl("up_Edit2")), this.GetType(), "CRM122", "alert('更改完成');location.replace('CRM122.aspx?Code=CRM12&ID=" + sId + "&mode=readonly&COUNT=" + sCount + "');", true);

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

            #endregion
        }
    }
Exemplo n.º 3
0
    }//通路設定更動

    protected void Insert_SaveButton_Click(object sender, EventArgs e)
    {
        #region 驗證控制項

        int i_Check_gvcheckbox = 0;

        TextBox txt_Msg = ((TextBox)FormView1.FindControl("Insert_txt_Msg"));
        DropDownList dp_Msg = (DropDownList)((ASP.sys_slp_slp_enumbase_ascx)FormView1.FindControl("Insert_slp_Msg")).FindControl("D1");
        RadioButtonList rd_Is_Allchan = ((RadioButtonList)FormView1.FindControl("Insert_rdbl_Is_Allchan"));
        GridView gv_Insert = ((GridView)FormView1.FindControl("Insert_GridView"));

        System.Text.StringBuilder stb = new System.Text.StringBuilder();

        if (txt_Msg.Text.Trim().Length <= 0)
        {
            stb.Append("\"訊息內容\"為必填欄位!\\r\\n");
        }
        else
        {
            if (dp_Msg.SelectedValue == "0")
            { //訊息類別=進貨
                if (txt_Msg.Text.Length > 200)
                {
                    stb.Append("\"訊息類別\"為\"進貨\"時,\"訊息內容\"只可輸入200個中文字!\\r\\n");
                }
            }
            else if (dp_Msg.SelectedValue == "1")
            { //訊息類別=退貨
                if (txt_Msg.Text.Length > 40)
                {
                    stb.Append("\"訊息類別\"為\"退貨\"時,\"訊息內容\"只可輸入40個中文字!\\r\\n");
                }
            }
        }

        try { DateTime.ParseExact(((TextBox)((ASP.wui_slp_slp_slpdate_ascx)FormView1.FindControl("slp_Insert_BUSDATE")).FindControl("TextBoxCode")).Text, "yyyy/MM/dd", null); }
        catch { stb.Append("\"業務日期\"輸入的日期格式不正確!\\r\\n"); }

        if (((TextBox)((ASP.wui_slp_slp_slpdate_ascx)FormView1.FindControl("slp_Insert_BUSDATE")).FindControl("TextBoxCode")).Text != "")
        {
            DateTime dt;
            if (!DateTime.TryParse(((TextBox)((ASP.wui_slp_slp_slpdate_ascx)FormView1.FindControl("slp_Insert_BUSDATE")).FindControl("TextBoxCode")).Text, out dt))
            {
                stb.Append("\"業務日期\"輸入有誤,請重新輸入!\\r\\n");
            }
        }

        if (rd_Is_Allchan.SelectedValue == "0")
        { //通路設定=個別通路
            for (int i = 0; i < gv_Insert.Rows.Count; i++)
            {
                if (((CheckBox)gv_Insert.Rows[i].FindControl("Insert_chb_Code")).Checked)
                {
                    i_Check_gvcheckbox += 1;
                }
            }

            if (i_Check_gvcheckbox <= 0)
            {
                stb.Append("\"通路設定\"為\"個別通路\"時,請選擇通路代號!\\r\\n");
            }
        }

        #endregion

        if (stb.ToString() != string.Empty)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(((Button)FormView1.FindControl("Insert_SaveButton")), this.GetType(), "CRM122", "alert('" + stb.ToString() + "')", true);
            return;
        }
        else
        {
            #region 新增狀態

            if (FormView1.CurrentMode == FormViewMode.Insert)
            {
                int i_Return_Id = 0;

                try
                {
                    #region 畫面取值

                    int v_MSG_TYPE = int.Parse(((ASP.sys_slp_slp_enumbase_ascx)FormView1.FindControl("Insert_slp_Msg")).Text);//訊息類別
                    DateTime v_BUSDATE = DateTime.Parse(((TextBox)((ASP.wui_slp_slp_slpdate_ascx)FormView1.FindControl("slp_Insert_BUSDATE")).FindControl("TextBoxCode")).Text);//業務日期
                    string v_MSG = ((TextBox)FormView1.FindControl("Insert_txt_Msg")).Text.Trim();//訊息內容
                    int v_IS_ALLCHAN = Convert.ToInt32(((RadioButtonList)FormView1.FindControl("Insert_rdbl_Is_Allchan")).SelectedItem.Value);//通路類別

                    #endregion 畫面取值

                    #region 傳遞 Master Table 變數
                    ArrayList ParameterList = new ArrayList();//20091117

                    ParameterList.Clear();
                    ParameterList.Add(Session["UID"].ToString());
                    ParameterList.Add(DateTime.Now);
                    ParameterList.Add(v_MSG_TYPE);
                    ParameterList.Add(v_BUSDATE);
                    ParameterList.Add(v_MSG);
                    ParameterList.Add(v_IS_ALLCHAN);

                    #endregion

                    #region 將 Detail Table 資料寫入 Temp Table

                    CRMModel.MaintainChainMessage BCO = new CRMModel.MaintainChainMessage(ConnectionDB);
                    DataTable dt_DETL = BCO.QuerySwitch(CRMModel.MaintainChainMessage.QueryType.CRM122_DETL_Schema, ParameterList);
                    DateTime d_Date_Now = DateTime.Now;
                    int i_Id = 0;

                    foreach (GridViewRow dRow in gv_Insert.Rows)
                    {
                        if (((CheckBox)dRow.FindControl("Insert_chb_Code")).Checked == true)
                        {
                            DataRow dt_DETL_Row = dt_DETL.NewRow();

                            dt_DETL_Row["ID"] = i_Id;
                            dt_DETL_Row["PID"] = i_Id;
                            dt_DETL_Row["CREATEDATE"] = d_Date_Now;
                            dt_DETL_Row["CREATEUID"] = Session["UID"].ToString();
                            dt_DETL_Row["UPDATEDATE"] = d_Date_Now;
                            dt_DETL_Row["UPDATEUID"] = Session["UID"].ToString();
                            dt_DETL_Row["CHAN_NO"] = ((CheckBox)dRow.FindControl("Insert_chb_Code")).Text;

                            dt_DETL.Rows.Add(dt_DETL_Row);
                            i_Id += 1;
                        }
                    }

                    #endregion

                    #region 新增資料至資料庫

                    i_Return_Id = BCO.CreateMasterAndDetail(ParameterList, null, dt_DETL);

                    #endregion

                    if (i_Return_Id > 0)
                    {
                        System.Web.UI.ScriptManager.RegisterStartupScript(this.Insert_SaveButton, this.GetType(), "CRM122", "alert('新增完成');location.replace('CRM122.aspx?Code=CRM12&ID=" + i_Return_Id.ToString() + "&mode=readonly');", true);
                    }
                }
                catch (Exception ex)
                {
                    WaringLogProcess(ex.Message);
                    this.ErrorMsgLabel.Text = ex.Message;
                }
                finally { }
            }

            #endregion

        }
    }
Exemplo n.º 4
0
    protected void Item_DeleteButton_Click(object sender, EventArgs e)
    {
        if (FormView1.CurrentMode == FormViewMode.ReadOnly)
        {
            int res = 0;
            try
            {
                #region 取得畫面元件的值


                DateTime d_Date_Now = DateTime.Now;

                #endregion

                #region 取得刪除前舊值


                #region 使用XML轉回DataSet

                DataSet ds_Master = new DataSet();
                System.IO.StringReader sr_Master = new System.IO.StringReader(xml_MasterOLDData.InnerHtml);
                ds_Master.ReadXml(sr_Master);

                DataSet ds_Detail = new DataSet();
                System.IO.StringReader sr_Detail = new System.IO.StringReader(xml_DetailOLDData.InnerHtml);
                ds_Detail.ReadXml(sr_Detail);

                #endregion

                if (ds_Master.Tables[0].Rows.Count == 0)
                {
                    throw new Exception("抓取不到舊值,更新失敗!");
                }

                #endregion

                #region 加入更新條件
                ArrayList ParameterList = new ArrayList();//20091117

                ParameterList.Clear();

                //舊值

                ParameterList.Add(ds_Master.Tables[0].Rows[0]["ID"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["CODE"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["NAME"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["CREATEDATE"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["CREATEUID"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["UPDATEDATE"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["UPDATEUID"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["ENABLE"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["MSG_TYPE"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["BUSDATE"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["MSG"]);
                ParameterList.Add(ds_Master.Tables[0].Rows[0]["IS_ALLCHAN"]);

                //需要更新值

                ParameterList.Add(d_Date_Now);
                ParameterList.Add(Session["UID"].ToString());
                #endregion

                CRMModel.MaintainChainMessage BCO = new CRMModel.MaintainChainMessage(ConnectionDB);

                BCO.DeleteMasterAndDetail(ParameterList, null, ds_Detail);

                System.Web.UI.ScriptManager.RegisterStartupScript(((Button)FormView1.FindControl("Item_DeleteButton")), this.GetType(), "CRM122", "alert('刪除完成');location.replace('CRM121.aspx?Code=CRM12');", true);

            }
            catch (Exception ex)
            {
                WaringLogProcess(ex.Message);
                this.ErrorMsgLabel.Text = ex.Message;
            }
            finally { }
        }
    }
Exemplo n.º 5
0
    private void databind()
    {
        #region 傳入參數

        CRMModel.CRMCommon CRMComm = new CRMModel.CRMCommon();
        ArrayList ParameterList = new ArrayList();//20091117

        ParameterList.Clear();
        ParameterList.Add(CRMComm.GetValueSetParameter(this.slp_Msg.Text, "string", false));
        ParameterList.Add(CRMComm.GetValueSetParameter(this.TextBoxDate.Text, "date", false));
        ParameterList.Add(CRMComm.GetValueSetParameter(this.SLP_StoreChain_B.Text, "string", false));
        ParameterList.Add(CRMComm.GetValueSetParameter(this.SLP_StoreChain_E.Text, "string", false));
        ParameterList.Add(CRMComm.GetValueSetParameter(TextBoxRowCountLimit.Text.Length == 0 ? "100" : TextBoxRowCountLimit.Text, "int", false));
        ParameterList.Add(CRMComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));

        #endregion

        #region 連結資料庫

        CRMModel.MaintainChainMessage BCO = new CRMModel.MaintainChainMessage(ConntionDB);
        DataTable dt = BCO.QuerySwitch(CRMModel.MaintainChainMessage.QueryType.CRM121_Query_All, ParameterList);

        #endregion

        #region 繫結GridView

        //抓取本頁初次登記的時間
        string SessionIDName = "CRM121_" + PageTimeStamp.Value;

        Session["SessionID"] = SessionIDName;
        Session[SessionIDName] = dt;
        GridView1.DataSource = dt;

        //設定分頁大小
        GridView1.PageSize = (this.TextBoxPagesize.Text == string.Empty) ? 10 : (int.Parse(this.TextBoxPagesize.Text) < 0) ? 10 : int.Parse(this.TextBoxPagesize.Text);
        GridView1.PageIndex = 0;
        GridView1.DataBind();

        this.LabelQueryRecordCount.Text = string.Format(" {0} Rows ", dt.Rows.Count.ToString());

        #endregion

        #region 檢查回傳資料

        if (dt.Rows.Count == 0)
        { this.ErrorMsgLabel.Text = "查無資料"; }

        #endregion
    }