예제 #1
0
 public ActionResult Update(PurchaseorderInfo purchaseorderInfo)
 {
     try
     {
         purchaseorderInfo.UpdatedBy   = CurrentUserInfo.UserName;
         purchaseorderInfo.UpdatedDate = DateTime.Now;
         IPurchaseorderService purchaseorderService = UnityHelper.UnityResolve <IPurchaseorderService>();
         var data = purchaseorderService.UpdatePurchaseorder(purchaseorderInfo);
         LogHelper.LogOperation(CurrentUserInfo.UserCode, string.Format("Update PurchaseorderInfo {0},{1}", LogHelper.ChangeEntityToLog(purchaseorderInfo), data));
         if (data > 0)
         {
             return(Content("OK"));
         }
         else
         {
             return(Content("Failed"));
         }
     }
     catch (BusinessException bex)
     {
         return(Content(bex.Message));
     }
     catch (Exception ex)
     {
         LogHelper.LogError(ex, "");
         return(Content(ex.Message));
     }
 }
예제 #2
0
        /// <summary>
        /// 更新一条Purchaseorder记录
        /// </summary>
        /// <param name="db">DataBase对象</param>
        /// <param name="tran">一个有效的DbTransaction</param>
        /// <param name="purchaseorder">Purchaseorder对象</param>
        /// <param name="whLoginID">要查询的仓库的前缀</param>
        /// <returns>执行更新对数据库影响的行数</returns>
        public int UpdatePurchaseorder(Database db, DbTransaction tran, PurchaseorderInfo purchaseorderInfo)
        {
            int result = 0;

            SqlParameter[] paras = Set_Purchaseorder_Parameters(purchaseorderInfo);
            if (paras != null)
            {
                result += DBHelper.ExecuteNonQuery(db, tran, CommandType.Text, SQL_UPDATE_PURCHASEORDER, paras);
            }
            return(result);
        }
예제 #3
0
 public ActionResult Edit(PurchaseorderInfo purchaseorderInfo)
 {
     if (purchaseorderInfo.PoID == 0)
     {
         return(Insert(purchaseorderInfo));
     }
     else
     {
         return(Update(purchaseorderInfo));
     }
 }
예제 #4
0
        /// <summary>
        /// 新增一条Purchaseorder记录
        /// </summary>
        /// <param name="purchaseorder">Purchaseorder对象</param>
        /// <param name="whLoginID">要查询的仓库的前缀</param>
        /// <returns>执行新增对数据库影响的行数</returns>
        public int InsertPurchaseorder(PurchaseorderInfo purchaseorderInfo)
        {
            int result = 0;

            SqlParameter[] paras = Set_Purchaseorder_Parameters(purchaseorderInfo);
            if (paras != null)
            {
                result = DBHelper.ExecuteNonQuery(CommandType.Text, SQL_INSERT_PURCHASEORDER, paras);
            }
            return(result);
        }
예제 #5
0
 /// <summary>
 /// 设置SQL参数表
 /// </summary>
 /// <param name="Purchaseorder">Purchaseorder对象</param>
 /// <returns>Purchaseorder参数数组</returns>
 private SqlParameter[] Set_Purchaseorder_Parameters(PurchaseorderInfo purchaseorderInfo)
 {
     SqlParameter[] paramArray = new SqlParameter[] { new SqlParameter("@PoID", purchaseorderInfo.PoID),
                                                      new SqlParameter("@SupplierID", purchaseorderInfo.SupplierID),
                                                      new SqlParameter("@PoDate", purchaseorderInfo.PoDate),
                                                      new SqlParameter("@Contact", string.IsNullOrEmpty(purchaseorderInfo.Contact)?"":purchaseorderInfo.Contact),
                                                      new SqlParameter("@ContactPhone", string.IsNullOrEmpty(purchaseorderInfo.ContactPhone)?"":purchaseorderInfo.ContactPhone),
                                                      new SqlParameter("@ContactAddress", string.IsNullOrEmpty(purchaseorderInfo.ContactAddress)?"":purchaseorderInfo.ContactAddress),
                                                      new SqlParameter("@Status", string.IsNullOrEmpty(purchaseorderInfo.Status)?"":purchaseorderInfo.Status),
                                                      new SqlParameter("@TotalAmount", purchaseorderInfo.TotalAmount),
                                                      new SqlParameter("@TotalItemCount", purchaseorderInfo.TotalItemCount),
                                                      new SqlParameter("@Remark", string.IsNullOrEmpty(purchaseorderInfo.Remark)?"":purchaseorderInfo.Remark),
                                                      new SqlParameter("@CreatedBy", string.IsNullOrEmpty(purchaseorderInfo.CreatedBy)?"":purchaseorderInfo.CreatedBy),
                                                      new SqlParameter("@UpdatedBy", string.IsNullOrEmpty(purchaseorderInfo.UpdatedBy)?"":purchaseorderInfo.UpdatedBy) };
     return(paramArray);
 }
예제 #6
0
        /// <summary>
        /// 根据purchaseorderID得到一条Purchaseorder记录
        /// </summary>
        /// <param name="purchaseorderID">purchaseorderID</param>
        /// <param name="whLoginID">要查询的仓库的前缀</param>
        /// <returns>根据purchaseorderID得到一条Purchaseorder记录</returns>
        public PurchaseorderInfo GetPurchaseorderByID(string purchaseorderID)
        {
            string sql = SQL_SELECT_ALL_PURCHASEORDER + " AND POID = @POID  ";

            SqlParameter[]    paras             = new SqlParameter[] { new SqlParameter("@POID", purchaseorderID) };
            PurchaseorderInfo purchaseorderInfo = null;

            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                if (reader.Read())
                {
                    purchaseorderInfo = InitPurchaseorderInfoByDataReader(purchaseorderInfo, reader);
                }
            }

            return(purchaseorderInfo);
        }
예제 #7
0
 /// <summary>
 /// 初始化PurchaseorderInfo
 /// </summary>
 private PurchaseorderInfo InitPurchaseorderInfoByDataReader(PurchaseorderInfo purchaseorderInfo, IDataReader reader)
 {
     purchaseorderInfo = new PurchaseorderInfo(reader["PoID"].ToString() != "" ? Int32.Parse(reader["PoID"].ToString()) : 0,
                                               reader["SupplierID"].ToString() != "" ? Int32.Parse(reader["SupplierID"].ToString()) : 0,
                                               reader["PoDate"].ToString() != "" ? DateTime.Parse(reader["PoDate"].ToString()) : new DateTime(),
                                               reader["Contact"].ToString(),
                                               reader["ContactPhone"].ToString(),
                                               reader["ContactAddress"].ToString(),
                                               reader["Status"].ToString(),
                                               reader["TotalAmount"].ToString() != "" ? Decimal.Parse(reader["TotalAmount"].ToString()) : 0,
                                               reader["TotalItemCount"].ToString() != "" ? Int32.Parse(reader["TotalItemCount"].ToString()) : 0,
                                               reader["Remark"].ToString(),
                                               reader["Ts"],
                                               reader["CreatedBy"].ToString(),
                                               reader["CreatedDate"].ToString() != "" ? DateTime.Parse(reader["CreatedDate"].ToString()) : new DateTime(),
                                               reader["UpdatedBy"].ToString(),
                                               reader["UpdatedDate"].ToString() != "" ? DateTime.Parse(reader["UpdatedDate"].ToString()) : new DateTime());
     return(purchaseorderInfo);
 }
예제 #8
0
        /// <summary>
        /// 根据purchaseorderID得到一条Purchaseorder记录
        /// </summary>
        /// <param name="db">DataBase对象</param>
        /// <param name="tran">一个有效的DbTransaction</param>
        /// <param name="purchaseorderID">purchaseorderID</param>
        /// <param name="whLoginID">要查询的仓库的前缀</param>
        /// <returns>根据purchaseorderID得到一条Purchaseorder记录</returns>
        public PurchaseorderInfo GetPurchaseorderByID(Database db, DbTransaction tran, string purchaseorderID)
        {
            string sql = SQL_SELECT_ALL_PURCHASEORDER + " AND POID = @POID  ";

            SqlParameter[]    paras             = new SqlParameter[] { new SqlParameter("@POID", purchaseorderID) };
            PurchaseorderInfo purchaseorderInfo = null;

            IDataReader reader = DBHelper.ExecuteReader(db, tran, CommandType.Text, sql, paras);

            if (reader.Read())
            {
                purchaseorderInfo = InitPurchaseorderInfoByDataReader(purchaseorderInfo, reader);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }

            return(purchaseorderInfo);
        }
예제 #9
0
 /// <summary>
 /// 新增一条Purchaseorder记录
 /// </summary>
 /// <param name="purchaseorder">Purchaseorder对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行新增对数据库影响的行数</returns>
 public int InsertPurchaseorder(PurchaseorderInfo purchaseorderInfo)
 {
     return(purchaseorderDA.InsertPurchaseorder(purchaseorderInfo));
 }
예제 #10
0
 /// <summary>
 /// 更新一条Purchaseorder记录
 /// </summary>
 /// <param name="purchaseorder">Purchaseorder对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行更新对数据库影响的行数</returns>
 public int UpdatePurchaseorder(PurchaseorderInfo purchaseorderInfo)
 {
     return(purchaseorderDA.UpdatePurchaseorder(purchaseorderInfo));
 }