Exemple #1
0
        public static void SaveSysDept(SysDept item, DataProviderAction action)
        {
            if (item == null)
            {
                return;
            }

            SqlConnection conn = DBUtils.GetConnection();
            SqlCommand    cmd  = DBUtils.GetCommand();

            try
            {
                cmd.Transaction = conn.BeginTransaction();

                ArrayList paras = new ArrayList();

                paras.Add(DBUtils.MakeInParam("@Dept_ID", SqlDbType.NVarChar, 8, item.DeptID));
                paras.Add(DBUtils.MakeInParam("@Dept_Name", SqlDbType.NVarChar, 30, item.DeptName));
                paras.Add(DBUtils.MakeInParam("@Dept_Short", SqlDbType.NVarChar, 4, item.DeptShort));
                paras.Add(DBUtils.MakeInParam("@Co_ID", SqlDbType.NVarChar, 4, item.CoID));
                paras.Add(DBUtils.MakeInParam("@Dept_PID", SqlDbType.NVarChar, 8, item.DeptPID));
                paras.Add(DBUtils.MakeInParam("@Crt_Date", SqlDbType.DateTime, item.CrtDate));
                paras.Add(DBUtils.MakeInParam("@Dept_Address", SqlDbType.NVarChar, 100, item.DeptAddress));
                paras.Add(DBUtils.MakeInParam("@Dept_Post", SqlDbType.NVarChar, 10, item.DeptPost));
                paras.Add(DBUtils.MakeInParam("@Dept_Tele", SqlDbType.NVarChar, 30, item.DeptTele));
                paras.Add(DBUtils.MakeInParam("@Dept_Fax", SqlDbType.NVarChar, 30, item.DeptFax));
                paras.Add(DBUtils.MakeInParam("@Dept_EMail", SqlDbType.NVarChar, 32, item.DeptEMail));
                paras.Add(DBUtils.MakeInParam("@Dept_Man", SqlDbType.NVarChar, 6, item.DeptMan));
                paras.Add(DBUtils.MakeInParam("@Dept_Level", SqlDbType.SmallInt, item.DeptLevel));
                paras.Add(DBUtils.MakeInParam("@Dept_Type", SqlDbType.SmallInt, item.DeptType));
                paras.Add(DBUtils.MakeInParam("@Dept_Depth", SqlDbType.SmallInt, item.DeptDepth));
                paras.Add(DBUtils.MakeInParam("@Sort_Order", SqlDbType.SmallInt, item.SortOrder));
                paras.Add(DBUtils.MakeInParam("@Dept_Status", SqlDbType.SmallInt, item.DeptStatus));
                paras.Add(DBUtils.MakeInParam("@Auth_Dept", SqlDbType.NVarChar, 8, item.AuthDept));
                paras.Add(DBUtils.MakeInParam("@Remark", SqlDbType.NVarChar, 20, item.Remark));
                paras.Add(DBUtils.MakeInParam("@Action", SqlDbType.Int, action));

                DBUtils.ExecuteNonQuery(conn, cmd, CommandType.StoredProcedure, PublicConsts.DatabaseOwner + ".P_Save_SysDept", paras);

                cmd.Transaction.Commit();
            }
            catch
            {
                cmd.Transaction.Rollback();
                throw;
            }
            finally
            {
                DBUtils.SetDispose(conn, cmd);
            }
        }
Exemple #2
0
        public static SysDept PopulateSysDept(IDataReader reader)
        {
            SysDept item = new SysDept();

            item.DeptID    = reader["Dept_ID"] as string;
            item.DeptName  = reader["Dept_Name"] as string;
            item.DeptShort = reader["Dept_Short"] as string;
            item.CoID      = reader["Co_ID"] as string;
            item.CoName    = reader["Co_Name"] as string;
            item.DeptPID   = reader["Dept_PID"] as string;
            item.CrtDate   = Convert.ToDateTime(reader["Crt_Date"]);
            if (reader["Dept_Address"] != DBNull.Value)
            {
                item.DeptAddress = reader["Dept_Address"] as string;
            }
            if (reader["Dept_Post"] != DBNull.Value)
            {
                item.DeptPost = reader["Dept_Post"] as string;
            }
            if (reader["Dept_Tele"] != DBNull.Value)
            {
                item.DeptTele = reader["Dept_Tele"] as string;
            }
            if (reader["Dept_Fax"] != DBNull.Value)
            {
                item.DeptFax = reader["Dept_Fax"] as string;
            }
            if (reader["Dept_EMail"] != DBNull.Value)
            {
                item.DeptEMail = reader["Dept_EMail"] as string;
            }
            item.DeptMan        = reader["Dept_Man"] as string;
            item.DeptLevel      = (short)reader["Dept_Level"];
            item.DeptLevelName  = reader["Dept_Level_Name"] as string;
            item.DeptType       = (short)reader["Dept_Type"];
            item.DeptTypeName   = reader["Dept_Type_Name"] as string;
            item.DeptDepth      = (short)reader["Dept_Depth"];
            item.SortOrder      = (short)reader["Sort_Order"];
            item.DeptStatus     = (short)reader["Dept_Status"];
            item.DeptStatusName = reader["Dept_Status_Name"] as string;
            item.AuthDept       = reader["Auth_Dept"] as string;
            if (reader["Remark"] != DBNull.Value)
            {
                item.Remark = reader["Remark"] as string;
            }

            return(item);
        }
Exemple #3
0
        public static SysDept GetSysDept(string deptid)
        {
            SysDept item = new SysDept();

            try
            {
                ArrayList paras = new ArrayList();
                paras.Add(DBUtils.MakeInParam("@Dept_ID", SqlDbType.NVarChar, 8, deptid));
                paras.Add(DBUtils.MakeInParam("@Get_Action", SqlDbType.NVarChar, 20, DataGetAction.Row.ToString().ToLower()));

                SqlDataReader reader = DBUtils.ExecuteReader(CommandType.StoredProcedure, PublicConsts.DatabaseOwner + ".P_Get_SysDept", paras);

                if (reader.Read())
                {
                    item = PopulateSysDept(reader);
                }

                reader.Close();
            }
            catch { throw; }

            return(item);
        }