Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        public static bool DeleteDonorsProject(int xid)
        {
            try
            {
                db = new UcasProEntities();
                TheDonorsProject tb = new TheDonorsProject();
                tb = db.TheDonorsProjects.Where(f => f.ID == xid).Single();
                if (tb.ID != 0)
                {
                    db.TheDonorsProjects.Remove(tb);
                    db.SaveChanges();
                    return true;
                }
                return false;
            }
            catch (Exception)
            {

                return false;
            }
        }