Exemple #1
0
 /// <summary>
 /// 增加采购单
 /// </summary>
 /// <param name="changeStock"></param>
 /// <param name="conn"></param>
 /// <returns></returns>
 public int InsertProductBill(ProductBillInfo productBill, SqlTransaction trans)
 {
     Guid g = Guid.NewGuid();
     productBill.id = g;
     string sql = @"INSERT INTO [ProductBillHead]
                            ([id]
                            ,[BuyNO]
                            ,[BatchNO]
                            ,[BuyDate]
                            ,[SupplyID]
                            ,[IsReview]
                            ,[ReviewUser]
                            ,[WareHouseID]
                            ,[Detail]
                            ,[Define1]
                            ,[Define2]
                            ,[Define3]
                            ,[InsertDateTime]
                            ,[InsertUser])
                      VALUES
                            (@id
                            ,@BuyNO
                            ,@BatchNO
                            ,@BuyDate
                            ,@SupplyID
                            ,@IsReview
                            ,@ReviewUser
                            ,@WareHouseID
                            ,@Detail
                            ,@Define1
                            ,@Define2
                            ,@Define3
                            ,@InsertDateTime
                            ,@InsertUser)";
     SqlParameter[] spvalues = DBTool.GetSqlPm(productBill);
     int res = SqlHelper.ExecuteNonQuery(trans, CommandType.Text, sql, spvalues);
     foreach (ProductBillBody ckb in productBill.BillDetail)
     {
         ckb.HeadId = g;
         InsertDetail(ckb, trans);
     }
     return res;
 }
Exemple #2
0
 /// <summary>
 /// 更新采购单
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public int UpdateProductBill(ProductBillInfo productBill, bool changebody, SqlTransaction trans)
 {
     string sql = @"UPDATE [ProductBillHead]
                    SET [BuyNO] = @BuyNO
                       ,[BatchNO] = @BatchNO
                       ,[BuyDate] = @BuyDate
                       ,[SupplyID] = @SupplyID
                       ,[IsReview] = @IsReview
                       ,[ReviewUser] = @ReviewUser
                       ,[WareHouseID] = @WareHouseID
                       ,[Detail] = @Detail
                       ,[Define1] = @Define1
                       ,[Define2] = @Define2
                       ,[Define3] = @Define3
                       ,[UpdateDateTime] = @UpdateDateTime
                       ,[UpdateUser] = @UpdateUser
                  WHERE id=@id";
     SqlParameter[] spvalues = DBTool.GetSqlPm(productBill);
     int res = SqlHelper.ExecuteNonQuery(trans, CommandType.Text, sql, spvalues);
     if (changebody)
     {
         DeleteDetail(productBill.id, trans);
         foreach (ProductBillBody ckb in productBill.BillDetail)
         {
             InsertDetail(ckb, trans);
         }
     }
     return res;
 }
 public int InsertProductBill(ProductBillInfo productBill)
 {
     SqlConnection conn;
     int count = 0;
     using (conn = SqlHelper.CreateConntion())
     {
         conn.Open();
         SqlTransaction trans = conn.BeginTransaction();
         try
         {
             count = DAL.InsertProductBill(productBill, trans);
             trans.Commit();
         }
         catch (Exception)
         {
             trans.Rollback();
         }
         conn.Close();
     }
     return count;
 }