Пример #1
0
 public static IEnumerable <SupplierSet> getAllSuppliers()
 {
     using (var ctx = new AccountingSystem())
     {
         return(ctx.SupplierSets.ToList());
     }
 }
Пример #2
0
 public static IEnumerable <ItemGroup> getAllCategory()
 {//repositoryItemComboBox1
     using (var ctx = new AccountingSystem())
     {
         return(ctx.ItemGroups.ToList());
     }
 }
Пример #3
0
 public static IEnumerable <Invoice> getAllInvoice()
 {
     using (var ctx = new AccountingSystem())
     {
         return(ctx.Invoices.ToList());
     }
 }
Пример #4
0
 public static IEnumerable <InvoiceDetail> getInvoiceDetais(int invID)
 {
     using (var ctx = new AccountingSystem())
     {
         return(ctx.InvoiceDetails.Where(i => i.InvoiceId == invID).ToList());
     }
 }
Пример #5
0
 public static IEnumerable <Item> getAllCategoryProducts(int catID)
 {//repositoryItemComboBox1
     using (var ctx = new AccountingSystem())
     {
         return(ctx.Items.Where(ctr => ctr.ItemGroupsId == catID).ToList());
     }
 }
Пример #6
0
 public static int getIvoiceCount()
 {
     using (var ctx = new AccountingSystem())
     {
         return(ctx.Invoices.Count());
     }
 }
Пример #7
0
        private void save_Click(object sender, EventArgs e)
        {
            news.Visible   = true;
            save.Visible   = false;
            update.Visible = true;
            splashScreenManager1.ShowWaitForm();
            Thread.Sleep(1000);
            using (var db = new AccountingSystem())
            {
                var Branch = db.Branches.Create();
                Branch.BName    = search.Text;
                Branch.BId      = Id.Text;
                Branch.BStatus  = Status.Checked.ToString();
                Branch.BPhone1  = Phone1.Text;
                Branch.BPhone2  = Phone2.Text;
                Branch.BAddress = Address.Text;
                db.Branches.Add(Branch);


                try
                {
                    db.SaveChanges();
                }
                catch (Exception dbEx)
                {
                    Exception raise = dbEx;
                    var       val   = dbEx.InnerException;
                    MessageBox.Show(val.ToString());
                }
                // MessageBox.Show("تم الحفظ بنجاح ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            fillsearch();
            splashScreenManager1.CloseWaitForm();
        }
Пример #8
0
        public StoresForm(string Id)
        {
            InitializeComponent();
            if (!Id.Equals("AddStore"))
            {
                Wharehous updatedItem = new Wharehous();
                using (var db = new AccountingSystem())
                {
                    i           = int.Parse(Id);
                    updatedItem = db.Wharehouses.First(x => x.Id == i);
                    isEditForm  = true;


                    GroupId.Text          = updatedItem.Id.ToString();
                    GroupName.Text        = updatedItem.StoreName;
                    StoreBranch.EditValue = updatedItem.BranchID;
                    StoreMobile.Text      = updatedItem.Mobile;
                    StoreSize.Text        = updatedItem.Size + "";
                    StoreStatus.Checked   = (bool)updatedItem.Status;
                    StoreAddress.Text     = updatedItem.Address;
                }
            }
            else
            {
                GetId();
            }

            CancelBtn.Visible = true;
        }
Пример #9
0
 private void news_Click(object sender, EventArgs e)
 {
     update.Visible = false;
     save.Visible   = true;
     using (var db = new AccountingSystem())
     {
         var dc = from c in db.Groups
                  //where c.Id.Equals(InvoiceID)
                  select new
         {
             c.Id,
         };
         var list = dc.ToList();
         int id   = list.Count;
         GroupId.Text = (id + 1).ToString();
     }
     search.Text            = "";
     Admin.Checked          = false;
     Sells.Checked          = false;
     Buys.Checked           = false;
     Warehouse.Checked      = false;
     Account.Checked        = false;
     VendorSupplier.Checked = false;
     Other.Checked          = false;
 }
Пример #10
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (MessageBox.Show("هل تريد الحذف؟", "تأكيد", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }
            string no = DebGrid.GetRowCellValue(DebGrid.FocusedRowHandle, "DebentureID").ToString();
            int    i  = int.Parse(no);

            using (var db = new AccountingSystem())
            {
                var widgets = db.debenturedetails.Where(x => x.DebentureID.Equals(i));
                foreach (debenturedetail widget in widgets)
                {
                    db.debenturedetails.Remove(widget);
                }
                db.SaveChanges();

                var d = db.debentures.Where(x => x.DebentureID.Equals(i));
                foreach (debenture widget in d)
                {
                    db.debentures.Remove(widget);
                }
                db.SaveChanges();
                MessageBox.Show("تم الحذف بنجاح");
                Refresh();
            }
        }
Пример #11
0
 public static IEnumerable <Item> getAllProducts()
 {//repositoryItemComboBox1
     using (var ctx = new AccountingSystem())
     {
         return(ctx.Items.ToList());
     }
 }
Пример #12
0
 public static TObject Find <TObject>(int id)
     where TObject : class
 {
     using (var ctx = new AccountingSystem())
     {
         return(ctx.Set <TObject>().Find(id));
     }
 }
Пример #13
0
 private void VendBankName_EditValueChanged(object sender, EventArgs e)
 {
     using (var d = new AccountingSystem())
     {
         var dc = from ff in d.BankBranches where (ff.IdBank.Equals(VendBankName.EditValue.ToString()))
                  select new { ff.BranchName, ff.IdBank, ff.Id };
         bindingSource4.DataSource = dc.ToList();
         VendBranch.Refresh();
     }
 }
Пример #14
0
 private void GetItems()
 {
     using (var db = new AccountingSystem())
     {
         var dc = from c in db.Items
                  select new { c.Id, c.Name };
         cmbItem.Properties.DataSource    = dc.ToList();
         cmbItem.Properties.ValueMember   = "Id";
         cmbItem.Properties.DisplayMember = "Name";
     }
 }
Пример #15
0
 private void GetPayType()
 {
     using (var db = new AccountingSystem())
     {
         var dc = from c in db.PaymentTypes
                  select new { c.PaymentTypeID, c.PaymentTypeName };
         cmbPaymentType.Properties.DataSource    = dc.ToList();
         cmbPaymentType.Properties.ValueMember   = "PaymentTypeID";
         cmbPaymentType.Properties.DisplayMember = "PaymentTypeName";
     }
 }
Пример #16
0
 public static int Update <TObject>(TObject obj)
     where TObject : class
 {
     using (var ctx = new AccountingSystem())
     {
         ctx.Set(typeof(TObject)).Attach(obj);
         ctx.Entry(obj).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
         return(0);
     }
 }
Пример #17
0
 private void GetCustomers()
 {
     using (var db = new AccountingSystem())
     {
         var dc = from c in db.VendorSets
                  select new { c.Id, c.VendorName };
         cmbCustomerID.Properties.DataSource    = dc.ToList();
         cmbCustomerID.Properties.ValueMember   = "Id";
         cmbCustomerID.Properties.DisplayMember = "VendorName";
     }
 }
Пример #18
0
 public static int Add <TEntity>(TEntity entity)
 {
     using (var ctx = new AccountingSystem())
     {
         //entity.cuid = LogTracker.GetLoggedUser().FullName;
         //entity.MakeCreated();
         ctx.Set(typeof(TEntity)).Add(entity);
         ctx.SaveChanges();
         return(0);
     }
 }
Пример #19
0
 private void GetCurrency()
 {
     using (var db = new AccountingSystem())
     {
         var dc = from c in db.CurrencySets
                  select new { c.Id, c.CurrencyName };
         cmbCurreny.Properties.DataSource    = dc.ToList();
         cmbCurreny.Properties.ValueMember   = "Id";
         cmbCurreny.Properties.DisplayMember = "CurrencyName";
     }
 }
Пример #20
0
        public void ReportVendors()
        {
            isVendor         = true;
            isSpuulier       = false;
            Vendor.Visible   = true;
            Supplier.Visible = false;
            //MessageBox.Show(ReprotStatus.SelectedIndex.ToString());
            using (var db = new AccountingSystem())
            {
                String status = "2";
                if ((ReprotStatus.SelectedIndex.ToString().Equals("0")) || (ReprotStatus.SelectedIndex.ToString().Equals("1")))
                {
                    if (ReprotStatus.SelectedIndex.ToString().Equals("0"))
                    {
                        status = "True";
                    }
                    if (ReprotStatus.SelectedIndex.ToString().Equals("1"))
                    {
                        status = "False";
                    }
                    var dc = from c in db.VendorSets
                             where c.VendorStatus.Equals(status)

                             select new
                    {
                        c.VendorName,
                        c.VendorCompanyName,
                        c.VendorStatus,
                        c.VendorBankName,
                        c.VendorPhone1,
                        c.VendorTypeOfBalance
                    };
                    bindingSource1.DataSource = dc.ToList();
                    Vendor.Refresh();
                }
                else
                {
                    var dc = from c in db.VendorSets
                             //where c.VendorStatus.Equals(status)
                             select new
                    {
                        c.VendorName,
                        c.VendorCompanyName,
                        c.VendorStatus,
                        c.VendorBankName,
                        c.VendorPhone1,
                        c.VendorTypeOfBalance
                    };
                    bindingSource1.DataSource = dc.ToList();
                    Vendor.Refresh();
                }
            }
        }
Пример #21
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            save.Visible   = false;
            news.Visible   = true;
            update.Visible = true;
            using (var db = new AccountingSystem())
            {
                var    na  = from b in db.Groups where b.Name.Equals(search.Text) select new { b.Id };
                var    lis = na.ToList();
                string Gid = lis[0].Id.ToString();
                if (lis.Count != 0)
                {
                    var dc = from c in db.PermissionControls
                             where c.CGroupId.Equals(Gid)
                             select new
                    {
                        c.CGroupId,
                        c.CAdmin,
                        c.CSells,
                        c.CBuys,
                        c.CWarehouse,
                        c.CVendorSupplier,
                        c.CAccount,
                        c.COther,
                    };
                    var list = dc.ToList();
                    if (list.Count != 0)
                    {
                        Other.Checked = list[0].COther;

                        Account.Checked = list[0].CAccount;

                        Admin.Checked = list[0].CAdmin;

                        Sells.Checked = list[0].CSells;

                        Buys.Checked = list[0].CBuys;

                        Warehouse.Checked = list[0].CWarehouse;

                        VendorSupplier.Checked = list[0].CVendorSupplier;

                        GroupId.Text = list[0].CGroupId;
                    }
                    else
                    {
                        MessageBox.Show("عفوا لا يوجد عميل بهذا الاسم", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Пример #22
0
        private void save_Click(object sender, EventArgs e)
        {
            if (search.Text.Equals("") || search.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء ادخال اسم المستخدم");
            }
            else if (Branch.Text.Equals("") || Branch.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار الفرع");
            }
            else if (Password.Text.Equals("") || Password.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء ادخال كلمة المرور");
            }
            else if (Group.Text.Equals("") || Group.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار المجموعة");
            }
            else
            {
                news.Visible   = true;
                save.Visible   = false;
                update.Visible = true;
                splashScreenManager1.ShowWaitForm();
                Thread.Sleep(1000);
                using (var db = new AccountingSystem())
                {
                    var User = db.Users.Create();
                    User.UCode     = Code.Text;
                    User.UName     = search.Text;
                    User.UStatus   = Status.Checked.ToString();
                    User.UBranch   = Branch.EditValue.ToString();
                    User.UPassword = Password.Text;
                    User.UGroup    = Group.EditValue.ToString();
                    db.Users.Add(User);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception dbEx)
                    {
                        Exception raise = dbEx;
                        var       val   = dbEx.InnerException;
                        MessageBox.Show(val.ToString());
                    }
                }
                fillsearch();
                splashScreenManager1.CloseWaitForm();
            }
        }
Пример #23
0
        public GroupForms(string id)
        {
            ItemGroup updatedItem = new ItemGroup();

            InitializeComponent();
            GroupId.Text = id;
            using (var db = new AccountingSystem())
            {
                i              = int.Parse(id);
                updatedItem    = db.ItemGroups.First(x => x.Id == i);
                isEditForm     = true;
                GroupName.Text = updatedItem.Name;
            }
        }
Пример #24
0
        public VenforVendpliersReview()
        {
            InitializeComponent();
            Vendor.Visible   = true;
            Supplier.Visible = false;
            // This line of code is generated by Data Source Configuration Wizard
            // Instantiate a new DBContext
            dbContext = new Purchase.AccountingSystem();
            // Call the Load method to get the data for the given DbSet from the database.
            dbContext.VendorSets.Load();
            // This line of code is generated by Data Source Configuration Wizard
            using (var db = new AccountingSystem())
            {
                var dc = from c in db.VendorSets
                         //where c.Id.Equals(InvoiceID)
                         select new
                {
                    c.VendorName,
                    c.VendorCompanyName,
                    c.VendorStatus,
                    c.VendorBankName,
                    c.VendorPhone1,
                    c.VendorTypeOfBalance
                };
                bindingSource1.DataSource = dc.ToList();
            }

            // This line of code is generated by Data Source Configuration Wizard
            // Instantiate a new DBContext
            // Call the Load method to get the data for the given DbSet from the database.
            dbContext.SupplierSets.Load();
            // This line of code is generated by Data Source Configuration Wizard
            using (var db = new AccountingSystem())
            {
                var dc = from c in db.SupplierSets
                         //where c.Id.Equals(InvoiceID)
                         select new
                {
                    c.SupplierName,
                    c.SupplierCompanyName,
                    c.SupplierStatus,
                    c.SupplierBankName,
                    c.SupplierPhone1,
                    c.SupplierTypeOfBalance
                };
                bindingSource2.DataSource = dc.ToList();
                //bindingSource2.DataSource = dbContext.SupplierSets.Local.ToBindingList();
            }
            ReprotStatus.SelectedIndex = 2;
        }
Пример #25
0
 private void GetId()
 {
     using (var db = new AccountingSystem())
     {
         var dc = 0;
         try
         {
             dc = (from c in db.Wharehouses
                   select c.Id).Max();
         }
         catch (Exception) { }
         GroupId.Text = (int.Parse(dc.ToString()) + 1) + "";
     }
 }
Пример #26
0
 public GroupForms()
 {
     InitializeComponent();
     using (var db = new AccountingSystem())
     {
         var dc = 0;
         try
         {
             dc = (from c in db.ItemGroups
                   select c.Id).Max();
         }catch (Exception)
         { }
         GroupId.Text = (int.Parse(dc.ToString()) + 1) + "";
     }
 }
Пример #27
0
 private void ItemCode_EditValueChanged(object sender, EventArgs e)
 {
     using (var db = new AccountingSystem())
     {
         if (db.Items.Any(o => o.Code == ItemCode.Text))
         {
             if (!ItemCode.Text.Equals(currentCode) && isEditForm)
             {
                 dxErrorProvider1.SetError(ItemCode, "هذا الكود موجود", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
             }
             else
             {
                 dxErrorProvider1.ClearErrors();
             }
         }
     }
 }
Пример #28
0
 private void AddGroup_Load(object sender, EventArgs e)
 {
     update.Visible = false;
     using (var db = new AccountingSystem())
     {
         var dc = from c in db.Groups
                  //where c.Id.Equals(InvoiceID)
                  select new
         {
             c.Id,
         };
         var list = dc.ToList();
         int id   = list.Count;
         GroupId.Text = (id + 1).ToString();
     }
     fillsearch();
 }
Пример #29
0
 private void update_Click(object sender, EventArgs e)
 {
     splashScreenManager1.ShowWaitForm();
     Thread.Sleep(1000);
     using (var db = new AccountingSystem())
     {
         try
         {
             var Control = db.PermissionControls.First(x => x.CGroupId.Equals(GroupId.Text.ToString()));
             Control.CAdmin          = Admin.Checked;
             Control.CSells          = Sells.Checked;
             Control.CBuys           = Buys.Checked;
             Control.CWarehouse      = Warehouse.Checked;
             Control.CAccount        = Account.Checked;
             Control.CVendorSupplier = VendorSupplier.Checked;
             Control.COther          = Other.Checked;
             db.Entry(Control).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
         catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
         {
             Exception raise = dbEx;
             foreach (var validationErrors in dbEx.EntityValidationErrors)
             {
                 foreach (var validationError in validationErrors.ValidationErrors)
                 {
                     string message = string.Format("{0}:{1}",
                                                    validationErrors.Entry.Entity.ToString(),
                                                    validationError.ErrorMessage);
                     raise = new InvalidOperationException(message, raise);
                 }
             }
             throw raise;
         }
         catch (Exception dbEx)
         {
             Exception raise = dbEx;
             var       val   = dbEx.InnerException;
             MessageBox.Show(val.ToString());
             //throw raise;
         }
     }
     fillsearch();
     splashScreenManager1.CloseWaitForm();
 }
Пример #30
0
 private void update_Click(object sender, EventArgs e)
 {
     splashScreenManager1.ShowWaitForm();
     Thread.Sleep(1000);
     using (var db = new AccountingSystem())
     {
         try
         {
             var Branch = db.Branches.First(x => x.BId.Equals(Id.Text.ToString()));
             Branch.BName    = search.Text;
             Branch.BId      = Id.Text;
             Branch.BStatus  = Status.Checked.ToString();
             Branch.BPhone1  = Phone1.Text;
             Branch.BPhone2  = Phone2.Text;
             Branch.BAddress = Address.Text;
             db.Branches.Add(Branch);
             db.Entry(Branch).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
         catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
         {
             Exception raise = dbEx;
             foreach (var validationErrors in dbEx.EntityValidationErrors)
             {
                 foreach (var validationError in validationErrors.ValidationErrors)
                 {
                     string message = string.Format("{0}:{1}",
                                                    validationErrors.Entry.Entity.ToString(),
                                                    validationError.ErrorMessage);
                     raise = new InvalidOperationException(message, raise);
                 }
             }
             throw raise;
         }
         catch (Exception dbEx)
         {
             Exception raise = dbEx;
             var       val   = dbEx.InnerException;
             MessageBox.Show(val.ToString());
             //throw raise;
         }
     }
     fillsearch();
     splashScreenManager1.CloseWaitForm();
 }