예제 #1
0
 /// <summary>
 /// Update Vehicle
 /// </summary>
 /// <param name="vehicle"></param>
 /// <returns></returns>
 public static int UpdateVehicle(tblVehicle vehicle )
 {
     var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     // Get orgin vehicle
     var vehicleOrgin = db.tblVehicles.Where(g => g.VehicleID == vehicle.VehicleID).FirstOrDefault();
     db.Attach(vehicleOrgin);
     db.ApplyPropertyChanges("tblVehicles", vehicle);
     return db.SaveChanges();
 }
예제 #2
0
 /// <summary>
 /// update declaration
 /// </summary>
 /// <param name="declaration"></param>
 /// <param name="modifiedByID"></param>
 /// <returns></returns>
 public static int Update(tblDeclaration declaration)
 {
     var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     declaration.ModifiedDate = DateTime.Now;
     // Get orgin object
     var objOrginDeclaration = db.tblDeclarations.Where(g => g.DeclarationID.Equals(declaration.DeclarationID)).FirstOrDefault();
     db.Attach(objOrginDeclaration);
     db.ApplyPropertyChanges("tblDeclarations", declaration);
     return db.SaveChanges();
 }
 public static int Update(tblVehicleCheck vehicleCheck)
 {
     var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));            
     // Get orgin object
     var objOrginVehicleCheck = db.tblVehicleChecks.Where(g => g.VehicleCheckID == vehicleCheck.VehicleCheckID).FirstOrDefault();
     db.Attach(objOrginVehicleCheck);
     db.ApplyPropertyChanges("tblVehicleChecks", vehicleCheck);
     int re = db.SaveChanges();
     db.Connection.Close();
     return re;        
 }
예제 #4
0
 public static int Update(tblGroup group)
 {          
   var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
   var groupOrgin = db.tblGroups.Where(g => g.GroupID == group.GroupID).FirstOrDefault();
   if (groupOrgin == null) return -1;
   db.Attach(groupOrgin);
   db.ApplyPropertyChanges("tblGroups", group);
   int re = db.SaveChanges();
   db.Connection.Close();
   return re;
 }
예제 #5
0
 public static int Update(tblCheck check)
 {
     check.ModifedDate = CommonFactory.GetCurrentDate();
     var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     var checkOrgin = db.tblChecks.Where(g => g.CheckID == check.CheckID).FirstOrDefault();
     if (checkOrgin == null) return -1;
     db.Attach(checkOrgin);
     db.ApplyPropertyChanges("tblChecks", check);
     int re = db.SaveChanges();
     db.Connection.Close();
     return re;
 }
 public static int Update(tblDeclarationLoan loan)
 {
     var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     loan.ModifiedDate = CommonFactory.GetCurrentDate();
     // Get orgin object
     var objOrginDeclaration = db.tblDeclarationLoans.Where(g => g.ID.Equals(loan.ID)).FirstOrDefault();
     db.Attach(objOrginDeclaration);
     db.ApplyPropertyChanges("tblDeclarationLoans", loan);
     int re = db.SaveChanges();
     db.Connection.Close();
     return re;
 }
예제 #7
0
        public static int Update(tblTrain train)
        {
            var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
            train.ModifiedDate = CommonFactory.GetCurrentDate();
            var originTrain = _db.tblTrains.Where(g => g.TrainID == train.TrainID).FirstOrDefault();

            if (originTrain == null)
            {
                return -1;
            }
            _db.Attach(originTrain);
            _db.ApplyPropertyChanges("tblTrains", train);
            
            return _db.SaveChanges();
        }
        /// <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;

                    }
            }
        }
예제 #9
0
        /// <summary>
        /// Update user
        /// </summary>
        /// <param name="userInfo">userInfo object</param>
        /// <returns>Number of rows are effected</returns>
        public static int Update(tblUser userInfo)
        {
            // Encode password & username
            userInfo.Password = Common.Encode(userInfo.Password);

            var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
            var usrOrgin = db.tblUsers.Where(g => g.UserID == userInfo.UserID).FirstOrDefault();
            if (usrOrgin == null) return -1;
            db.Attach(usrOrgin);
            db.ApplyPropertyChanges("tblUsers", userInfo);
            int re = db.SaveChanges();
            db.Connection.Close();
            return re;
        }