Example #1
0
    private void dataget_Dtl()
    {
        #region
        try
        {
            //抓取本頁初次登記的時間
            string SessionIDName = "ALO02A2_" + PageTimeStamp.Value;

            ALOModel.MaintainDisRank BCO = new ALOModel.MaintainDisRank(ConntionDB);

            DataTable Dt = null;

            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(s_RANKCODE);

            Dt = BCO.QueryLineSwitch(ALOModel.MaintainDisRank.QueryType.CODE, ParameterList);

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

            DetailOLDData.InnerHtml = Dt.DataSet.GetXml();
            DetailOLDData_Source.InnerHtml = Dt.DataSet.GetXml();

            #endregion

            Session[SessionIDName] = Dt;
            GridView2.DataSource = Dt;
            GridView2.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        #endregion
    }
Example #2
0
    //Update GridView2
    protected void Update_Dtl()
    {
        #region


        try
        {
            // 刪除DB中之資料-------------------------------------------------------------------------------------------------
            #region 取得畫面元件的值


            //string v_RANK_CODE = txtTab2Code.Text.Trim();


            //#endregion

            //#region 加入刪除條件


            //ParameterList.Clear();

            //ParameterList.Add(v_RANK_CODE);


            #endregion

            ALOModel.MaintainDisRank BCO = new ALOModel.MaintainDisRank(ConntionDB);

            //BCO.DeleteDisRecord(ParameterList, null);

            // 加入temp中之資料至DB-------------------------------------------------------------------------------------------
            #region 取得temp中之資料

            //修改過的表
            DataSet Ds = new DataSet();
            DataTable Dt = new DataTable();
            ArrayList ParameterList = new ArrayList();

            if (DetailOLDData.InnerHtml != "")
            {
                System.IO.StringReader sr = new System.IO.StringReader(DetailOLDData.InnerHtml);
                Ds.ReadXml(sr);
            }
      
            if (Ds.Tables.Count == 0)
            {
                //從DB讀取一空table回來
                string SessionIDName = "ALO02A4_" + PageTimeStamp.Value;

                ParameterList.Clear();
                Dt = BCO.QueryLineSwitch(ALOModel.MaintainDisRank.QueryType.Empty, ParameterList);
            }
            else
            {
                Dt = Ds.Tables[0];
            }

            //原始資料表
            DataSet Ds2 = new DataSet();
            DataTable Dt2 = new DataTable();

            if (DetailOLDData_Source.InnerHtml != "")
            {
                System.IO.StringReader sr = new System.IO.StringReader(DetailOLDData_Source.InnerHtml);
                Ds2.ReadXml(sr);
            }

            if (Ds2.Tables.Count == 0)
            {
                //從DB讀取一空table回來
                string SessionIDName = "ALO02A5_" + PageTimeStamp.Value;

                ParameterList.Clear();
                Dt2 = BCO.QueryLineSwitch(ALOModel.MaintainDisRank.QueryType.Empty, ParameterList);
            }
            else
            {
                Dt2 = Ds2.Tables[0];
            }


            #endregion

            //Update
            for (int i = 0; i <= Dt2.Rows.Count - 1; i++)
            {
                string exist = "";

                for (int j = 0; j <= Dt.Rows.Count - 1; j++)
                {
                    if (Dt2.Rows[i]["ID"].ToString() == Dt.Rows[j]["ID"].ToString())
                    {
                        ParameterList.Clear();

                        //舊值
                        ParameterList.Add(Dt.Rows[j]["ID"].ToString());
                        ParameterList.Add(Dt.Rows[j]["PID"].ToString());

                        //需要更新值
                        ParameterList.Add(System.DateTime.Now.ToString());
                        ParameterList.Add(Session["UID"].ToString());
                        ParameterList.Add(Dt.Rows[j]["RANK_CODE"].ToString());
                        ParameterList.Add(Dt.Rows[j]["RANK_LEVEL"].ToString());
                        ParameterList.Add(Dt.Rows[j]["RANK_RATE"].ToString());

                        BCO.UpdateDisRecord(ParameterList, null);

                        exist = "Y";
                    }
                    
                }
                //Delete
                if (exist == "")
                {
                    ParameterList.Clear();

                    ParameterList.Add(Dt2.Rows[i]["ID"].ToString());
                    ParameterList.Add(Dt2.Rows[i]["PID"].ToString());
                    ParameterList.Add(Session["UID"].ToString());

                    BCO.DeleteDisRecord(ParameterList, null);
                }
            }

            //Insert
            for (int i = 0; i <= Dt.Rows.Count - 1; i++)
            {
                string exist = "";

                for (int j = 0; j <= Dt2.Rows.Count - 1; j++)
                {
                    if (Dt.Rows[i]["ID"].ToString() == Dt2.Rows[j]["ID"].ToString())
                    {
                        exist = "Y";
                    }
                }
                if (exist == "")
                {
                    ParameterList.Clear();

                    ParameterList.Add(iMasterID);//Dt.Rows[i]["PID"]
                    ParameterList.Add(Dt.Rows[i]["CREATEDATE"]);
                    ParameterList.Add(Dt.Rows[i]["CREATEUID"]);
                    ParameterList.Add(Dt.Rows[i]["UPDATEDATE"]);
                    ParameterList.Add(Dt.Rows[i]["UPDATEUID"]);
                    ParameterList.Add(Dt.Rows[i]["ENABLE"]);
                    ParameterList.Add(Dt.Rows[i]["RANK_CODE"]);
                    ParameterList.Add(Dt.Rows[i]["RANK_LEVEL"]);
                    ParameterList.Add(Dt.Rows[i]["RANK_RATE"]);

                    BCO.CreateDisRecord(ParameterList, null);
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        #endregion
    }
Example #3
0
    //Tab3 插入明細
    protected void btnTab3Insert_Click(object sender, EventArgs e)
    {
        #region
        #region 檢查輸入值


        if (txtTab3Lv.Text.Trim() == "" || txtTab3Rate.Text.Trim() == "")
        {
            ErrorMsgLabel.Text = "[等級區分]及[佔有率]不得為空白";
            return;
        }


        #endregion

        DataTable Dt = null;
        DataSet Ds = new DataSet();
        ArrayList ParameterList = new ArrayList();

        if (DetailOLDData.InnerHtml != "")
        {
            System.IO.StringReader sr = new System.IO.StringReader(DetailOLDData.InnerHtml);
            Ds.ReadXml(sr);
        }

        try
        {
            if (Ds.Tables.Count == 0)
            {
                //從DB讀取一空table回來
                ALOModel.MaintainDisRank BCO = new ALOModel.MaintainDisRank(ConntionDB);
                ParameterList.Clear();
                Dt = BCO.QueryLineSwitch(ALOModel.MaintainDisRank.QueryType.Empty, ParameterList);
            }
            else
            {
                Dt = Ds.Tables[0];
            }

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

            //ID和PID贊自訂, 真正寫入CO時會重取
            Int64 v_ID = DateTime.Now.ToFileTime();//20100125 modified
            int v_PID = iMasterID;//20090114 modified
            string v_RANK_CODE = txtTab2Code.Text.Trim();
            string v_txtTab3Lv = txtTab3Lv.Text.Trim();
            string v_txtTab3Rate = txtTab3Rate.Text.Trim();

            if (CheckRankLevelIsExisted(Dt, v_ID, v_txtTab3Lv, CurrentGridviewMode.Insert))
            {
                #region
                DataRow dRow = Dt.NewRow();

                dRow["ID"] = v_ID;
                dRow["PID"] = v_PID;
                dRow["RANK_CODE"] = v_RANK_CODE;
                dRow["RANK_LEVEL"] = v_txtTab3Lv;
                dRow["RANK_RATE"] = Convert.ToInt32(v_txtTab3Rate);
                dRow["CREATEDATE"] = DateTime.Now;
                dRow["UPDATEDATE"] = DateTime.Now;
                dRow["CREATEUID"] = Session["UID"];
                dRow["UPDATEUID"] = Session["UID"];
                dRow["ENABLE"] = "1";

                Dt.Rows.Add(dRow);


                txtTab3Lv.Text = "";
                txtTab3Rate.Text = "";
                Panel2.Visible = false;

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

                DetailOLDData.InnerHtml = Dt.DataSet.GetXml();

                #endregion

                //2010/02/22 modified
                string SessionIDName = "ALO02A2_" + PageTimeStamp.Value;
                Session[SessionIDName] = Dt;

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