Example #1
0
        public static bool NewContract(Contract Ct)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.ProxyCreationEnabled = false;
                db.Configuration.LazyLoadingEnabled = false;
                db.Contracts.Add(Ct);
                db.SaveChanges();
                return true;

            }
            catch (Exception ex)
            {
               
                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                File.WriteAllText("t.txt", ex.InnerException.InnerException.Message);
                e.UserDescription = "Error in Save Changed";
                if (ex.InnerException.InnerException.Message.Contains("Violation of PRIMARY KEY constraint 'PK_Contracts'. Cannot insert duplicate key in object 'dbo.Contracts'"))
                {
                    e.UserDescriptionArabic = "الموظف موجود عقده في المشروع مسبقا";

                }
                else
                    e.UserDescriptionArabic = e.OtherDescription;//"خطاء في اضافة البيانات";
               
                 throw e;
            }
        }
        public static bool EditTheDonorsProject(TheDonorsProject tb)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;
                var q = db.TheDonorsProjects.Where(p => p.ID == tb.ID).SingleOrDefault();
                q.DonorsID = tb.DonorsID;
                q.TotalCost = tb.TotalCost;
                db.SaveChanges();
                return true;

            }
            catch (Exception ex)
            {

                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                File.WriteAllText("t.txt", ex.InnerException.InnerException.Message);
                e.UserDescription = "Error in Save Changed";
                if (ex.InnerException.InnerException.Message.Contains("Violation of PRIMARY KEY constraint 'PK_TheDonorsProjects'. Cannot insert duplicate key in object 'dbo.TheDonorsProjects'"))
                {
                    e.UserDescriptionArabic = "الممول مضاف مسبقا للمشروع";

                }
                else
                    e.UserDescriptionArabic = e.OtherDescription;//"خطاء في اضافة البيانات";

                throw e;
            }
        }
      public static bool EditProjectProfile(ProjectProfile ptb)
         
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;
                var q = db.ProjectProfiles.Where(p => p.ID == ptb.ID).SingleOrDefault();
                q.ProjectName = ptb.ProjectName;
                q.ProjectDescription = ptb.ProjectDescription;
                q.StartDate = ptb.StartDate;
                q.EndDate = ptb.EndDate;
                q.Status = ptb.Status;
                q.Coin = ptb.Coin;
                q.TotalCost = ptb.TotalCost;
               
                db.SaveChanges();
                return true;

            }
            catch (Exception ex)
            {


                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                e.UserDescription = "Error in Add";
                e.UserDescriptionArabic = "خطاء في اضافة البيانات";
                throw e;
            }
        }
        public static bool EditProjectExpens(ProjectExpens tb)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;
                var q = db.ProjectExpenses.Where(p => p.ID == tb.ID).SingleOrDefault();
                q.ExpensesName = tb.ExpensesName;
                q.DateofProcess = tb.DateofProcess;
                q.BillNumber = tb.BillNumber;
                q.RequiarAmount = tb.RequiarAmount;
                q.CashingNumber = tb.CashingNumber;
                q.ProjectSubActivity_ID = tb.ProjectSubActivity_ID;
                q.Supplier_ID = tb.Supplier_ID;


                db.SaveChanges();
                return true;

            }
            catch (Exception ex)
            {


                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                e.UserDescription = "Error in Save Changed";
                e.UserDescriptionArabic = "خطاء في حفظ البيانات";
                throw e;
            }
        }
Example #5
0
 public static List<Supplier> GetAll()
 {
     db = new UcasProEntities();
     db.Configuration.LazyLoadingEnabled = false;
     db.Configuration.ProxyCreationEnabled = false;
     return db.Suppliers.ToList();
 }
Example #6
0
        public static bool EditSubActivity(ProjectSubActivity SActv)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;
                var q = db.ProjectSubActivities.Where(p => p.ID == SActv.ID).SingleOrDefault();
                q.SubActivityName = SActv.SubActivityName;
                q.Description = SActv.Description;
                q.Startdate = SActv.Startdate;
                q.enddate = SActv.enddate;
                q.TotalCost = SActv.TotalCost;
                q.Status = SActv.Status;
                q.Progress = SActv.Progress;

                db.SaveChanges();
                return true;

            }
            catch (Exception ex)
            {

                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                e.UserDescription = "Error in Save Changed";
                e.UserDescriptionArabic = "خطاء في حفظ البيانات";  
                throw e;
               
            }
        }
        public static bool AddTheTheDonorsProject(TheDonorsProject tb)
        {
            try
            {
                db = new UcasProEntities();
                db.TheDonorsProjects.Add(tb);
                db.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {

                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                File.WriteAllText("t.txt", ex.InnerException.InnerException.Message);
                e.UserDescription = "Error in Save Changed";
                if (ex.InnerException.InnerException.Message.Contains("Violation of PRIMARY KEY constraint 'PK_TheDonorsProjects'. Cannot insert duplicate key in object 'dbo.TheDonorsProjects'"))
                {
                    e.UserDescriptionArabic = "الممول مضاف مسبقا للمشروع";

                }
                else
                    e.UserDescriptionArabic = e.OtherDescription;//"خطاء في اضافة البيانات";

                throw e;
            }
        }
Example #8
0
        public static int GetLastId()
        {
            db = new UcasProEntities();

            int  q = (from i in db.Employees select i.ID).Max();
            return q;
        }
 public static List<AmountsReceived> GetAllAmountsReceived()
 {
     db = new UcasProEntities();
     db.Configuration.LazyLoadingEnabled = false;
     db.Configuration.ProxyCreationEnabled = false;
     return db.AmountsReceiveds.ToList();
 }
Example #10
0
        public static bool EditSalary(Monthlysalary tb)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;
                var q = db.Monthlysalaries.Where(p => p.ID == tb.ID).SingleOrDefault();
                q.ContractID = tb.ContractID;
                q.IssueDate = tb.IssueDate;
                q.Amount = tb.Amount;
                q.Formonth = tb.Formonth;
               

                db.SaveChanges();
                return true;

            }
            catch (Exception ex)
            {


                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                e.UserDescription = "Error in Save Changed";
                e.UserDescriptionArabic = "خطاء في حفظ البيانات";
                throw e;
            }
        }
Example #11
0
        public static bool EditContract(Contract Ct)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;
                var q = db.Contracts.Where(p => p.ID == Ct.ID).SingleOrDefault();
                q.Employee_ID = Ct.Employee_ID;
                q.TotalSalary = Ct.TotalSalary;
                q.SelaryAmount = Ct.SelaryAmount;
                q.StartDate = Ct.StartDate;
                q.EndDate = Ct.EndDate;
                q.Status = Ct.Status;
                
                db.SaveChanges();
                return true;

            }
            catch (Exception ex)
            {


                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                e.UserDescription = "Error in Save Changed";
                e.UserDescriptionArabic = "خطاء في حفظ البيانات";
                throw e;
            }
        }
Example #12
0
 public static List<UserTb> GetAllUsersToProjects()
 {
     db = new UcasProEntities();
     var lst = (from p in db.UserTbs
                where p.TypeUser=="منسق"||p.TypeUser=="محاسب"
                 select p).ToList();
     return lst;
 }
Example #13
0
       public static List<UserTb> GetAllUsers()
       {
           db = new UcasProEntities();
           var lst = (from p in db.UserTbs

                      select p).ToList();
           return lst;
       }
Example #14
0
   public static List<Attachment> GetGetAllAttachmentByproID(int ProID)
 {
     db = new UcasProEntities();
     
     var LST = (from c in db.Attachments
                where c.ProjectProfile_ID == ProID
                select c).ToList();
     return LST;
 }
Example #15
0
 public static bool AddDonor(TheDonor tb)
 {
     db = new UcasProEntities();
     db.Configuration.LazyLoadingEnabled = false;
     db.Configuration.ProxyCreationEnabled = false;
     db.TheDonors.Add(tb);
     db.SaveChanges();
     return true;
 }
Example #16
0
       public static bool NewUser(UserTb tb)
       {

           db = new UcasProEntities();

           db.UserTbs.Add(tb);
           db.SaveChanges();
           return true;

       }
Example #17
0
        public static bool addEmployee(Employee emp)
        {
            
                db = new UcasProEntities();
                
                db.Employees.Add(emp);
                db.SaveChanges();
                return true;

          
        }
Example #18
0
        public static bool NewAttachment(Attachment tb)
        {
           
                db = new UcasProEntities();
                //db.Configuration.ProxyCreationEnabled = false;
                // db.Configuration.LazyLoadingEnabled = false;
                db.Attachments.Add(tb);
                db.SaveChanges();
                return true;

        }
        public static List<TheDonorsProject> GetAllDonorsByproID(int ProID)
        {
            db = new UcasProEntities();

            var LST = (from c in db.TheDonorsProjects
                       where c.ProjectID == ProID
                       select c).ToList();
            return LST;


        }
Example #20
0
        public static List<ProjectProfile> AlertAllProjectsEnded()
        {
            DateTime CheckerDate = DateTime.Now.AddDays(3);

            db = new UcasProEntities();
            var LST = (from p in db.ProjectProfiles
                       orderby p.StartDate ascending
                       where p.EndDate == CheckerDate 
                       select p).ToList();
            return LST;
        }
Example #21
0
 public static List<Contract> AlertAllContractsEnded()
 {
     DateTime CheckerDate = DateTime.Now.AddDays(3);
     db = new UcasProEntities();
     db.Configuration.LazyLoadingEnabled = false;
     db.Configuration.ProxyCreationEnabled = false;
     var LstExpiers = ( from c in  db.Contracts.ToList()
                      orderby c.StartDate ascending 
                      where c.EndDate == CheckerDate
                      select c).ToList ();
   return LstExpiers;
 }
Example #22
0
 public static bool DeleteAttachment(int ID)
 {
     
         db = new UcasProEntities();
         db.Configuration.LazyLoadingEnabled = false;
         db.Configuration.ProxyCreationEnabled = false;
         var q = db.Attachments.Where(p => p.IDX == ID).SingleOrDefault();
         db.Attachments.Remove(q);
         db.SaveChanges();
         return true;
    
    
 }
Example #23
0
       public static bool newSupplier(Supplier Sup)
       {
           
               db = new UcasProEntities();
               db.Configuration.ProxyCreationEnabled = false;
               db.Configuration.LazyLoadingEnabled = false;
               db.Suppliers.Add(Sup);
               db.SaveChanges();
               return true;

           
          
       }
        public static IEnumerable GetAllDonorsBypro(int ProId)
        {
            db = new UcasProEntities();
            var q = (from i in db.TheDonorsProjects
                     join pro in db.TheDonors on i.DonorsID equals pro.ID
                     where i.ProjectID == ProId
                   



                     select new { i.ID, pro.Name,i.TotalCost }).ToList();
            return q;

        }
        public static double GetTotalExpensesBySubActivity(int SubID)
        {
            db = new UcasProEntities();

            var LST = (from p in db.ProjectExpenses

                       where p.ProjectSubActivity_ID == SubID
                       select p.RequiarAmount).ToList();

            double total = 0;
            foreach (var Sm in LST) { total += Convert.ToDouble(Sm); }

            return total;

        }
Example #26
0
        public static bool EditAttachment(Attachment tb)
        {
           
                db = new UcasProEntities();
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;
                var q = db.Attachments.Where(p => p.IDX == tb.IDX).SingleOrDefault();
                q.AttachmentName = tb.AttachmentName;
                q.CreateDate = tb.CreateDate;

                q.ProjectProfile_ID = tb.ProjectProfile_ID;


                db.SaveChanges();
                return true;

           
        }
        public static bool NewAmountsReceived(AmountsReceived tb)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.ProxyCreationEnabled = false;
                db.Configuration.LazyLoadingEnabled = false;
                db.AmountsReceiveds.Add(tb);
                db.SaveChanges();
                return true;

            }
            catch (Exception )
            {

                return false;
            }
        }
        public static bool DeleteAmountsReceived(int ID)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;
                var q = db.AmountsReceiveds.Where(p => p.ID == ID).SingleOrDefault();
                db.AmountsReceiveds.Remove(q);
                db.SaveChanges();
                return true;
            }
            catch (Exception )
            {

                return false;
            }
        }
Example #29
0
        public static bool DeleteEmployee(int ID)
        {
            try
            {
                db = new UcasProEntities();

                var q = db.Employees.Where(p => p.ID == ID).SingleOrDefault();
                db.Employees.Remove(q);
                db.SaveChanges();
                return true;
           
            }
            catch (Exception )
            {

                return false;
            }
              
        }
Example #30
0
        public static bool EditEmployee(Employee emp)
        {
           
                db = new UcasProEntities();
              
                var q = db.Employees.Where(p => p.ID == emp.ID).SingleOrDefault();
                q.EmployeeName = emp.EmployeeName;
                q.EmployeejobNumber = emp.EmployeejobNumber;
                q.EmployeeGender = emp.EmployeeGender;
                q.PhoneNumber = emp.PhoneNumber;
                q.Mobilenumber = emp.Mobilenumber;
                q.Email = emp.Email;
                q.EmployeeNationalNumber = emp.EmployeeNationalNumber;
                db.SaveChanges();
                return true;

           
           
        }