示例#1
0
        public static bool UpdateProperty(PropertyDTO pd)
        {
            using (ArgamanExpressEntities db = new ArgamanExpressEntities())
            {
                Property p = db.Properties.Find(pd.PropertyID);

                p.OwnerID          = pd.OwnerID;
                p.CityID           = pd.CityID;
                p.StreetID         = pd.StreetID;
                p.Number           = pd.Number;
                p.Size             = pd.Size;
                p.Floor            = pd.Floor;
                p.IsDivided        = pd.IsDivided;
                p.ManagmentPayment = pd.ManagmentPayment;
                p.IsPaid           = pd.IsPaid;
                p.IsExclusivity    = pd.IsExclusivity;
                p.ExclusivityID    = pd.ExclusivityID;
                p.IsWarranty       = pd.IsWarranty;
                p.IsRented         = pd.IsRented;
                p.RoomsNum         = pd.RoomsNum;
                p.ApartmentNum     = pd.ApartmentNum;
                if (pd.Dock != null)
                {
                    Document doc = new Document();
                    doc.DocCoding = pd.Dock;
                    doc.DocUser   = pd.PropertyID;
                    doc.type      = 1;
                    doc.DocName   = pd.DocName;
                    DocumentBL.AddUserDocuments(new DocumentDTO(doc));
                }
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
示例#2
0
        public static bool UpdateSubProperty(SubPropertyDTO spd)
        {
            using (ArgamanExpressEntities db = new ArgamanExpressEntities())
            {
                SubProperty sp = db.SubProperties.Find(spd.SubPropertyID);


                sp.num      = spd.num;
                sp.IsRented = spd.IsRented;
                sp.Size     = spd.Size;
                sp.RoomsNum = spd.RoomsNum;
                if (spd.Dock != null)
                {
                    Document doc = new Document();
                    doc.DocCoding = spd.Dock;
                    doc.DocUser   = spd.SubPropertyID;
                    doc.type      = 5;
                    doc.DocName   = spd.DocName;
                    DocumentBL.AddUserDocuments(new DocumentDTO(doc));
                }
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
示例#3
0
 public static bool DailySet()
 {
     try
     {
         using (ArgamanExpressEntities db = new ArgamanExpressEntities())
         {
             foreach (Dal.Task task in db.Tasks)
             {
                 if (task.IsHandled != true && task.ClassificationID != null)
                 {
                     if (task.DateForHandling.Date <= DateTime.Now.Date || (task.TaskTypeId != 1 && task.TaskTypeId != 4 && (task.DateForHandling.Date - DateTime.Now.Date).Days <= 30))
                     {
                         task.ClassificationID = 1;
                     }
                     else if (task.ClassificationID != 1 && ((task.DateForHandling.Date - DateTime.Now.Date).Days <= 7 || (task.TaskTypeId != 1 && task.TaskTypeId != 4 && (task.DateForHandling.Date - DateTime.Now.Date).Days <= 60)))
                     {
                         task.ClassificationID = 2;
                     }
                 }
             }
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
示例#4
0
 public static bool UpdatePropertyOwner(PropertyOwnerDTO po)
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         PropertiesOwner pro = db.PropertiesOwners.Find(po.OwnerID);
         pro.OwnerID           = p.OwnerID;
         pro.CityID            = p.CityID;
         this.CityName         = p.CityName;
         this.StreetID         = p.StreetID;
         this.StreetName       = p.StreetName;
         this.Number           = p.Number;
         this.Size             = p.Size;
         this.Floor            = p.Floor;
         this.IsDivided        = p.IsDivided;
         this.ManagmentPayment = p.ManagmentPayment;
         this.IsPaid           = p.IsPaid;
         this.IsExclusivity    = p.IsExclusivity;
         this.ExclusivityID    = p.ExclusivityID;
         this.IsWarranty       = p.IsWarranty;
         this.IsRented         = p.IsRented;
         this.RoomsNum         = p.RoomsNum;
         this.ApartmentNum     = p.ApartmentNum;
         db.SaveChanges();
         return(true);
     }
     return(false);
 }
示例#5
0
 public static bool DeleteProperty(int id)
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         Property p = db.Properties.Find(id);
         p.status = false;
         db.SaveChanges();
         return(true);
     }
     return(false);
 }
示例#6
0
 public static bool DeleteTask(int id)
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         Dal.Task t = db.Tasks.Find(id);
         t.status = false;
         db.SaveChanges();
         return(true);
     }
     return(false);
 }
示例#7
0
文件: RentalBL.cs 项目: leahr0040/C-
 public static bool DeleteRental(int id)
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         Rental p = db.Rentals.Find(id);
         p.Property.IsRented = false;
         p.status            = false;
         db.SaveChanges();
         return(true);
     }
     return(false);
 }
示例#8
0
 public static bool AddTaskType(string name)
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         TaskType taskType = new TaskType();
         taskType.TaskTypeName = name;
         db.TaskTypes.Add(taskType);
         db.SaveChanges();
         return(true);
     }
     return(false);
 }
示例#9
0
        public static bool DeleteUser(int id)
        {
            using (ArgamanExpressEntities db = new ArgamanExpressEntities())
            {
                User t = db.Users.Find(id);
                t.status = false;

                db.SaveChanges();
                return(true);
            }
            return(false);
        }
示例#10
0
 public static bool UpdatePropertyOwner(PropertyOwnerDTO po)
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         Property pro = db.Properties.Find(po.OwnerID);
         pro.OwnerFirstName = po.OwnerFirstName;
         pro.OwnerLastName  = po.OwnerLastName;
         pro.Phone          = po.Phone;
         pro.Email          = po.Email;
         db.SaveChanges();
         return(true);
     }
     return(false);
 }
示例#11
0
文件: RentalBL.cs 项目: leahr0040/C-
 //    static System.Timers.Timer timer;
 public static void DeleteAllNotUsedRentals()
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         foreach (Rental rental in db.Rentals)
         {
             if (rental.status == false)
             {
                 db.Rentals.Remove(rental);
             }
         }
         db.SaveChanges();
     }
 }
示例#12
0
        //        static System.Timers.Timer timer;
        //        public static void schedule_Timer(DateTime scheduledTime)
        //        {

        //            DateTime nowTime = DateTime.Now;
        //            //DateTime scheduledTime = DateTime.Now.AddSeconds(15); //new DateTime((nowTime.Year, nowTime.Month, nowTime.Day, 8, 42, 0, 0); //Specify your scheduled time HH,MM,SS [8am and 42 minutes]
        //            if (nowTime > scheduledTime)
        //            {
        //                scheduledTime = scheduledTime.AddMonths(1);
        //            }
        ////double tickTime = (double)(scheduledTime - DateTime.Now).TotalMilliseconds;
        //            timer = new System.Timers.Timer(1000*60*60*24*5);
        //            timer.Elapsed += new ElapsedEventHandler(DeleteAllNotUsedTasks);
        //            timer.Start();
        //        }
        public static void DeleteAllNotUsedTasks()
        {
            using (ArgamanExpressEntities db = new ArgamanExpressEntities())
            {
                foreach (Dal.Task task in db.Tasks)
                {
                    if (task.status == false)
                    {
                        db.Tasks.Remove(task);
                    }
                }
                db.SaveChanges();
            }
        }
示例#13
0
 public static bool SetClassification(int id, int classificationId)
 {
     try
     {
         using (ArgamanExpressEntities db = new ArgamanExpressEntities())
         {
             Dal.Task task = db.Tasks.Find(id);
             task.ClassificationID = classificationId;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
示例#14
0
文件: RentalBL.cs 项目: leahr0040/C-
        public static bool UpdateRental(RentalDTO rd)
        {
            using (ArgamanExpressEntities db = new ArgamanExpressEntities())
            {
                Rental r = db.Rentals.Find(rd.RentalID);
                r.PropertyID    = rd.PropertyID;
                r.SubPropertyID = rd.SubPropertyID;
                r.UserID        = rd.UserID;
                r.RentPayment   = rd.RentPayment;
                r.PaymentTypeID = rd.PaymentTypeID;
                r.EnteryDate    = rd.EnteryDate;
                r.EndDate       = rd.EndDate;
                if (r.ContactRenew != rd.ContactRenew)
                {
                    if (rd.ContactRenew == true && rd.EndDate.Value < DateTime.Today.AddMonths(3))
                    {
                        Bl.TaskBL.AddRenewTask(rd.PropertyID, rd.SubPropertyID);
                    }
                    else
                    {
                        getAllTasks_Result task = db.getAllTasks().Where(t => t.PropertyID == rd.PropertyID && t.TaskTypeId == 2 && t.status == true && t.SubPropertyID == rd.SubPropertyID).FirstOrDefault();
                        if (task != null)
                        {
                            Bl.TaskBL.DeleteTask(task.TaskID);
                        }
                    }
                }
                r.ContactRenew = rd.ContactRenew;

                if (rd.Dock != null)
                {
                    Document doc = new Document();
                    doc.DocCoding = rd.Dock;
                    doc.DocUser   = rd.RentalID;
                    doc.type      = 3;
                    doc.DocName   = rd.DocName;
                    DocumentBL.AddUserDocuments(new DocumentDTO(doc));
                }
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
示例#15
0
        public static bool UpdateTask(TaskDTO td)
        {
            using (ArgamanExpressEntities db = new ArgamanExpressEntities())
            {
                Dal.Task t = db.Tasks.Find(td.TaskID);


                t.TaskTypeId             = td.TaskTypeId;
                t.Description            = td.Description;
                t.PropertyID             = td.PropertyID;
                t.SubPropertyID          = td.SubPropertyID;
                t.ClassificationID       = td.ClassificationID;
                t.ClientClassificationID = td.ClientClassificationID;
                t.ReportDate             = td.ReportDate;
                t.DateForHandling        = td.DateForHandling;
                t.IsHandled = td.IsHandled;
                if (td.IsHandled == true)
                {
                    t.status = false;
                }
                else
                {
                    t.status = true;
                }

                t.HandlingDate = td.HandlingDate;
                t.HandlingWay  = td.HandlingWay;
                if (td.Dock != null)
                {
                    Document doc = new Document();
                    doc.DocCoding = td.Dock;
                    doc.DocUser   = td.TaskID;
                    doc.type      = 6;
                    doc.DocName   = td.DocName;
                    DocumentBL.AddUserDocuments(new DocumentDTO(doc));
                    return(true);
                }
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
示例#16
0
 public static bool UpdateUser(UserDTO ud)
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         bool b = false;
         User u = db.Users.Find(ud.UserID);
         if ((u.Email != ud.Email) || (u.UserName != ud.UserName) || (u.Password != ud.Password))
         {
             b = true;
         }
         if ((ud.UserName == null) || (ud.Password == null) || (ud.UserName == ""))
         {
             Random rand = new Random();//הגרלה לא תקינה
             int    i    = rand.Next(100000, 999999);
             if (ud.Email != null)
             {
                 ud.UserName = ud.Email;
                 ud.Password = ud.Email.Substring(0, 2) + i.ToString();
             }//יותר לפי firstname
             else
             {
                 ud.UserName = ud.FirstName.Substring(1, 4) + ud.LastName.Substring(1, 4);
                 ud.Password = ud.UserName.Substring(1, 3) + i.ToString();
             }
         }
         u.FirstName = ud.FirstName;
         u.LastName  = ud.LastName;
         u.SMS       = ud.SMS;
         u.Email     = ud.Email;
         u.Phone     = ud.Phone;
         u.RoleID    = ud.RoleID;
         u.UserName  = ud.UserName;
         u.Password  = ud.Password;
         if (b == true)//עוד בלי אופציית SMS
         {
             Mailsend.Mailnewuser(ud);
         }
         db.SaveChanges();
         return(true);
         //return false;
     }
 }
示例#17
0
        public static bool Forgotpassword(string username, string mail)
        {
            //פונקצייה חיפוש עפי מייל קיים
            //Mailsend.Mailforgotpasword()
            using (ArgamanExpressEntities db = new ArgamanExpressEntities())
            {
                User u = (from a in db.Users where username == a.UserName && mail == a.Email select a).FirstOrDefault();


                if (u != null)
                {
                    Random rand = new Random();
                    int    i    = rand.Next(100000, 999999);
                    u.Password = u.UserName.Substring(0, 2) + i.ToString();
                    db.SaveChanges();
                    Mailsend.Mailforgotpasword(u);
                    return(true);
                }
                return(false);
            }
        }
示例#18
0
 public static bool UpdatePassword(UserDTO ud)//שינוי סיסמה
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         Random rand = new Random();//הגרלה לא תקינה
         int    i    = rand.Next(100000, 999999);
         //User u = UserDTO.ToDal(ud);
         if (ud.Email != null)
         {
             ud.UserName = ud.Email;
             ud.Password = ud.Email.Substring(0, 2) + i.ToString();
         }//יותר לפי firstname
         else
         {
             ud.UserName = ud.FirstName.Substring(1, 4) + ud.LastName.Substring(1, 4);
             ud.Password = ud.UserName.Substring(2, 5) + i.ToString();
         }
         Mailsend.Mailnewuser(ud);
         db.SaveChanges();
         return(true);
     }
 }
示例#19
0
 public static bool UpdatePropertyOwner(PropertyOwnerDTO po)
 {
     using (ArgamanExpressEntities db = new ArgamanExpressEntities())
     {
         PropertiesOwner pro = db.PropertiesOwners.Find(po.OwnerID);
         pro.OwnerFirstName = po.OwnerFirstName;
         pro.OwnerLastName  = po.OwnerLastName;
         pro.Phone          = po.Phone;
         pro.Email          = po.Email;
         if (po.Dock != null)
         {
             Document doc = new Document();
             doc.DocCoding = po.Dock;
             doc.DocUser   = po.OwnerID;
             doc.type      = 2;
             doc.DocName   = po.DocName;
             DocumentBL.AddUserDocuments(new DocumentDTO(doc));
         }
         db.SaveChanges();
         return(true);
     }
     return(false);
 }