Ejemplo n.º 1
0
        public int Insert(VirtualInfo oParam)
        {
            string sql = @"INSERT INTO St_Virtual
                            (
                            ProductSysNo, VirtualQty, CreateTime,
                            CreateUserSysNo
                            )
                            VALUES (
                            @ProductSysNo, @VirtualQty, @CreateTime,
                            @CreateUserSysNo
                            );set @SysNo = SCOPE_IDENTITY();";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4);
            SqlParameter paramProductSysNo = new SqlParameter("@ProductSysNo", SqlDbType.Int,4);
            SqlParameter paramVirtualQty = new SqlParameter("@VirtualQty", SqlDbType.Int,4);
            SqlParameter paramCreateTime = new SqlParameter("@CreateTime", SqlDbType.DateTime);
            SqlParameter paramCreateUserSysNo = new SqlParameter("@CreateUserSysNo", SqlDbType.Int,4);

            paramSysNo.Direction = ParameterDirection.Output;

            if ( oParam.ProductSysNo != AppConst.IntNull)
                paramProductSysNo.Value = oParam.ProductSysNo;
            else
                paramProductSysNo.Value = System.DBNull.Value;
            if ( oParam.VirtualQty != AppConst.IntNull)
                paramVirtualQty.Value = oParam.VirtualQty;
            else
                paramVirtualQty.Value = System.DBNull.Value;
            if ( oParam.CreateTime != AppConst.DateTimeNull)
                paramCreateTime.Value = oParam.CreateTime;
            else
                paramCreateTime.Value = System.DBNull.Value;
            if ( oParam.CreateUserSysNo != AppConst.IntNull)
                paramCreateUserSysNo.Value = oParam.CreateUserSysNo;
            else
                paramCreateUserSysNo.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramProductSysNo);
            cmd.Parameters.Add(paramVirtualQty);
            cmd.Parameters.Add(paramCreateTime);
            cmd.Parameters.Add(paramCreateUserSysNo);

            return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo);
        }
Ejemplo n.º 2
0
        public void Create(VirtualInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

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

                //������¼
                int rowsAffected = new VirtualDac().Insert(oParam);
                if(rowsAffected != 1)
                    throw new BizException("insert virtual error");

                InventoryManager.GetInstance().SetVirtualQty(oParam.ProductSysNo, oParam.VirtualQty);

                scope.Complete();
            }
        }
Ejemplo n.º 3
0
 private void map(VirtualInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.ProductSysNo = Util.TrimIntNull(tempdr["ProductSysNo"]);
     oParam.VirtualQty = Util.TrimIntNull(tempdr["VirtualQty"]);
     oParam.CreateTime = Util.TrimDateNull(tempdr["CreateTime"]);
     oParam.CreateUserSysNo = Util.TrimIntNull(tempdr["CreateUserSysNo"]);
 }