Example #1
0
        public int InsertOrUpdateDepart(OperationTypeInfo oParam,bool isAdd)
        {
            string sql = "";
            int _tmpInt = AppConst.IntNull;
            if (isAdd)
            {
                sql = @"INSERT INTO sys_OperationType
                            (
                            TypeName, TypeDescription, Status
                            )
                            VALUES (
                            @TypeName, @TypeDescription, @Status
                            );set @SysNo = SCOPE_IDENTITY();";
            }
            else
            {
                sql=@"UPDATE sys_OperationType
                            SET TypeName=@TypeName,TypeDescription=@TypeDescription,Status=@Status WHERE SysNo=@SysNo";
            }

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramTypeName = new SqlParameter("@TypeName", SqlDbType.VarChar, 50);
            SqlParameter paramTypeDescription = new SqlParameter("@TypeDescription", SqlDbType.VarChar, 500);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4);

            if (isAdd)
                paramSysNo.Direction = ParameterDirection.Output;
            else
            {
                if (oParam.SysNo != AppConst.IntNull)
                    paramSysNo.Value = oParam.SysNo;
                else
                    paramSysNo.Value = System.DBNull.Value;
            }

            if (oParam.TypeName != AppConst.StringNull)
                paramTypeName.Value = oParam.TypeName;
            else
                paramTypeName.Value = System.DBNull.Value;
            if (oParam.TypeDescription != AppConst.StringNull)
                paramTypeDescription.Value = oParam.TypeDescription;
            else
                paramTypeDescription.Value = System.DBNull.Value;
            if (oParam.Status != AppConst.IntNull)
                paramStatus.Value = oParam.Status;
            else
                paramStatus.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramTypeName);
            cmd.Parameters.Add(paramTypeDescription);
            cmd.Parameters.Add(paramStatus);

            if (isAdd)
            {
                SqlHelper.ExecuteNonQuery(cmd, out _tmpInt);
                oParam.SysNo = _tmpInt;
                return 1;
            }
            else
                return SqlHelper.ExecuteNonQuery(cmd);
        }
Example #2
0
 /// <summary>
 /// Map OperationInfo
 /// </summary>
 /// <param name="oParam"></param>
 /// <param name="tempdr"></param>
 private void map(OperationTypeInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.TypeName = Util.TrimNull(tempdr["TypeName"]);
     oParam.TypeDescription = Util.TrimNull(tempdr["TypeDescription"]);
     oParam.Status = Util.TrimIntNull(tempdr["Status"]);
 }
Example #3
0
 /// <summary>
 /// ��ȡ��������Dateset
 /// </summary>
 /// <param name="paramHash"></param>
 /// <returns></returns>
 public Hashtable GetOperationTypeHt(Hashtable paramHash)
 {
     DataSet ds = GetOperationTypeDs(paramHash);
     if(!Util.HasMoreRow(ds))
         return null;
     Hashtable ht=new Hashtable();
     foreach(DataRow dr in ds.Tables[0].Rows)
     {
         OperationTypeInfo item = new OperationTypeInfo();
         map(item, dr);
         ht.Add(item, null);
     }
     return ht;
 }
Example #4
0
        /// <summary>
        /// ��Ӳ��š�
        /// </summary>
        /// <param name="paramRolePrivilegeSysNo"></param>
        /// <returns></returns>
        public int InsertDeptInfo(OperationTypeInfo oParam,string paramDelSql)
        {
            bool isAdd = false;
            int _return = 0;

            if (oParam.SysNo == -1) isAdd = true;

            string[] strPrivilege = paramDelSql.Split(',');
            if(isAdd) oParam.SysNo = SequenceDac.GetInstance().Create("Sys_Sequence");
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                _return = new DepartMentDC().InsertOrUpdateDepart(oParam,isAdd);
                _return = new DepartMentDC().DelPrivilegeDept(paramDelSql,oParam.SysNo);
                for (int i = 0; i < strPrivilege.Length; i++)
                {
                    if (Util.IsNumber(strPrivilege[i]))
                        _return = new DepartMentDC().InsertPrivilegeDept(oParam.SysNo, Int16.Parse(strPrivilege[i]));
                }
                scope.Complete();
            }
            return _return;
        }