本文整理汇总了C#中DataContext.AnnonContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# AnnonContext.SaveChanges方法的具体用法?C# AnnonContext.SaveChanges怎么用?C# AnnonContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataContext.AnnonContext
的用法示例。
在下文中一共展示了AnnonContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: copyCurrentToOrder
/// <summary>
/// 将临时表中的数据复制到订单中
/// </summary>
/// <param name="orderId"></param>
/// <returns></returns>
public static int copyCurrentToOrder(int orderId)
{
using (var context = new AnnonContext())
{
try
{
//先删除已有orderId的订单
deleteOrder(orderId);
var unitOrders = context.UnitCurrentValues
.Where(s => s.OrderId == orderId);
//将临时表中的数据复制到订单表中
foreach (var unitOrder in unitOrders)
{
context.UnitOrders.Add(new UnitOrder
{
PropertyName = unitOrder.PropertyName,
Value = unitOrder.Value,
OrderId = unitOrder.OrderId,
});
}
////删除临时表中的数据
//foreach (var uo in unitOrders)
//{
// context.UnitCurrentValues.Remove(uo);
//}
return context.SaveChanges();
}
catch (Exception e)
{
return -1;
}
}
}
示例2: CopyOrderDetail
//复制详细订单信息;
public static int CopyOrderDetail(int OrderDtIfID,int newOrderID)
{
using (var context = new AnnonContext())
{
try
{
var od1 = context.orderDetailInfoes
.Where(s => s.orderDetailInfoID == OrderDtIfID)
.First();
orderDetailInfo od2 = new orderDetailInfo
{
OrderInfoId = od1.OrderInfoId,
OrderDetailNo = newOrderID,
Qty = od1.Qty,
custPrice = od1.custPrice,
listPrice = od1.listPrice,
RepPrice = od1.RepPrice,
tag = od1.tag,
ProDes = od1.ProDes,
OrderInfoType=od1.OrderInfoType,
OdDetlNum=ReturnLastNum()+1,
DeviceId=od1.DeviceId
};
context.orderDetailInfoes.Add(od2);
return context.SaveChanges();
}
catch (System.Exception ex)
{
return -1;
}
}
}
示例3: CopyOrder
//复制一条订单;
public static int CopyOrder(int orderID)
{
using (var context = new AnnonContext())
{
try
{
var ois = context.ordersinfoes
.Where(s => s.ordersinfoID == orderID)
.First();
ordersinfo oi = new ordersinfo
{
OrderNo=ReturnLastNum()+1,
JobNum = ois.JobNum,
JobName = ois.JobName,
JobDes = ois.JobDes,
Site = ois.Site,
Customer = ois.Customer,
Activity = ois.Activity,
AAonCon = ois.AAonCon,
};
context.ordersinfoes.Add(oi);
return context.SaveChanges();
}
catch (Exception e)
{
return -1;
}
}
}
示例4: copyOrder
/// <summary>
/// 拷贝订单
/// </summary>
/// <param name="orderId"></param>
/// <returns></returns>
public static int copyOrder(int orderId)
{
using (var context = new AnnonContext())
{
try
{
int newOrderId = 1;
var currentOrder = context.UnitOrders
.Select(s => s.OrderId);
if (currentOrder.Count() != 0)
newOrderId = currentOrder.Max() + 1;
var catlogOrders = context.UnitOrders
.Where(s => s.OrderId == orderId);
foreach (var catlog in catlogOrders)
{
context.UnitOrders.Add(new UnitOrder
{
PropertyName = catlog.PropertyName,
OrderId = newOrderId,
Value = catlog.Value
});
}
context.SaveChanges();
return newOrderId;
}
catch (Exception e)
{
return -1;
}
}
}
示例5: copyCurrentToOrder
/// <summary>
/// 将临时表复制到订单表中,在最终需要到订单时保存时需要
/// </summary>
/// <param name="orderId"></param>
/// <returns></returns>
public static int copyCurrentToOrder(int orderId)
{
using (var context = new AnnonContext())
{
try
{
//先要删除对应orderId的订单
deleteOrder(orderId);
var contentCurrentValues = context.ContentCurrentValues
.Where(s => s.OrderID == orderId);
//将临时表数据复制到订单中
foreach (var ccv in contentCurrentValues)
{
context.ContentOrders.Add(new ContentOrder
{
ModuleTag = ccv.ModuleTag,
PropertyName = ccv.PropertyName,
Value = ccv.Value,
ImageName = ccv.ImageName,
CoolingPower = ccv.CoolingPower,
OrderID = ccv.OrderID,
Guid=ccv.Guid,
Price=ccv.Price,
Items=ccv.Items
});
}
return context.SaveChanges();
}
catch (Exception e)
{
return -1;
}
}
}
示例6: deleteOrder
/// <summary>
/// 删除制定订单
/// </summary>
/// <param name="accessoryId"></param>
/// <returns></returns>
public static int deleteOrder(int accessoryId)
{
using (var context = new AnnonContext())
{
try
{
var accessoryOrder = context.AccessoryOrders
.Where(s => s.AccessoryOrderID == accessoryId)
.First();
context.AccessoryOrders.Remove(accessoryOrder);
return context.SaveChanges();
}
catch (Exception e)
{
return -1;
}
}
}
示例7: DeleteAll
/// <summary>
/// 删除约束中的所有内容
/// 可用
/// </summary>
/// <returns></returns>
public static int DeleteAll()
{
using (var context = new AnnonContext())
{
try
{
var propertyConstraints = context.PropertyConstraints;
foreach (var propertyConstraint in propertyConstraints)
{
context.PropertyConstraints.Remove(propertyConstraint);
}
return context.SaveChanges();
}
catch (Exception e)
{
return -1;
}
}
}
示例8: DeleteAllCurrentDevices
public static void DeleteAllCurrentDevices(int orderId, int deviceId)
{
using (var context = new AnnonContext())
{
try
{
var currentDevices = context.CurrentDevices
.Where(s => s.DeviceID == deviceId
&& s.OrderDetailID == orderId);
foreach (var currentDevice in currentDevices)
{
context.CurrentDevices.Remove(currentDevice);
}
context.SaveChanges();
}
catch (Exception e)
{
}
}
}
示例9: DeleteAll
/// <summary>
/// 删除数据库中所有的图块信息
/// </summary>
/// <returns></returns>
public static int DeleteAll()
{
using (var context = new AnnonContext())
{
try
{
var imageBlocks = context.ImageBlocks;
foreach (var imageBlock in imageBlocks)
{
context.ImageBlocks.Remove(imageBlock);
}
return context.SaveChanges();
}
catch (Exception e)
{
return -1;
}
}
}
示例10: DeleteAllOrder
//删除所有订单数据;
public static int DeleteAllOrder()
{
using (var context = new AnnonContext())
{
try
{
var ois = context.ordersinfoes;
foreach (var os in ois)
{
context.ordersinfoes.Remove(os);
}
//context.ordersinfoes.Remove(ois);
return context.SaveChanges();
}
catch (Exception e)
{
return -1;
}
}
}
示例11: DeleteAllOrderDetail
//删除所有详细订单信息;
public static int DeleteAllOrderDetail()
{
using (var context = new AnnonContext())
{
try
{
var od = context.orderDetailInfoes;
foreach (var odd in od)
{
context.orderDetailInfoes.Remove(odd);
}
return context.SaveChanges();
}
catch (System.Exception ex)
{
return -1;
}
}
}
示例12: copyOrder
/// <summary>
/// 拷贝订单
/// </summary>
/// <param name="orderId"></param>
/// <param name="newOrderId"></param>
/// <returns></returns>
public static int copyOrder(int orderId, int newOrderId)
{
using (var context = new AnnonContext())
{
try
{
var imageModels = context.ImageModels
.Where(s => s.OrderId == orderId);
foreach (var imageModel in imageModels)
{
context.ImageModels.Add(new ImageModel
{
Name=imageModel.Name,
X=imageModel.X,
Y=imageModel.Y,
Width=imageModel.Width,
Height=imageModel.Height,
Url=imageModel.Url,
Type=imageModel.Type,
Text=imageModel.Text,
coolingType=imageModel.coolingType,
FirstDance=imageModel.FirstDance,
SecondDance=imageModel.SecondDance,
ModuleTag=imageModel.ModuleTag,
OrderId=newOrderId,
IsSelected=imageModel.IsSelected,
ParentName=imageModel.ParentName,
Guid=imageModel.Guid
});
}
return context.SaveChanges();
}
catch (Exception e)
{
return -1;
}
}
}
示例13: InsertIntoCurrentDevice
/// <summary>
/// 添加当前设备
/// </summary>
/// <param name="deviceId">设备ID</param>
/// <param name="propertyId">属性ID</param>
/// <param name="propertyValueArray">属性值列表</param>
/// <param name="orderDetailId">订单ID</param>
/// <param name="propertyValueId">属性当前取值</param>
public static void InsertIntoCurrentDevice(int deviceId,int propertyId,string propertyValueArray,int orderDetailId,int propertyValueId)
{
var currentDevice = new CurrentDevice
{
DeviceID = deviceId,
PropertyID = propertyId,
PropertyValueArray = propertyValueArray,
OrderDetailID = orderDetailId,
PropertyValueId = propertyValueId
};
using (var context = new AnnonContext())
{
try
{
context.CurrentDevices.Add(currentDevice);
context.SaveChanges();
}
catch (Exception e)
{
}
}
}
示例14: deleteAll
/// <summary>
/// 删除所有数据
/// </summary>
/// <returns></returns>
public static int deleteAll()
{
using (var context = new AnnonContext())
{
try
{
var accessories = context.Accessories;
if (accessories != null && accessories.Count() != 0)
{
foreach (var accessory in accessories)
{
context.Accessories.Remove(accessory);
}
return context.SaveChanges();
}
return 0;
}
catch (Exception e)
{
return -1;
}
}
}
示例15: deleteOrder
/// <summary>
/// 删除某个订单号的订单
/// </summary>
/// <param name="orderId"></param>
/// <returns></returns>
public static int deleteOrder(int orderId)
{
using (var context = new AnnonContext())
{
try
{
var imageModels = context.ImageModels
.Where(s => s.OrderId == orderId);
if (imageModels != null && imageModels.Count() != 0)
{
foreach (var imageModel in imageModels)
{
context.ImageModels.Remove(imageModel);
}
return context.SaveChanges();
}
return 0;
}
catch (Exception e)
{
return -1;
}
}
}