当前位置: 首页>>代码示例>>C#>>正文


C# dbEcustomEntities.AddTotblDeclarationVehicles方法代码示例

本文整理汇总了C#中ECustoms.DAL.dbEcustomEntities.AddTotblDeclarationVehicles方法的典型用法代码示例。如果您正苦于以下问题:C# dbEcustomEntities.AddTotblDeclarationVehicles方法的具体用法?C# dbEcustomEntities.AddTotblDeclarationVehicles怎么用?C# dbEcustomEntities.AddTotblDeclarationVehicles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ECustoms.DAL.dbEcustomEntities的用法示例。


在下文中一共展示了dbEcustomEntities.AddTotblDeclarationVehicles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Insert

 public  static int Insert(long vehicleID, long declarationID)
 {
     var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     var declarationVehicle = new tblDeclarationVehicle();
     declarationVehicle.VehicleID = vehicleID;
     declarationVehicle.DeclarationID = declarationID;
     db.AddTotblDeclarationVehicles(declarationVehicle);
     int re = db.SaveChanges();
     db.Connection.Close();
     return re;
 }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:11,代码来源:DeclarationVehicleFactory.cs

示例2: UpdateVehicle

        /// <summary>
        /// Update Vehicle
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="declerationID"></param>
        /// <returns></returns>
        public static int UpdateVehicle(tblVehicle vehicle, long declerationID)
        {
            // Set last modified date to now
            vehicle.ModifiedDate = CommonFactory.GetCurrentDate();
            var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
            switch (declerationID)
            {
                case 0:
                    {
                        // Get orgin vehicle
                        var vehicleOrgin = db.tblVehicles.Where(g => g.VehicleID == vehicle.VehicleID).FirstOrDefault();
                        if (vehicleOrgin != null)
                        {
                            db.Attach(vehicleOrgin);
                            db.ApplyPropertyChanges("tblVehicles", vehicle);

                            if (vehicle.ListVehicleChangeGood != null)
                            {
                                //update tblVehicleChange 
                                VehicleFactory.DeleteVehicleChangeByVehicleId(vehicle.VehicleID);
                                VehicleFactory.AddVehicleChangeByVehicleId(vehicle.VehicleID, vehicle.ListVehicleChangeGood.Select(x => x.VehicleId).ToList());
                            }
                            db.Connection.Close();
                            
                            int re = db.SaveChanges();
                            return re;
                        }
                        return -1;
                    }
                default:
                    {
                        var vehicleOrgin = db.tblVehicles.Where(g => g.VehicleID == vehicle.VehicleID).FirstOrDefault();
                        db.Attach(vehicleOrgin);
                        db.ApplyPropertyChanges("tblVehicles", vehicle);
                        //db.SaveChanges();
                        // Insert to tblVehicleDeclerateion
                        var vehicleDeclara = new tblDeclarationVehicle();
                        vehicleDeclara.VehicleID = vehicle.VehicleID;
                        vehicleDeclara.DeclarationID = declerationID;
                        db.AddTotblDeclarationVehicles(vehicleDeclara);
                        int re = db.SaveChanges();
                        db.Connection.Close();
                        db.Dispose();
                        return re;

                    }
            }
        }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:54,代码来源:VehicleFactory.cs

示例3: InsertVehicle

 public static int InsertVehicle(tblVehicle vehicle, long declarationID)
 {
     // Update created, last modified date by now
     var now = CommonFactory.GetCurrentDate();
     vehicle.CreatedDate = now;
     vehicle.ModifiedDate = now;
     var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     db.tblDeclarations.Where(g => g.DeclarationID == declarationID).FirstOrDefault();
     db.AddTotblVehicles(vehicle);
     db.SaveChanges();
     // Insert to tblVehicleDeclerate
     var vehicleDeclere = new tblDeclarationVehicle();
     vehicleDeclere.VehicleID = vehicle.VehicleID;
     vehicleDeclere.DeclarationID = declarationID;
     db.AddTotblDeclarationVehicles(vehicleDeclere);
     int re = db.SaveChanges();
     db.Connection.Close();
     return re;
 }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:19,代码来源:VehicleFactory.cs

示例4: 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;
        }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:74,代码来源:DeclarationFactory.cs


注:本文中的ECustoms.DAL.dbEcustomEntities.AddTotblDeclarationVehicles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。