/// <summary>
 /// 刪除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     string alert = "";
     string flag = this.hidOperate.Value.ToString().Trim();
     ParameterModel model = new ParameterModel();
     if (flag == "Delete")
     {
         bool deFlag = false;
         model.ParaName = txtParaName.Text.ToString().Trim();
         logmodel.ProcessFlag = "delete";
         deFlag = parameterBll.DeleteByKey(model, logmodel);
         if (deFlag == true)
         {
             alert = "alert('" + Message.DeleteSuccess + "')";
         }
         else
         {
             alert = "alert('" + Message.DeleteFailed + "')";
         }
         this.hidOperate.Value = "";
     }
     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "show", alert, true);
     PageHelper.CleanControlsValue(pnlContent.Controls);
     ParameterBind();
 }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            pager.CurrentPageIndex = 1;
            string actionFlag = this.hidOperate.Value.ToString().Trim();
            ParameterModel model = new ParameterModel();
            if (actionFlag == "Condition")
            {
                model = PageHelper.GetModel<ParameterModel>(pnlContent.Controls);
                ParameterBind();
                this.hidOperate.Value = null;

            }
            else
            {

                ParameterBind();
            }
        }
 /// <summary>
 /// 數據綁定
 /// </summary>
 private void ParameterBind()
 {
     int totalCount;
     ParameterModel model = new ParameterModel();
     string actionFlag = this.hidOperate.Value.ToString().Trim();
     if (actionFlag == "Condition")
     {
          model = PageHelper.GetModel<ParameterModel>(pnlContent.Controls);
     }
     DataTable dt = parameterBll.GetParameter(model, pager.CurrentPageIndex, pager.PageSize, out totalCount);
     pager.RecordCount = totalCount;
     UltraWebGridParameter.DataSource = dt.DefaultView;
     UltraWebGridParameter.DataBind();
     pager.TextAfterPageIndexBox = "/" + pager.PageCount.ToString();
 }
 /// <summary>
 /// 存儲
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     ParameterModel model = PageHelper.GetModel<ParameterModel>(pnlContent.Controls);
     string alert = "";
     if (hidOperate.Value == "Add")
     {
         model.ParaName = txtParaName.Text;
         model.CreateUser = CurrentUserInfo.Personcode;
         model.CreateDate = DateTime.Now;
         if (!string.IsNullOrEmpty(model.ParaName))
         {
             ParameterModel addModel = parameterBll.GetParameterByKey(model.ParaName);//檢驗新增數據的主鍵是否已存在
             if (addModel == null)
             {
                 logmodel.ProcessFlag = "insert";
                 if (parameterBll.AddNew(model, logmodel))
                 {
                     alert = "alert('" + Message.AddSuccess + "')";
                 }
                 else
                 {
                     alert = "alert('" + Message.AddFailed + "')";
                 }
             }
             else
             {
                 alert = "alert('" + Message.DataExist + "')";
             }
         }
         else
         {
             alert = "alert('" + Message.TextBoxNotNull + "')";
         }
         hidOperate.Value = null;
     }
     else if (hidOperate.Value == "Modify")
     {
         model.UpdateUser = CurrentUserInfo.Personcode;
         model.UpdateDate = DateTime.Now;
         logmodel.ProcessFlag = "update";
         bool updateFlag = parameterBll.UpdateByKey(model, false, logmodel);
         if (updateFlag == true)
         {
             alert = "alert('" + Message.UpdateSuccess + "')";
         }
         else
         {
             alert = "alert('" + Message.UpdateFailed + "')";
         }
         hidOperate.Value = null;
     }
     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "show", alert, true);
     PageHelper.CleanControlsValue(pnlContent.Controls);
     model = new ParameterModel();
     ParameterBind();
 }