public int CompareTo(object obj)
        {
            CategoryAttribute2Info b = obj as CategoryAttribute2Info;

            if (this._ordernum > b._ordernum)
            {
                return(2);
            }
            else
            {
                return(-2);
            }
        }
Exemple #2
0
 //---------------------------Category_Attribute1-------------------------
 //---------------------------Category_Attribute2-------------------------
 public bool IsExistAttribute2(CategoryAttribute2Info oParam)
 {
     return new CategoryDac().IsExistAttribute2(oParam);
 }
Exemple #3
0
        public int InsertAttribute2(CategoryAttribute2Info oParam)
        {
            string _atrribute2ID = "";
            string _tmpStr = "";
            int _tmpInt = -1;
            string sql = "select max(Attribute2ID) from Category_Attribute2 where A1SysNo=" + oParam.A1SysNo.ToString();
            _tmpStr = SqlHelper.ExecuteScalar(sql).ToString();
            if (_tmpStr.Trim() == "")
                _tmpStr = "0";
            if (!Util.IsInteger(_tmpStr))
                throw new BizException("�Բ������ɱ�Ŵ��󣬲������");
            _tmpInt = Convert.ToInt32(_tmpStr);
            _tmpInt++;

            _atrribute2ID = _tmpInt.ToString();

            oParam.Attribute2ID = _atrribute2ID;

            return new CategoryDac().InsertAttribute2(oParam);
        }
Exemple #4
0
 public int GetCatetoryAttribute2NewOrderNum(CategoryAttribute2Info oParam)
 {
     return new CategoryDac().GetCatetoryAttribute2NewOrderNum(oParam);
 }
Exemple #5
0
 private void Map(CategoryAttribute2Info oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.A1SysNo = Util.TrimIntNull(tempdr["A1SysNo"]);
     oParam.Attribute2ID = Util.TrimNull(tempdr["Attribute2ID"]);
     oParam.Attribute2Name = Util.TrimNull(tempdr["Attribute2Name"]);
     oParam.OrderNum = Util.TrimIntNull(tempdr["OrderNum"]);
     oParam.Status = Util.TrimIntNull(tempdr["Status"]);
     oParam.Attribute2Type  = Util.TrimIntNull(tempdr["Attribute2Type"]);
 }
Exemple #6
0
 public SortedList GetAttribute2List(int paramA1SysNo)
 {
     string sql = " select * from category_attribute2 where a1sysno = " + paramA1SysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if ( !Util.HasMoreRow(ds))
         return null;
     SortedList sl = new SortedList(ds.Tables[0].Rows.Count);
     foreach( DataRow dr in ds.Tables[0].Rows )
     {
         CategoryAttribute2Info item = new CategoryAttribute2Info();
         Map(item, dr);
         sl.Add(item, null);
     }
     return sl;
 }
Exemple #7
0
 public int UpdateAttribute2(CategoryAttribute2Info oParam)
 {
     return new CategoryDac().UpdateAttribute2(oParam);
 }
Exemple #8
0
        public void MoveUp(CategoryAttribute2Info oParam)
        {
            if ( oParam.OrderNum == 1 )
            {
                throw new BizException("it's the first one, can't be moved up");
            }
            SortedList sl = GetAttribute2List(oParam.A1SysNo);
            if ( sl == null )
            {
                throw new BizException("no attributes");
            }

            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                CategoryDac o = new CategoryDac();

                foreach(CategoryAttribute2Info item  in sl.Keys)
                {
                    if ( item.OrderNum == oParam.OrderNum-1 )
                    {
                        item.OrderNum += 1;
                        o.SetOrderNum(item);
                    }
                }
                oParam.OrderNum -= 1;
                o.SetOrderNum(oParam);

                scope.Complete();
            }
        }
Exemple #9
0
 public CategoryAttribute2Info LoadCategoryAttribute2(int paramAttribute2SysNo)
 {
     string sql = "select * from category_attribute2 where sysno=" + paramAttribute2SysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if ( !Util.HasMoreRow(ds))
         return null;
     CategoryAttribute2Info item = new CategoryAttribute2Info();
     Map( item, ds.Tables[0].Rows[0]);
     return item;
 }
Exemple #10
0
        public int UpdateAttribute2(CategoryAttribute2Info oParam)
        {
            string sql = @"UPDATE Category_Attribute2 SET
                            A1SysNo=@A1SysNo,
                            Attribute2ID=@Attribute2ID, Attribute2Name=@Attribute2Name,
                            OrderNum=@OrderNum, Status=@Status,Attribute2Type=@Attribute2Type
                            WHERE SysNo=@SysNo";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4);
            SqlParameter paramA1SysNo = new SqlParameter("@A1SysNo", SqlDbType.Int,4);
            SqlParameter paramAttribute2ID = new SqlParameter("@Attribute2ID", SqlDbType.NVarChar,20);
            SqlParameter paramAttribute2Name = new SqlParameter("@Attribute2Name", SqlDbType.NVarChar,50);
            SqlParameter paramOrderNum = new SqlParameter("@OrderNum", SqlDbType.Int,4);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int,4);
            SqlParameter paramAttribute2Type = new SqlParameter("@Attribute2Type", SqlDbType.Int,4);

            paramSysNo.Value = oParam.SysNo;
            paramA1SysNo.Value = oParam.A1SysNo;
            paramAttribute2ID.Value = oParam.Attribute2ID;
            paramAttribute2Name.Value = oParam.Attribute2Name;
            paramOrderNum.Value = oParam.OrderNum;
            paramStatus.Value = oParam.Status;
            paramAttribute2Type.Value = oParam.Attribute2Type;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramA1SysNo);
            cmd.Parameters.Add(paramAttribute2ID);
            cmd.Parameters.Add(paramAttribute2Name);
            cmd.Parameters.Add(paramOrderNum);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramAttribute2Type);

            return SqlHelper.ExecuteNonQuery(cmd);
        }
Exemple #11
0
 public int SetOrderNum(CategoryAttribute2Info oParam)
 {
     string sql = "update category_attribute2 set ordernum = " + oParam.OrderNum + " where sysno = " + oParam.SysNo;
     SqlCommand cmd = new SqlCommand(sql);
     return SqlHelper.ExecuteNonQuery(cmd);
 }
Exemple #12
0
        public bool IsExistAttribute2(CategoryAttribute2Info oParam)
        {
            string sql = "select top 1 sysno from category_attribute2 where a1sysno=@a1sysno and Attribute2Name=@Attribute2Name and SysNo!=@SysNo";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramA1SysNo = new SqlParameter("@A1SysNo", SqlDbType.Int,4);
            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramAttribute2Name = new SqlParameter("@Attribute2Name", SqlDbType.NVarChar,50);

            paramA1SysNo.Value = oParam.A1SysNo;
            paramAttribute2Name.Value = oParam.Attribute2Name;
            paramSysNo.Value = oParam.SysNo;

            cmd.Parameters.Add(paramA1SysNo);
            cmd.Parameters.Add(paramAttribute2Name);
            cmd.Parameters.Add(paramSysNo);

            DataSet ds = SqlHelper.ExecuteDataSet(cmd);;
            if ( Util.HasMoreRow(ds))
                return true;
            else
                return false;
        }
Exemple #13
0
        public int InsertAttribute2(CategoryAttribute2Info oParam)
        {
            string sql = @"INSERT INTO Category_Attribute2
                            (
                            A1SysNo, Attribute2ID, Attribute2Name,
                            OrderNum, Status, Attribute2Type
                            )
                            VALUES (
                            @A1SysNo, @Attribute2ID, @Attribute2Name,
                            @OrderNum, @Status, @Attribute2Type
                            )";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramA1SysNo = new SqlParameter("@A1SysNo", SqlDbType.Int,4);
            SqlParameter paramAttribute2ID = new SqlParameter("@Attribute2ID", SqlDbType.NVarChar,20);
            SqlParameter paramAttribute2Name = new SqlParameter("@Attribute2Name", SqlDbType.NVarChar,50);
            SqlParameter paramOrderNum = new SqlParameter("@OrderNum", SqlDbType.Int,4);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int,4);
            SqlParameter paramAttribute2Type = new SqlParameter("@Attribute2Type",SqlDbType.Int,4);

            paramA1SysNo.Value = oParam.A1SysNo;
            paramAttribute2ID.Value = oParam.Attribute2ID;
            paramAttribute2Name.Value = oParam.Attribute2Name;
            paramOrderNum.Value = oParam.OrderNum;
            paramStatus.Value = oParam.Status;
            paramAttribute2Type.Value = oParam.Attribute2Type;

            cmd.Parameters.Add(paramA1SysNo);
            cmd.Parameters.Add(paramAttribute2ID);
            cmd.Parameters.Add(paramAttribute2Name);
            cmd.Parameters.Add(paramOrderNum);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramAttribute2Type);

            return SqlHelper.ExecuteNonQuery(cmd);
        }
Exemple #14
0
 public int GetCatetoryAttribute2NewOrderNum(CategoryAttribute2Info oParam)
 {
     string sql = "select isnull(max(OrderNum),0)+1 as newOrderNum from Category_Attribute2 where A1SysNo=" + oParam.A1SysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if(Util.HasMoreRow(ds))
     {
         return Int32.Parse(ds.Tables[0].Rows[0][0].ToString());
     }
     else
     {
         return 1;
     }
 }