★33°空間‰


                                 ----★七彩服飾  【最潮拜☆日單精品】【Esprit】【Hotwind】滿150包郵-女裝-流行女裝    www.7color.hb.cn

                                 ----智力比知識重要,素質比智力重要,覺悟比素質更重要
          posts - 110,comments - 35,trackbacks - 0
          using ?TestWeb.HR.BusinessLogicLayer;
          using ?TestWeb.HR.DataAccessLayer;
          public ? partial ? class ?HR_CompanyView?:?System.Web.UI.UserControl
          {
          ????
          protected ? void ?Page_Load( object ?sender,?EventArgs?e)
          ????
          {
          ????????
          if ?( ! this .IsPostBack)
          ????????
          {
          ????????????GetAllCompanies();?
          // 初試加載所有公司
          ????????}

          }

          ????
          /// ? <summary>
          ????
          /// ?返回所有公司
          ????
          /// ? </summary>

          ???? private ? void ?GetAllCompanies()
          ????
          {
          ????????
          try
          ????????
          {
          ????????????List
          < Company > ?companyList? = ? new ?List < Company > ();
          ????????????companyList?
          = ?Company.GetAllCompanies();
          ????????????
          if ?(companyList? != ? null )
          ????????????
          {
          ????????????????
          this .GridView1.DataSource? = ?companyList;
          ????????????????
          this .GridView1.DataBind();
          ????????????}

          ????????}

          ????????
          catch ?(Exception?ex)
          ????????
          {
          ????????????ShowMessage.ErrorMessage(
          this .Page,?ex.Message);
          ????????}

          ????}

          ????
          /// ? <summary>
          ????
          /// ?編輯公司
          ????
          /// ? </summary>
          ????
          /// ? <param?name="sender"></param>
          ????
          /// ? <param?name="e"></param>

          ???? protected ? void ?GridView1_RowEditing( object ?sender,?GridViewEditEventArgs?e)
          ????
          {
          ????????
          this .GridView1.EditIndex? = ?e.NewEditIndex;
          ????????GetAllCompanies();
          ????}

          ????
          /// ? <summary>
          ????
          /// ?取消編輯
          ????
          /// ? </summary>
          ????
          /// ? <param?name="sender"></param>
          ????
          /// ? <param?name="e"></param>

          ???? protected ? void ?GridView1_RowCancelingEdit( object ?sender,?GridViewCancelEditEventArgs?e)
          ????
          {
          ????????
          this .GridView1.EditIndex? = ? - 1 ;
          ????????GetAllCompanies();
          ????}

          ????
          /// ? <summary>
          ????
          /// ?更新公司
          ????
          /// ? </summary>
          ????
          /// ? <param?name="sender"></param>
          ????
          /// ? <param?name="e"></param>

          ???? protected ? void ?GridView1_RowUpdating( object ?sender,?GridViewUpdateEventArgs?e)
          ????
          {
          ????????GridViewRow?uprow?
          = ? this .GridView1.Rows[e.RowIndex];
          ????????TextBox?text1?
          = ?(TextBox)uprow.Cells[ 0 ].FindControl( " TextBox1 " );
          ????????TextBox?text2?
          = ?(TextBox)uprow.Cells[ 0 ].FindControl( " TextBox2 " );
          ????????TextBox?text3?
          = ?(TextBox)uprow.Cells[ 0 ].FindControl( " TextBox3 " );
          ????????HyperLink?hlk?
          = ?(HyperLink)uprow.Cells[ 0 ].FindControl( " HyperLink1 " );
          ????????
          int ?companyId? = ?Convert.ToInt32( this .GridView1.DataKeys[e.RowIndex].Value);
          ????????
          // 直接調用存儲過程進行更新
          ???????? string ?connectionstring? = ?ConfigurationManager.ConnectionStrings[ " TESTDB_Database_Connection " ].ConnectionString;
          ????????SqlCommand?upcmd?
          = ? new ?SqlCommand();
          ????????upcmd.CommandType?
          = ?CommandType.StoredProcedure;
          ????????upcmd.CommandText?
          = ? " UPCompany " ;
          ????????upcmd.Parameters.Add(
          " @CompanyName " ,?SqlDbType.VarChar,? 50 );
          ????????upcmd.Parameters[
          " @CompanyName " ].Value? = ?text1.Text.Trim();
          ????????upcmd.Parameters.Add(
          " @Phone " ,?SqlDbType.VarChar,? 50 );
          ????????upcmd.Parameters[
          " @Phone " ].Value? = ?text2.Text.Trim();
          ????????upcmd.Parameters.Add(
          " @Fax " ,?SqlDbType.VarChar,? 50 );
          ????????upcmd.Parameters[
          " @Fax " ].Value? = ?text3.Text.Trim();
          ????????upcmd.Parameters.Add(
          " @WebSite " ,?SqlDbType.VarChar,? 50 );
          ????????upcmd.Parameters[
          " @WebSite " ].Value? = ?hlk.Text.Trim();
          ????????upcmd.Parameters.Add(
          " @CompanyId " ,?SqlDbType.Int,? 4 );
          ????????upcmd.Parameters[
          " @CompanyId " ].Value? = ?companyId;
          ????????SqlConnection?con?
          = ? new ?SqlConnection(connectionstring);
          ????????upcmd.Connection?
          = ?con;
          ????????con.Open();
          ????????upcmd.ExecuteNonQuery();
          ????????con.Close();

          ????????
          this .GridView1.EditIndex? = ? - 1 ;
          ????????GetAllCompanies();
          ????}

          ????
          /// ? <summary>
          ????
          /// ?刪除公司
          ????
          /// ? </summary>
          ????
          /// ? <param?name="sender"></param>
          ????
          /// ? <param?name="e"></param>

          ???? protected ? void ?GridView1_RowDeleting( object ?sender,?GridViewDeleteEventArgs?e)
          ????
          {
          ????????
          int ?companyId? = ?Convert.ToInt32( this .GridView1.DataKeys[e.RowIndex].Value);
          ????????
          string ?connectionstring? = ?ConfigurationManager.ConnectionStrings[ " TESTDB_Database_Connection " ].ConnectionString;
          ????????SqlCommand?delcmd?
          = ? new ?SqlCommand();
          ????????delcmd.CommandType?
          = ?CommandType.StoredProcedure;
          ????????delcmd.CommandText?
          = ? " HR_DeleteCompanyByCompanyId " ;
          ????????delcmd.Parameters.Add(
          " @CompanyId " ,?SqlDbType.Int,? 4 );
          ????????delcmd.Parameters[
          " @CompanyId " ].Value? = ?companyId;
          ????????SqlConnection?_Con?
          = ? new ?SqlConnection(connectionstring);
          ????????delcmd.Connection?
          = ?_Con;
          ????????_Con.Open();
          ????????delcmd.ExecuteNonQuery();
          ????????_Con.Close();
          ????????GetAllCompanies();
          ????}

          ????
          /// ? <summary>
          ????
          /// ?允許分頁
          ????
          /// ? </summary>
          ????
          /// ? <param?name="sender"></param>
          ????
          /// ? <param?name="e"></param>

          ???? protected ? void ?GridView1_PageIndexChanging( object ?sender,?GridViewPageEventArgs?e)
          ????
          {
          ????????
          this .GridView1.PageIndex? = ?e.NewPageIndex;
          ????????GetAllCompanies();
          ????}

          ????
          /// ? <summary>
          ????
          /// ?焦點行顏色變化
          ????
          /// ? </summary>
          ????
          /// ? <param?name="sender"></param>
          ????
          /// ? <param?name="e"></param>

          ???? protected ? void ?GridView1_RowDataBound( object ?sender,?GridViewRowEventArgs?e)
          ????
          {
          ????????
          if ?(e.Row.RowType? == ?DataControlRowType.DataRow)
          ????????
          {
          ????????????
          // 當鼠標放上去的時候?先保存當前行的背景顏色?并給附一顏色?
          ????????????e.Row.Attributes.Add( " onmouseover " ,? " currentcolor=this.style.backgroundColor;this.style.backgroundColor='yellow',this.style.fontWeight=''; " );
          ????????????
          // 當鼠標離開的時候?將背景顏色還原的以前的顏色?
          ????????????e.Row.Attributes.Add( " onmouseout " ,? " this.style.backgroundColor=currentcolor,this.style.fontWeight=''; " );
          ????????}

          ????????
          // 單擊行改變行背景顏色?
          ???????? if ?(e.Row.RowType? == ?DataControlRowType.DataRow)
          ????????
          {
          ????????????e.Row.Attributes.Add(
          " onclick " ,? " this.style.backgroundColor='#99cc00';?this.style.color='buttontext';this.style.cursor='default'; " );
          ????????}

          ????}

          ????
          /// ? <summary>
          ????
          /// ?根據ID獲取公司詳細信息
          ????
          /// ? </summary>
          ????
          /// ? <param?name="sender"></param>
          ????
          /// ? <param?name="e"></param>

          ???? protected ? void ?Button1_Click( object ?sender,?EventArgs?e)
          ????
          {
          ????????Response.Redirect(
          " ~/CompanyDetails.aspx " );
          ????}
          ?
          }
          posted on 2006-10-30 14:44 圣域飛俠 閱讀(535) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 潼南县| 满洲里市| 阳春市| 于都县| 冕宁县| 乐安县| 清远市| 大英县| 横峰县| 马尔康县| 定州市| 琼海市| 宜宾县| 全州县| 山阳县| 仲巴县| 宕昌县| 乌鲁木齐县| 南开区| 邯郸县| 万全县| 富顺县| 农安县| 右玉县| 子长县| 合山市| 调兵山市| 苍溪县| 建德市| 绥棱县| 花垣县| 乌拉特中旗| 大宁县| 志丹县| 阿鲁科尔沁旗| 宁晋县| 邳州市| 通许县| 新邵县| 田阳县| 湘乡市|