/// <summary>
        /// 新增
        /// </summary>
        /// <param name="fun"></param>
        /// <returns></returns>
        public bool InsertFunction(FunctionEntity fun)
        {
            if (fun != null)
            {
                string strSQL = @" INSERT  INTO TBLFUNCTION
                                            ( oid , functionkey , functionname ,  functionlevel , functionparentid , functionurl ,functionstatus ,
                                              functionorder , functiontype , memo ,cuser ,cdate ,muser ,mdate ,addition1 ,addition2 )
                                    VALUES  ( @OID ,@functionkey ,@functionname ,@functionlevel ,@functionparentid ,@functionurl ,@functionstatus ,
                                              @functionorder ,@functiontype , @memo ,@cuser ,GETDATE() , @muser ,GETDATE() ,NULL ,NULL) ";
                string[] paramNames = new string[12];
                object[] paramValues = new object[12];

                paramNames[0] = "OID";
                paramNames[1] = "functionkey";
                paramNames[2] = "functionname";
                paramNames[3] = "functionlevel";
                paramNames[4] = "functionparentid";
                paramNames[5] = "functionurl";
                paramNames[6] = "functionstatus";
                paramNames[7] = "functionorder";
                paramNames[8] = "functiontype";
                paramNames[9] = "memo";
                paramNames[10] = "cuser";
                paramNames[11] = "muser";

                paramValues[0] = fun.OID;
                paramValues[1] = fun.FUNCTIONKEY;
                paramValues[2] = fun.FUNCTIONNAME;
                paramValues[3] = fun.FUNCTIONLEVEL;
                paramValues[4] = fun.FUNCTIONPARENTID;
                paramValues[5] = fun.FUNCTIONURL;
                paramValues[6] = fun.FUNCTIONSTATUS;
                paramValues[7] = fun.FUNCTIONORDER;
                paramValues[8] = fun.FUNCTIONTYPE;
                paramValues[9] = fun.MEMO;
                paramValues[10] = fun.CUSER;
                paramValues[11] = fun.MUSER;
                SqlDBBroker broker = new SqlDBBroker();
                try
                {
                    broker.Open();
                    broker.BeginTrans();
                    broker.ExecuteNonQuery(strSQL, CommandType.Text, paramNames, paramValues);
                    broker.CommitTrans();
                }
                catch
                {
                    broker.RollbackTrans();
                    return false;
                }
                finally
                {
                    broker.Close();
                }
            }
            return true;
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="fun"></param>
        /// <returns></returns>
        public bool UpdateFunction(FunctionEntity fun)
        {
            if (fun != null)
            {
                string strSQL = @" UPDATE TBLFUNCTION SET functionkey=@functionkey,functionname=@functionname, functionurl=@functionurl ,
                                    functionstatus=@functionstatus ,functionorder=@functionorder,memo=@memo,muser=@muser,mdate=GETDATE()
                                    WHERE oid=@OID ";
                string[] paramNames = new string[8];
                object[] paramValues = new object[8];

                paramNames[0] = "OID";
                paramNames[1] = "functionkey";
                paramNames[2] = "functionname";
                paramNames[3] = "functionurl";
                paramNames[4] = "functionstatus";
                paramNames[5] = "functionorder";
                paramNames[6] = "memo";
                paramNames[7] = "muser";

                paramValues[0] = fun.OID;
                paramValues[1] = fun.FUNCTIONKEY;
                paramValues[2] = fun.FUNCTIONNAME;
                paramValues[3] = fun.FUNCTIONURL;
                paramValues[4] = fun.FUNCTIONSTATUS;
                paramValues[5] = fun.FUNCTIONORDER;
                paramValues[6] = fun.MEMO;
                paramValues[7] = fun.MUSER;
                SqlDBBroker broker = new SqlDBBroker();
                try
                {
                    broker.Open();
                    broker.BeginTrans();
                    broker.ExecuteNonQuery(strSQL, CommandType.Text, paramNames, paramValues);
                    broker.CommitTrans();
                }
                catch
                {
                    broker.RollbackTrans();
                    return false;
                }
                finally
                {
                    broker.Close();
                }
            }
            return true;
        }
 private FunctionEntity Datarow2Entity(DataRow dr)
 {
     if (dr != null)
     {
         FunctionEntity fun = new FunctionEntity();
         fun.OID = Convert.ToString(dr["OID"]);
         fun.FUNCTIONKEY = Convert.ToString(dr["FUNCTIONKEY"]);
         fun.FUNCTIONLEVEL = Convert.ToInt32(dr["FUNCTIONLEVEL"]);
         fun.FUNCTIONNAME = Convert.ToString(dr["FUNCTIONNAME"]);
         fun.FUNCTIONORDER = Convert.ToInt32(dr["FUNCTIONORDER"]);
         fun.FUNCTIONPARENTID = Convert.ToString(dr["FUNCTIONPARENTID"]);
         fun.FUNCTIONSTATUS = Convert.ToString(dr["FUNCTIONSTATUS"]);
         fun.FUNCTIONTYPE = Convert.ToInt32(dr["FUNCTIONTYPE"]);
         fun.FUNCTIONURL = Convert.ToString(dr["FUNCTIONURL"]);
         fun.MEMO = Convert.ToString(dr["MEMO"]);
         return fun;
     }
     else
     {
         return null;
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (CheckSave())
     {
         bool retValue = true;
         FunctionController controler = new FunctionController();
         FunctionEntity fun = new FunctionEntity();
         fun.OID = hdfOID.Value;
         fun.FUNCTIONPARENTID = hfParentOID.Value;
         fun.FUNCTIONKEY = txtFuncCode.Text.Trim();
         fun.FUNCTIONLEVEL = Convert.ToInt32(txtFuncLevel.Text.Trim());
         fun.FUNCTIONNAME = txtFuncName.Text.Trim();
         fun.FUNCTIONORDER = Convert.ToInt32(txtFuncOrder.Text.Trim());
         fun.FUNCTIONSTATUS = drpFuncStatus.SelectedValue;
         fun.FUNCTIONTYPE = 0;
         fun.FUNCTIONURL = txtFuncUrl.Text.Trim();
         fun.MEMO = txtFuncMemo.Text.Trim();
         fun.CUSER = AppCenter.CurrentPersonAccount;
         fun.MUSER = AppCenter.CurrentPersonAccount;
         if (string.IsNullOrEmpty(fun.OID))
         {
             fun.OID = Guid.NewGuid().ToString();
             retValue = controler.InsertFunction(fun);
         }
         else
         {
             retValue = controler.UpdateFunction(fun);
         }
         if (retValue)
         {
             base.ShowMessage(CommonMessage.SaveSuccess);
             this.ClearAllControls();
             this.BindTree();
         }
         else
         {
             base.ShowMessage(CommonMessage.SaveFailed);
         }
     }
 }