Exemplo n.º 1
0
        public int Insert(OnlineC1_C2Info oParam)
        {
            string sql = @"INSERT INTO OnlineC1_C2
                            (
                            C2SysNo, OrderNum
                            )
                            VALUES (
                            @C2SysNo, @OrderNum
                            )";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramC2SysNo = new SqlParameter("@C2SysNo", SqlDbType.Int, 4);
            SqlParameter paramOrderNum = new SqlParameter("@OrderNum", SqlDbType.Int, 4);

            if (oParam.C2SysNo != AppConst.IntNull)
                paramC2SysNo.Value = oParam.C2SysNo;
            else
                paramC2SysNo.Value = System.DBNull.Value;
            if (oParam.OrderNum != AppConst.IntNull)
                paramOrderNum.Value = oParam.OrderNum;
            else
                paramOrderNum.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramC2SysNo);
            cmd.Parameters.Add(paramOrderNum);

            return SqlHelper.ExecuteNonQuery(cmd);
        }
Exemplo n.º 2
0
        public int CompareTo(object obj)
        {
            OnlineC1_C2Info b = obj as OnlineC1_C2Info;

            if (this.OrderNum > b.OrderNum)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Exemplo n.º 3
0
        public int Delete(OnlineC1_C2Info oParam)
        {
            string sql = "DELETE OnlineC1_C2 where C2SysNo=@C2SysNo";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramC2SysNo = new SqlParameter("@C2SysNo", SqlDbType.Int, 4);
            if (oParam.C2SysNo != AppConst.IntNull)
                paramC2SysNo.Value = oParam.C2SysNo;
            else
                paramC2SysNo.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramC2SysNo);

            return SqlHelper.ExecuteNonQuery(cmd);
        }
Exemplo n.º 4
0
        public int Update(OnlineC1_C2Info oParam)
        {
            string sql = @"UPDATE OnlineC1_C2 SET
                            C2SysNo=@C2SysNo, OrderNum=@OrderNum
                            WHERE C2SysNo=@C2SysNo";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramC2SysNo = new SqlParameter("@C2SysNo", SqlDbType.Int, 4);
            SqlParameter paramOrderNum = new SqlParameter("@OrderNum", SqlDbType.Int, 4);

            if (oParam.C2SysNo != AppConst.IntNull)
                paramC2SysNo.Value = oParam.C2SysNo;
            else
                paramC2SysNo.Value = System.DBNull.Value;
            if (oParam.OrderNum != AppConst.IntNull)
                paramOrderNum.Value = oParam.OrderNum;
            else
                paramOrderNum.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramC2SysNo);
            cmd.Parameters.Add(paramOrderNum);

            return SqlHelper.ExecuteNonQuery(cmd);
        }
Exemplo n.º 5
0
 private void map(OnlineC1_C2Info oParam, DataRow tempdr)
 {
     oParam.C2SysNo = Util.TrimIntNull(tempdr["C2SysNo"]);
     oParam.OrderNum = Util.TrimIntNull(tempdr["OrderNum"]);
 }
Exemplo n.º 6
0
        public void MoveUp(OnlineC1_C2Info oParam)
        {
            if (oParam.OrderNum == 1)
            {
                throw new BizException("it's the first one, can't be moved up");
            }
            SortedList sl = GetOnlineC1_C2List(oParam.C2SysNo);
            if (sl == null)
            {
                throw new BizException("no items");
            }

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

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

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

                scope.Complete();
            }
        }
Exemplo n.º 7
0
 public OnlineC1_C2Info LoadOnlineC1_C2(int C2SysNo)
 {
     string sql = "select * from onlineC1_C2(nolock) where c2sysno=" + C2SysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if (Util.HasMoreRow(ds))
     {
         OnlineC1_C2Info o = new OnlineC1_C2Info();
         map(o, ds.Tables[0].Rows[0]);
         return o;
     }
     else
         return null;
 }
Exemplo n.º 8
0
        public void Delete(OnlineC1_C2Info oParam)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                MoveBottom(oParam);
                new OnlineC1_C2Dac().Delete(oParam);
                DataSet ds = GetOnlineC1_C2_ProductDs(oParam.C2SysNo);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    OnlineC1_ProductInfo o = LoadOnlineC1_Product(Util.TrimIntNull(dr["SysNo"]));
                    new OnlineC1_ProductDac().Delete(o);
                }
                scope.Complete();
            }
        }
Exemplo n.º 9
0
        public SortedList GetOnlineC1_C2List(int C2SysNo)
        {
            Category2Info c2 = CategoryManager.GetInstance().GetC2Hash()[C2SysNo] as Category2Info;
            int c1SysNo = c2.C1SysNo;
            string sql = @"select * from OnlineC1_C2 oc(nolock) inner join category2 c2(nolock) on oc.c2sysno=c2.sysno where c2.c1sysno=" + c1SysNo + " order by ordernum";
            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)
            {
                OnlineC1_C2Info item = new OnlineC1_C2Info();
                map(item, dr);
                sl.Add(item, null);
            }
            return sl;
        }
Exemplo n.º 10
0
 public int SetOrderNum(OnlineC1_C2Info oParam)
 {
     string sql = "update onlineC1_C2 set ordernum = " + oParam.OrderNum + " where c2sysno = " + oParam.C2SysNo;
     SqlCommand cmd = new SqlCommand(sql);
     return SqlHelper.ExecuteNonQuery(cmd);
 }