コード例 #1
0
        public int CompareTo(object obj)
        {
            CategoryAttributeInfo b = obj as CategoryAttributeInfo;

            if (this._ordernum > b._ordernum)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
コード例 #2
0
ファイル: CategoryManager.cs プロジェクト: ue96/ue96
        public void InitAttribute(int paramC3SysNo)
        {
            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();

                CategoryAttributeInfo oItem = new CategoryAttributeInfo();
                for(int i=1; i<=attributeCapacity; i++ )
                {
                    oItem.C3SysNo = paramC3SysNo;
                    oItem.AttributeID = "A" + i.ToString();
                    oItem.AttributeName = "" + i.ToString();
                    oItem.OrderNum = i;
                    oItem.Status = (int)AppEnum.BiStatus.InValid;
                    oItem.AttributeType = (int)AppEnum.AttributeType.Text;
                    o.InsertAttribute(oItem);
                }

                scope.Complete();
            }
        }
コード例 #3
0
ファイル: CategoryManager.cs プロジェクト: ue96/ue96
        public void ImportCategory()
        {
            if ( !AppConfig.IsImportable)
                throw new BizException("Is Importable is false");

            /*  do not  use the following code after Data Pour in */
            string sql = " select top 1 * from category1 ";
            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            if ( Util.HasMoreRow(ds) )
                throw new BizException("the table category is not empty");

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

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

                try
                {
                    string sql1 = @"select cf.*, cfl.firstcategoryname from ipp2003..category_first cf, ipp2003..category_first_language cfl
                                    where cf.sysno = cfl.firstcategorysysno and languageid = 'cn'";
                    DataSet ds1 = SqlHelper.ExecuteDataSet(sql1);
                    foreach(DataRow dr1 in ds1.Tables[0].Rows )
                    {
                        Category1Info oC1 = new Category1Info();
                        oC1.C1ID = Util.TrimNull(dr1["FirstCategoryID"]);
                        oC1.C1Name = Util.TrimNull(dr1["FirstCategoryName"]);
                        oC1.Status = Util.TrimIntNull(dr1["Status"]);

                        this.Insert(oC1);

                        //insert into convert table
                        ImportInfo oC1Convert = new ImportInfo();
                        oC1Convert.OldSysNo = Util.TrimIntNull(dr1["SysNo"]);
                        oC1Convert.NewSysNo = oC1.SysNo;
                        new ImportDac().Insert(oC1Convert, "Category1");

                        string sql2 = @"select a.*, b.secondcategoryname from ipp2003..category_second a, ipp2003..category_second_language b
                                        where a.sysno = b.secondcategorysysno and languageid = 'cn'
                                        and firstcategorysysno = " + Util.TrimIntNull(dr1["SysNo"]);
                        DataSet ds2 = SqlHelper.ExecuteDataSet(sql2);
                        foreach( DataRow dr2 in ds2.Tables[0].Rows )
                        {
                            Category2Info oC2 = new Category2Info();
                            oC2.C1SysNo = oC1.SysNo;
                            oC2.C2ID = Util.TrimNull(dr2["SecondCategoryID"]);
                            oC2.C2Name = Util.TrimNull(dr2["SecondCategoryName"]);
                            oC2.Status = Util.TrimIntNull(dr2["Status"]);

                            this.Insert(oC2);

                            //insert into convert table
                            ImportInfo oC2Convert = new ImportInfo();
                            oC2Convert.OldSysNo = Util.TrimIntNull(dr2["SysNo"]);
                            oC2Convert.NewSysNo = oC2.SysNo;
                            new ImportDac().Insert(oC2Convert,"Category2");

                            string sql3 = @"select a.*, b.thirdcategoryname from ipp2003..category_third a, ipp2003..category_third_language b
                                            where a.sysno = b.thirdcategorysysno and languageid = 'cn'
                                            and secondcategorysysno = "+ Util.TrimIntNull(dr2["SysNo"]);
                            DataSet ds3 = SqlHelper.ExecuteDataSet(sql3);
                            foreach( DataRow dr3 in ds3.Tables[0].Rows )
                            {
                                Category3Info oC3 = new Category3Info();
                                oC3.C2SysNo = oC2.SysNo;
                                oC3.C3ID = Util.TrimNull(dr3["ThirdCategoryID"]);
                                oC3.C3Name = Util.TrimNull(dr3["ThirdCategoryName"]);
                                oC3.Status = Util.TrimIntNull(dr3["Status"]);

                                this.Insert(oC3);

                                //insert into convert table
                                ImportInfo oC3Convert = new ImportInfo();
                                oC3Convert.OldSysNo = Util.TrimIntNull(dr3["SysNo"]);
                                oC3Convert.NewSysNo = oC3.SysNo;
                                new ImportDac().Insert(oC3Convert, "Category3");

                                string sql4 = @"select a.*,b.AttributeName from ipp2003..category_attribute as a, ipp2003..category_attribute_language as b
                                            where
                                            a.ThirdCategorySysNo = b.ThirdCategorySysNo
                                            and a.AttributeID = b.AttributeID
                                            and languageid = 'cn' and AttributeName <>''
                                            and a.thirdcategorysysno = "+ Util.TrimIntNull(dr3["SysNo"]);
                                DataSet ds4 = SqlHelper.ExecuteDataSet(sql4);

                                int count = 0;
                                foreach( DataRow dr4 in ds4.Tables[0].Rows )
                                {
                                    if ( count == 0)
                                    {
                                        InitAttribute(Util.TrimIntNull(oC3.SysNo));
                                        count ++;
                                    }

                                    CategoryAttributeInfo oCA = new CategoryAttributeInfo();
                                    oCA.C3SysNo = oC3.SysNo;
                                    oCA.AttributeID = Util.TrimNull(dr4["AttributeID"]);
                                    oCA.AttributeName = Util.TrimNull(dr4["AttributeName"]);
                                    oCA.OrderNum = Util.TrimIntNull(dr4["SequenceNo"]);
                                    oCA.Status = Util.TrimIntNull(dr4["Status"]);

                                    new CategoryDac().UpdateAttributeByC3andAID(oCA);
                                }
                            }
                        }
                    }
                }
                catch(Exception ex)
                {
                    C1Hash.Clear();
                    C2Hash.Clear();
                    C3Hash.Clear();
                    throw ex;
                }
                scope.Complete();

            }
        }
コード例 #4
0
ファイル: CategoryManager.cs プロジェクト: ue96/ue96
 public SortedList GetAttributeList(int paramC3SysNo)
 {
     string sql = " select * from category_attribute where c3sysno = " + paramC3SysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if ( !Util.HasMoreRow(ds))
         return null;
     SortedList sl = new SortedList(attributeCapacity);
     foreach( DataRow dr in ds.Tables[0].Rows )
     {
         CategoryAttributeInfo item = new CategoryAttributeInfo();
         Map(item, dr);
         sl.Add(item, null);
     }
     return sl;
 }
コード例 #5
0
ファイル: CategoryManager.cs プロジェクト: ue96/ue96
 private void Map(CategoryAttributeInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.C3SysNo = Util.TrimIntNull(tempdr["C3SysNo"]);
     oParam.AttributeID = Util.TrimNull(tempdr["AttributeID"]);
     oParam.AttributeName = Util.TrimNull(tempdr["AttributeName"]);
     oParam.OrderNum = Util.TrimIntNull(tempdr["OrderNum"]);
     oParam.Status = Util.TrimIntNull(tempdr["Status"]);
     oParam.AttributeType  = Util.TrimIntNull(tempdr["AttributeType"]);
 }
コード例 #6
0
ファイル: CategoryManager.cs プロジェクト: ue96/ue96
 public int UpdateAttribute(CategoryAttributeInfo oParam)
 {
     return new CategoryDac().UpdateAttribute(oParam);
 }
コード例 #7
0
ファイル: CategoryManager.cs プロジェクト: ue96/ue96
        public void MoveUp(CategoryAttributeInfo oParam)
        {
            if ( oParam.OrderNum == 1 )
            {
                throw new BizException("it's the first one, can't be moved up");
            }
            SortedList sl = GetAttributeList(oParam.C3SysNo);
            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(CategoryAttributeInfo item  in sl.Keys)
                {
                    if ( item.OrderNum == oParam.OrderNum-1 )
                    {
                        item.OrderNum += 1;
                        o.SetOrderNum(item);
                    }
                }
                oParam.OrderNum -= 1;
                o.SetOrderNum(oParam);

                scope.Complete();
            }
        }
コード例 #8
0
ファイル: CategoryManager.cs プロジェクト: ue96/ue96
 //////////////////////////////////////////////////////////////////////////
 public CategoryAttributeInfo Load(int paramAttributeSysNo)
 {
     string sql = "select * from category_attribute where sysno=" + paramAttributeSysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if ( !Util.HasMoreRow(ds))
         return null;
     CategoryAttributeInfo item = new CategoryAttributeInfo();
     Map( item, ds.Tables[0].Rows[0]);
     return item;
 }
コード例 #9
0
ファイル: CategoryDac.cs プロジェクト: ue96/ue96
        public int UpdateAttributeByC3andAID(CategoryAttributeInfo oParam)
        {
            string sql = @"UPDATE Category_Attribute SET
                             AttributeName=@AttributeName,
                            OrderNum=@OrderNum, Status=@Status
                            WHERE C3SysNo=@C3SysNo and AttributeID=@AttributeID ";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramC3SysNo = new SqlParameter("@C3SysNo", SqlDbType.Int,4);
            SqlParameter paramAttributeID = new SqlParameter("@AttributeID", SqlDbType.NVarChar,20);
            SqlParameter paramAttributeName = new SqlParameter("@AttributeName", SqlDbType.NVarChar,50);
            SqlParameter paramOrderNum = new SqlParameter("@OrderNum", SqlDbType.Int,4);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int,4);
            SqlParameter paramAttributeType = new SqlParameter("@AttributeType",SqlDbType.Int,4);

            paramC3SysNo.Value = oParam.C3SysNo;
            paramAttributeID.Value = oParam.AttributeID;
            paramAttributeName.Value = oParam.AttributeName;
            paramOrderNum.Value = oParam.OrderNum;
            paramStatus.Value = oParam.Status;
            paramAttributeType.Value = oParam.AttributeType;

            cmd.Parameters.Add(paramC3SysNo);
            cmd.Parameters.Add(paramAttributeID);
            cmd.Parameters.Add(paramAttributeName);
            cmd.Parameters.Add(paramOrderNum);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramAttributeType);

            return SqlHelper.ExecuteNonQuery(cmd);
        }
コード例 #10
0
ファイル: CategoryDac.cs プロジェクト: ue96/ue96
 public int SetOrderNum(CategoryAttributeInfo oParam)
 {
     string sql = "update category_attribute set ordernum = " + oParam.OrderNum + " where sysno = " + oParam.SysNo;
     SqlCommand cmd = new SqlCommand(sql);
     return SqlHelper.ExecuteNonQuery(cmd);
 }
コード例 #11
0
ファイル: CategoryDac.cs プロジェクト: ue96/ue96
        public int InsertAttribute(CategoryAttributeInfo oParam)
        {
            string sql = @"INSERT INTO Category_Attribute
                            (
                            C3SysNo, AttributeID, AttributeName,
                            OrderNum, Status, AttributeType
                            )
                            VALUES (
                            @C3SysNo, @AttributeID, @AttributeName,
                            @OrderNum, @Status, @AttributeType
                            )";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramC3SysNo = new SqlParameter("@C3SysNo", SqlDbType.Int,4);
            SqlParameter paramAttributeID = new SqlParameter("@AttributeID", SqlDbType.NVarChar,20);
            SqlParameter paramAttributeName = new SqlParameter("@AttributeName", SqlDbType.NVarChar,50);
            SqlParameter paramOrderNum = new SqlParameter("@OrderNum", SqlDbType.Int,4);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int,4);
            SqlParameter paramAttributeType = new SqlParameter("@AttributeType",SqlDbType.Int,4);

            paramC3SysNo.Value = oParam.C3SysNo;
            paramAttributeID.Value = oParam.AttributeID;
            paramAttributeName.Value = oParam.AttributeName;
            paramOrderNum.Value = oParam.OrderNum;
            paramStatus.Value = oParam.Status;
            paramAttributeType.Value = oParam.AttributeType;

            cmd.Parameters.Add(paramC3SysNo);
            cmd.Parameters.Add(paramAttributeID);
            cmd.Parameters.Add(paramAttributeName);
            cmd.Parameters.Add(paramOrderNum);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramAttributeType);

            return SqlHelper.ExecuteNonQuery(cmd);
        }