Example #1
0
    /// <summary>
    /// 於檢視模式,按下刪除鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DeleteButton_Click(object sender, EventArgs e)
    {
        int DeleteRecord = 0;
        try
        {
            #region 取得畫面元件的值

            DateTime processtime = DateTime.Now;
 
            #endregion

            #region 取得刪除前舊值


            #region 使用XML轉回DataSet

            DataSet Ds = new DataSet();
            DataTable Dt = dt_Result;

            #endregion

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

            #endregion

            #region 加入更新條件

            ParameterList.Clear();
            //舊值

            ParameterList.Add(Dt.Rows[0]["ID"]);
            ParameterList.Add(Dt.Rows[0]["CODE"]);
            ParameterList.Add(Dt.Rows[0]["NAME"]);
            ParameterList.Add(Dt.Rows[0]["CREATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[0]["ENABLE"]);
            ParameterList.Add(Dt.Rows[0]["ADDRESS1"]);
            ParameterList.Add(Dt.Rows[0]["ADDRESS2"]);
            ParameterList.Add(Dt.Rows[0]["PHONE"]);
            ParameterList.Add(Dt.Rows[0]["FAX"]);
            ParameterList.Add(Dt.Rows[0]["EMAIL"]);

            //需要更新值
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            #endregion

            SYSModel.MaintainCompanyInfo BCO = new SYSModel.MaintainCompanyInfo(ConnectionDB);

            DeleteRecord = BCO.DeleteCompanyInfoReturn(ParameterList, null);

            if (DeleteRecord == 0)
            {
                throw new Exception("刪除失敗!");
            }
            else
            {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "ClientScript", "alert('刪除完成');location.replace('SYS011.aspx?Code=SYS01');", true);               
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Example #2
0
    }//end EditCancelButton_Click

    /// <summary>
    ///  編輯模式,按下更新確認鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void EditCommitButton_Click(object sender, EventArgs e)
    {       
        try
        {
            ErrorMsgLabel.Text = "";
            int UpdateRecord = 0;

            #region 取得畫面元件的值

            string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim();
            DateTime processtime = DateTime.Now;
            string v_Address1 = ((TextBox)FormView1.FindControl("TextBoxAddress1")).Text.Trim();
            string v_Address2 = ((TextBox)FormView1.FindControl("TextBoxAddress2")).Text.Trim();
            string v_Phone = ((TextBox)FormView1.FindControl("TextBoxPhone")).Text.Trim();
            string v_Fax = ((TextBox)FormView1.FindControl("TextBoxFax")).Text.Trim();
            string v_EMail = ((WUI.SLP.EMailAddress)FormView1.FindControl("TextBoxEMail")).Text.Trim();            

            #endregion

            #region 取得更新前舊值

            #region 使用XML轉回DataSet

            DataSet Ds = new DataSet();
            DataTable Dt = dt_Result;

            #endregion

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

            #endregion

            #region 加入更新條件

            ParameterList.Clear();

            //舊值
            ParameterList.Add(Dt.Rows[0]["ID"]);
            ParameterList.Add(Dt.Rows[0]["CODE"]);
            ParameterList.Add(Dt.Rows[0]["NAME"]);
            ParameterList.Add(Dt.Rows[0]["CREATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[0]["ENABLE"]);            
            ParameterList.Add(Dt.Rows[0]["ADDRESS1"]);
            ParameterList.Add(Dt.Rows[0]["ADDRESS2"]);
            ParameterList.Add(Dt.Rows[0]["PHONE"]);
            ParameterList.Add(Dt.Rows[0]["FAX"]);
            ParameterList.Add(Dt.Rows[0]["EMAIL"]);
 
            //需要更新值
            ParameterList.Add(v_Name);
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(v_Address1);
            ParameterList.Add(v_Address2);
            ParameterList.Add(v_Phone);
            ParameterList.Add(v_Fax);
            ParameterList.Add(v_EMail);       
            #endregion

            SYSModel.MaintainCompanyInfo BCO = new SYSModel.MaintainCompanyInfo(ConnectionDB);

            UpdateRecord = BCO.UpdateCompanyInfoReturn(ParameterList, null);

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

                ClientScript.RegisterClientScriptBlock(this.GetType(), "SYS012", "<script>alert('更改完成');</script>");
                ChangeFormMode(FormViewMode.ReadOnly);               
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Example #3
0
    private void Loaddata(string NewCode)
    {
        SYSModel.MaintainCompanyInfo BCO = new SYSModel.MaintainCompanyInfo(ConnectionDB);
        ParameterList.Clear();
        ParameterList.Add(NewCode);
        DataTable Dt = BCO.QueryCompanyInfoByID(ParameterList);

        if (Dt != null)
        {
            if (Dt.Rows.Count == 0)
            {
                ArrayList AL = (ArrayList)Session["SYS01_SortKey" + Request.QueryString["SYS012_PageTimeStamp"]];

                string strRemove = "id=" + NewCode;
                AL.Remove(strRemove);
                Session["SYS01_SortKey" + Request.QueryString["SYS012_PageTimeStamp"]] = AL;

                throw new Exception("此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!");
            }
        }
    }
Example #4
0
    }//end InsertCancelButton_Click


    /// <summary>
    /// 由新增模式,確認新增
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void InsertButton_Click(object sender, EventArgs e)
    {        
        try
        {
            int AddRecord = 0;
            ErrorMsgLabel.Text = "";

            #region 取得畫面元件的值

            string v_Code = ((WUI.SLP.SLPUnique)FormView1.FindControl("TextBoxCode")).Text.Trim();
            string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim();
            DateTime processtime = DateTime.Now;
            string v_Address1 = ((TextBox)FormView1.FindControl("TextBoxAddress1")).Text.Trim();
            string v_Address2 = ((TextBox)FormView1.FindControl("TextBoxAddress2")).Text.Trim();
            string v_Phone = ((TextBox)FormView1.FindControl("TextBoxPhone")).Text.Trim();
            string v_Fax = ((TextBox)FormView1.FindControl("TextBoxFax")).Text.Trim();
            string v_EMail = ((WUI.SLP.EMailAddress)FormView1.FindControl("TextBoxEMail")).Text.Trim();

            ParameterList.Clear();
            SYSModel.MaintainProgram Uniq = new SYSModel.MaintainProgram(ConnectionDB);
            ParameterList.Add(v_Code);
            ParameterList.Add("SYS_COMPANYINFO");
            ParameterList.Add("CODE");
            ParameterList.Add("");
            DataTable Dup = Uniq.QuerySwitch(SYSModel.MaintainProgram.QueryType.Duplicate,
                                         ParameterList
                                         );
            if (Dup.Rows.Count > 0)
            {
                if (Dup.Rows[0]["ENABLE"].ToString() == "1")
                {
                    throw new Exception("資料重覆!");
                }
            }
            #endregion

            #region 加入輸入條件

            ParameterList.Clear();

            ParameterList.Add(v_Code);
            ParameterList.Add(v_Name);
            ParameterList.Add(processtime);               //vCreateDate
            ParameterList.Add(Session["UID"].ToString()); //vCreateUID
            ParameterList.Add(processtime);               //vUpdateDate
            ParameterList.Add(Session["UID"].ToString()); //vUpdateUID
            ParameterList.Add(v_Address1);
            ParameterList.Add(v_Address2);
            ParameterList.Add(v_Phone);
            ParameterList.Add(v_Fax);
            ParameterList.Add(v_EMail);          
            #endregion

            SYSModel.MaintainCompanyInfo BCO = new SYSModel.MaintainCompanyInfo(ConnectionDB);
            AddRecord = BCO.CreateCompanyInfo(ParameterList, null);

            if (AddRecord == 0)
            {
                throw new Exception("新增0筆資料!");
            }
            else
            {
                Response.Write("<script>alert('新增完成');location.replace('SYS012.aspx?mode=readonly&ID=" + AddRecord + "');</script>");               
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }
Example #5
0
    /// <summary>
    /// 繫結資料
    /// </summary>
    /// <param name=VirtualDataID></param>
    private void databind(FormViewMode fvm)
    {
        try
        {
            SYSModel.MaintainCompanyInfo BCO = new SYSModel.MaintainCompanyInfo(ConnectionDB);

            ParameterList.Clear();
            if (Request["ID"] != null)
                ParameterList.Add(Request["ID"].ToString());
            else
                ParameterList.Add("0");

            dt_Result = BCO.QuerySwitch(SYSModel.MaintainCompanyInfo.QueryType.ID,
                                           ParameterList
                                           );

            if (dt_Result.Rows.Count > 0)
            {
                this.hiddenID.Value = dt_Result.Rows[0]["ID"].ToString();
                FormView1.DataSource = dt_Result;
                FormView1.DataBind();

                if (dt_Result.Rows[0]["ENABLE"].ToString() == "0")
                {
                    ((Button)FormView1.FindControl("EditButton")).Visible = false;
                    ((Button)FormView1.FindControl("DeleteButton")).Visible = false;
                }
            }

            AuthorityControls(this);

            //ToolBarStatus
            switch (fvm)
            {
                case FormViewMode.Edit:
                    ToolBarStatus("edit");
                    TextBox txtname = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    txtname.Visible = false;
                    break;
                case FormViewMode.Insert:
                    ToolBarStatus("insert");
                    break;
                case FormViewMode.ReadOnly:
                    ToolBarStatus("readonly");
                    TextBox txtname1 = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    txtname1.Visible = false;
                    break;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }//databind