예제 #1
0
 public SKUCGYModel(SKUCGY cgy)
 {
     this.ID = cgy.ID;
     this.Code = cgy.Code;
     this.Name = cgy.Name;
     this.PID = cgy.PID;
     this.LevelIndex = cgy.LevelIndex;
 }
예제 #2
0
 public int AddTwo(SKUCGY cgy)
 {
     int result = -1;
     string sql = @"INSERT INTO SKUCGY
                    (ID, CODE, NAME, PID, LEVELINDEX)
                    VALUES(@ID, @CODE, @NAME, @PID, @LEVELINDEX)";
     using (DbCommand cmd = _database.GetSqlStringCommand(sql))
     {
         _database.AddInParameter(cmd, "@ID", DbType.Guid, cgy.ID);
         _database.AddInParameter(cmd, "@CODE", DbType.String, cgy.Code);
         _database.AddInParameter(cmd, "@NAME", DbType.String, cgy.Name);
         _database.AddInParameter(cmd, "@PID", DbType.Guid, cgy.PID);
         _database.AddInParameter(cmd, "@LEVELINDEX", DbType.Int16, cgy.LevelIndex);
         result = _database.ExecuteNonQuery(cmd);
     }
     return result;
 }
예제 #3
0
 public bool AddOne(SKUCGY cgy)
 {
     bool result = false;
     try
     {
         int count = _dal.AddOne(cgy);
         if(count > 0)
         {
             result = true;
         }
     }
     catch(Exception e)
     {
         string excepMsg = string.Format(@"{0},{1}", DateTime.Now.ToString(), e.Message);
         Trace.TraceError(excepMsg);
         throw new Exception("判断一级Code是否存在出错:BLLOneManagement.AddOne(SKUCGY cgy)", e);
     }
     return result;
 }
예제 #4
0
        public List<SKUCGY> GetOneList()
        {
            List<SKUCGY> result = null;
            try
            {
                DataTable dt = _dal.GetOneList();
                if(dt != null && dt.Rows.Count > 0)
                {
                    result = new List<SKUCGY>();
                    SKUCGY cgy;
                    foreach(DataRow dr in dt.Rows)
                    {
                        Guid ID = dr.GetFieldValue<Guid>("ID");
                        string code = dr.GetFieldValue<string>("CODE");
                        string name = dr.GetFieldValue<string>("NAME");
                        Guid PID = dr.GetFieldValue<Guid>("PID");
                        short levelIndex = dr.GetFieldValue<short>("LEVELINDEX");
                        cgy = new SKUCGY(ID)
                        {
                            Code = code,
                            Name = name,
                            PID = PID,
                            LevelIndex = levelIndex
                        };
                        result.Add(cgy);
                    }
                }
            }
            catch(Exception e)
            {
                string excepMsg = string.Format(@"{0},{1}", DateTime.Now.ToString(), e.Message);
                Trace.TraceError(excepMsg);
                throw new Exception("获取一级目录列表出错:BLLOneManagement.GetOneList()", e);
            }

            return result;
        }
 /// <summary>
 /// 在制定列表中查找某个节点的父节点并返回查找情况
 /// </summary>
 /// <param name="list"></param>
 /// <param name="child"></param>
 /// <param name="parent"></param>
 /// <returns></returns>
 private bool FindParentNode(List<SKUCGY> list, SKUCGY child, out SKUCGY parent)
 {
     parent = null;
     var parents = list.Where(x => x.ID == child.PID);
     if (parents != null && parents.Count() > 0)
     {
         parent = parents.First();
         return true;
     }
     else
     {
         return false;
     }
 }
 public void TwoChangedEventExecute(SKUCGY cgy)
 {
     this.InitSKUCGYTree();
 }
예제 #7
0
 public int UpdateTwo(SKUCGY cgy)
 {
     int result = -1;
     string sql = @"UPDATE SKUCGY
                    SET NAME = @NAME
                    WHERE ID = @ID";
     using (DbCommand cmd = _database.GetSqlStringCommand(sql))
     {
         _database.AddInParameter(cmd, "@NAME", DbType.String, cgy.Name);
         _database.AddInParameter(cmd, "@ID", DbType.Guid, cgy.ID);
         result = _database.ExecuteNonQuery(cmd);
     }
     return result;
 }
예제 #8
0
        private List<SKUCGY> GenerateSKUCGYList(DataTable dt)
        {
            List<SKUCGY> result = null;
            if(dt != null && dt.Rows.Count > 0)
            {
                result = new List<SKUCGY>();
                SKUCGY cgy = null;
                foreach(DataRow dr in dt.Rows)
                {
                    cgy = new SKUCGY()
                    {
                        Code = dr[0].ToString(),
                        Name = dr[1].ToString(),
                        PID = Guid.Empty,
                        LevelIndex = 1,
                    };
                    result.Add(cgy);
                }
            }

            return result;
        }