本文整理汇总了C#中ECustoms.DAL.dbEcustomEntities.AddTotblDeclarations方法的典型用法代码示例。如果您正苦于以下问题:C# dbEcustomEntities.AddTotblDeclarations方法的具体用法?C# dbEcustomEntities.AddTotblDeclarations怎么用?C# dbEcustomEntities.AddTotblDeclarations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ECustoms.DAL.dbEcustomEntities
的用法示例。
在下文中一共展示了dbEcustomEntities.AddTotblDeclarations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddDeclaration
/// <summary>
/// Insert to Declaration and list vehicle
/// </summary>
/// <param name="declarationInfo"></param>
/// <param name="vehicleInfos"></param>
public int AddDeclaration(tblDeclaration declarationInfo, List<tblVehicle> vehicleInfos, int userID)
{
var result = -1;
var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
declarationInfo.tblUser = db.tblUsers.Where(g => g.UserID.Equals(userID)).FirstOrDefault();
// Set Created date and Last modified date
declarationInfo.CreatedDate = DateTime.Now;
declarationInfo.ModifiedDate = DateTime.Now;
db.AddTotblDeclarations(declarationInfo);
db.SaveChanges();
// Return if insert fail
if(declarationInfo.DeclarationID <= 0) return - 1;
var declarationID = declarationInfo.DeclarationID;
// Add vehicle
foreach (var vehicle in vehicleInfos)
{
vehicle.tblDeclaration = declarationInfo;
db.AddTotblVehicles(vehicle);
db.SaveChanges();
}
return result;
}
示例2: AddDeclaration
/// <summary>
/// Insert to Declaration and list vehicle
/// </summary>
/// <param name="declarationInfo"></param>
/// <param name="vehicleInfos"></param>
/// <param name="listVehicleUpdate"></param>
/// <param name="userID"></param>
public static int AddDeclaration(tblDeclaration declarationInfo, List<tblVehicle> vehicleInfos, List<tblVehicle> listVehicleUpdate, int userID)
{
var result = -1;
var currentDate = CommonFactory.GetCurrentDate();
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
//--------------Luu vào bảng tờ khai ----------------
//declarationInfo.tblUser = db.tblUsers.Where(g => g.UserID.Equals(userID)).FirstOrDefault();
// Set Created date and Last modified date
declarationInfo.CreatedDate = currentDate;
declarationInfo.ModifiedDate = currentDate;
declarationInfo.CreatedByID = userID;
db.AddTotblDeclarations(declarationInfo);
db.SaveChanges();
// Return if insert fail
if (declarationInfo.DeclarationID <= 0) return -1;
// -------- Trong trường hợp đây là tạo mới, thì add vehicle ---------------
// Add vehicle
foreach (var vehicle in vehicleInfos)
{
// Update movidifedDate and Created date
vehicle.CreatedDate = currentDate;
vehicle.ModifiedDate = currentDate;
db.AddTotblVehicles(vehicle);
db.SaveChanges();
//insert to the tblVehicleChange
List<long> listVehicleId = new List<long>();
if (vehicle.ListVehicleChangeGood != null)
{
listVehicleId= vehicle.ListVehicleChangeGood.Select(x => x.VehicleId).ToList();
}
VehicleFactory.AddVehicleChangeByVehicleId(vehicle.VehicleID, listVehicleId);
// Insert to the tblVehicleDeclerateion
var vehicleDeclara = new tblDeclarationVehicle();
vehicleDeclara.VehicleID = vehicle.VehicleID;
vehicleDeclara.DeclarationID = declarationInfo.DeclarationID;
db.AddTotblDeclarationVehicles(vehicleDeclara);
db.SaveChanges();
// Add data to tblDecleVehicle
}
// -------- Trong trường hợp đây là cập nhật, thì add vehicle ---------------
// Update the vehicle
if (listVehicleUpdate.Count > 0)
{
foreach (var vehicle in listVehicleUpdate)
{
// Update Vehicle info
VehicleFactory.UpdateVehicle(vehicle, 0);
// Add to tblDeclerateVehcle
var declerartionTem =
db.tblDeclarations.Where(g => g.DeclarationID == declarationInfo.DeclarationID).FirstOrDefault();
var vehicleDeclara = new tblDeclarationVehicle();
vehicleDeclara.VehicleID = vehicle.VehicleID;
vehicleDeclara.DeclarationID = declerartionTem.DeclarationID;
db.AddTotblDeclarationVehicles(vehicleDeclara);
db.SaveChanges();
}
}
db.Connection.Close();
return result;
}