Пример #1
0
    public ALO_SLP_SLP_Rank()
    {

        BCO = new ALOModel.MaintainDisRank(ConnectionDB);

        #region 例舉值各別定義內容

        ////取例舉值清單
        //valueArr = Enum.GetValues(typeof(BCO.MaintainProgram.ProgramType));

        ////取顯示的值名稱,預設值
        //nameArr = Enum.GetNames(typeof(BCO.MaintainProgram.ProgramType));

        ////指定顯示名稱供使用者檢視
        //for (int i = 0; i < valueArr.GetLength(0); i++)
        //{
        //    nameArr[i] = BCO.MaintainProgram.get_ProgramType_Description((BCO.MaintainProgram.ProgramType)valueArr.GetValue(i));
        //}
        #endregion 例舉值各別定義內容   

    }//ALO_SLP_SLP_Rank
Пример #2
0
    //Insert GridView1
    protected void Insert_Mst()
    {
        #region
        int AddRecord = 0;
        try
        {
            #region 取得畫面元件的值


            string v_CODE = txtTab2Code.Text.Trim();
            string v_NAME = txtTab2Name.Text.Trim();
            DateTime v_UPDATEDATE = System.DateTime.Now;
            string v_UPDATEUID = Session["UID"].ToString();
            string v_MEMO = txtTab2Memo.Text.Trim();
            string v_PARAM_CODE = TextBoxParam.Text.Trim();


            #endregion

            #region 加入輸入條件

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

            ParameterList.Add(v_CODE);
            ParameterList.Add(v_NAME);
            ParameterList.Add(v_UPDATEDATE);
            ParameterList.Add(v_UPDATEUID);
            ParameterList.Add(v_MEMO);
            ParameterList.Add(v_PARAM_CODE);


            #endregion

            ALOModel.MaintainDisRank BCO = new ALOModel.MaintainDisRank(ConntionDB);
            AddRecord = BCO.CreateDisRank(ParameterList, null);

            if (AddRecord == 0)
            {
                throw new Exception("新增0筆資料!");
            }

            iMasterID = AddRecord;//20090114 added --> ID
        }
        catch (Exception ex)
        {
            throw ex;
        }
        #endregion
    }
Пример #3
0
    //Update GridView1
    protected void Update_Mst(string Enable)
    {
        #region
        int UpdateRecord = 0;


        try
        {
            #region 取得畫面元件的值


            string v_CODE = txtTab2Code.Text.Trim();
            string v_NAME = txtTab2Name.Text.Trim();
            string v_MEMO = txtTab2Memo.Text.Trim();
            string v_PARAM_CODE = TextBoxParam.Text.Trim();


            #endregion

            #region 檢查輸入值


            if (GridView2.Rows.Count != 0)
            {
                int tmpRateCount = 0;
                for (int i = 0; i <= GridView2.Rows.Count - 1; i++)
                {
                    tmpRateCount += Convert.ToInt32(((Label)GridView2.Rows[i].Cells[1].FindControl("Label2")).Text);
                }


                if (tmpRateCount != 100)
                {
                    ErrorMsgLabel.Text = "[佔有率%] 的總合須為100";
                    return;
                }
            }


            #endregion

            #region 加入更新條件

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

            //舊值
            ParameterList.Add(v_CODE);
            ParameterList.Add(v_PARAM_CODE);

            //需要更新值
            ParameterList.Add(v_CODE);
            ParameterList.Add(v_NAME);
            ParameterList.Add(v_MEMO);
            ParameterList.Add(System.DateTime.Now.ToString());
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(Enable);//ENABLE


            #endregion

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

            UpdateRecord = BCO.UpdateDisRank(ParameterList, null);

            if (UpdateRecord == 0)
            {
                throw new Exception("更新0筆資料!");
            }

            dataget_Mst();

            btnTab3Cancel_Click(this, EventArgs.Empty);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        #endregion
    }
Пример #4
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
    }
Пример #5
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
    }
Пример #6
0
    //dataget 查詢資料庫取得資料
    private void dataget_Mst()
    {
        #region
        try
        {
            //抓取本頁初次登記的時間
            string SessionIDName = "ALO02A_" + PageTimeStamp.Value;

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

            DataTable Dt = null;

            //ParameterList.Clear();
            //ParameterList.Add("1");
            //ParameterList.Add(TextBoxParam.Text.Trim());

            Dt = BCO.QuerySwitch(ALOModel.MaintainDisRank.QueryType.ALL, null);

            Session[SessionIDName] = Dt;
            GridView1.DataSource = Dt;
            GridView1.DataBind();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Пример #7
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
    }
Пример #8
0
    //Tab2 新增存檔
    protected void btnTab2SaveInsert_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            ResultMsgLabel.Text = "";

            if (txtTab2Code.Text.Trim() == "" || txtTab2Name.Text.Trim() == "")
            {
                ErrorMsgLabel.Text = "[RANK類別代號] 及 [RANK類別名稱] 不得為空白";
                return;
            }
            else if (GetStringLen(txtTab2Name.Text.Trim()) > 20)
            {
                ErrorMsgLabel.Text = "RANK類別名稱限制20個字元";
                return;
            }
            else if (GetStringLen(txtTab2Memo.Text.Trim()) > 40)
            {
                ErrorMsgLabel.Text = "備註限制40個字元";
                return;
            }


            //2010/02/22 modified
            string SessionIDName = "ALO02A2_" + PageTimeStamp.Value;
            DataTable dtTemp = (DataTable)Session[SessionIDName];

            int tmpRateCount = 0;
            if (dtTemp != null && dtTemp.Rows.Count != 0)
            {
                for (int i = 0; i <= dtTemp.Rows.Count - 1; i++)
                {
                    tmpRateCount += Convert.ToInt32(((dtTemp.Rows[i]["RANK_RATE"].ToString().Trim())));
                }


                if (tmpRateCount != 100)
                {
                    ErrorMsgLabel.Text = "[佔有率%] 的總合須為100";
                    return;
                }
            }


            //---檢查DB中是否已有重複資料
            string v_CODE = txtTab2Code.Text.Trim();
            string exist = "";
            ALOModel.MaintainDisRank BCO = new ALOModel.MaintainDisRank(ConntionDB);
            DataTable Dt2 = new DataTable();
            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            //ParameterList.Add("1");
            //ParameterList.Add(TextBoxParam.Text.Trim());

            Dt2 = BCO.QuerySwitch(ALOModel.MaintainDisRank.QueryType.ALL, null);

            if (Dt2 != null)
            {
                for (int i = 0; i <= Dt2.Rows.Count - 1; i++)
                {
                    if (Dt2.Rows[i]["CODE"].ToString() == v_CODE)
                    {
                        if (Dt2.Rows[i]["ENABLE"].ToString() == "1")
                        {
                            ErrorMsgLabel.Text = "此RANK類別代號已存在";
                            return;
                        }
                        else if (Dt2.Rows[i]["ENABLE"].ToString() == "0")
                        {
                            exist = "Y"; //表示資料存於DB中但ENABLE = 0
                        }
                    }
                }
            }

            if (exist == "Y")
            {
                if (DetailOLDData.InnerHtml != "")
                {
                    Update_Mst("1"); 
                    Update_Dtl();

                }
            }
            else
            {               
                Insert_Mst();
                Update_Dtl();
            }

            dataget_Mst();

            hidtxtTab2Memo.Text = txtTab2Memo.Text.Trim();

            txtTab2Code.ReadOnly = true;
            txtTab2Name.ReadOnly = true;
            txtTab2Memo.ReadOnly = true;
            btnTab2SaveInsert.Visible = false;
            btnTab2Del.Visible = true;
            btnTab2Edit.Visible = true;
            btnTab3NewInsert.Visible = false;
            btnTab3New.Visible = true;
            txtTab3Lv.Text = "";
            txtTab3Rate.Text = "";
            Panel2.Visible = false;
            GridView2.Columns[2].Visible = false;
            GridView2.Columns[3].Visible = false;

            ResultMsgLabel.Text = "新增完成";

            CurrentPageMode = PageCurrentMode.Query;

            DetailOLDData.InnerHtml = "";
            DetailOLDData_Source.InnerHtml = "";


        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Пример #9
0
    //Tab2 刪除
    protected void btnTab2Del_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            Update_Mst("0");


    

            // 刪除DETL的資料-------------------------------------------------------------------------------------------------
            #region 取得畫面元件的值


            string v_RANK_CODE = txtTab2Code.Text.Trim();


            #endregion

            #region 加入刪除條件

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

            ParameterList.Add(v_RANK_CODE);
            ParameterList.Add(Session["UID"].ToString());


            #endregion

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

            BCO.DeleteALLDisRecord(ParameterList, null);

            //btnTab2Cancel_Click(null, null);

            hidtxtTab2Memo.Text = "";
            ResultMsgLabel.Text = "刪除完成";

            CurrentPageMode = PageCurrentMode.Query;


            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "OpenCollapsiblePanel();", true);

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

    }