コード例 #1
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();
            }
        }
コード例 #2
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();
        }
コード例 #3
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);
     }
 }
コード例 #4
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);
     }
 }
コード例 #5
0
ファイル: AddUser.cs プロジェクト: MazinKarar/photoshop
        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();
            }
        }
コード例 #6
0
ファイル: AddGroup.cs プロジェクト: MazinKarar/photoshop
 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();
 }
コード例 #7
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();
 }
コード例 #8
0
ファイル: AddArea.cs プロジェクト: MazinKarar/photoshop
 private void button1_Click(object sender, EventArgs e)
 {
     if (name.Text.Equals(""))
     {
         MessageBox.Show("الرجاء ادخال اسم المنطقة");
     }
     else
     {
         splashScreenManager1.ShowWaitForm();
         Thread.Sleep(1000);
         using (var db = new AccountingSystem())
         {
             var AreaSet = db.AreasSets.Create();
             AreaSet.AreaName = name.Text;
             db.AreasSets.Add(AreaSet);
             db.SaveChanges();
             name.Text = "";
             splashScreenManager1.CloseWaitForm();
         }
     }
 }
コード例 #9
0
ファイル: AddBanks.cs プロジェクト: MazinKarar/photoshop
 private void button1_Click(object sender, EventArgs e)
 {
     if (BankName.Text.Equals(""))
     {
         MessageBox.Show("الرجاء ادخال اسم البنك");
     }
     else
     {
         splashScreenManager1.ShowWaitForm();
         Thread.Sleep(1000);
         using (var db = new AccountingSystem())
         {
             var Bank = db.BankSets.Create();
             Bank.BankName = BankName.Text;
             db.BankSets.Add(Bank);
             db.SaveChanges();
             BankName.Text = "";
             splashScreenManager1.CloseWaitForm();
         }
     }
 }
コード例 #10
0
ファイル: AddGroup.cs プロジェクト: MazinKarar/photoshop
        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 group = db.Groups.Create();
                group.Name = search.Text;
                var Control = db.PermissionControls.Create();
                Control.CGroupId        = GroupId.Text;
                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.PermissionControls.Add(Control);
                db.Groups.Add(group);


                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();
        }
コード例 #11
0
ファイル: AddBank.cs プロジェクト: MazinKarar/photoshop
 private void button1_Click(object sender, EventArgs e)
 {
     if (BankName.Text.Equals("") || BankBranch.Text.Equals(""))
     {
         MessageBox.Show("الرجاء ملئ كل الحقول");
     }
     else
     {
         splashScreenManager1.ShowWaitForm();
         Thread.Sleep(1000);
         using (var db = new AccountingSystem())
         {
             var BankBranh1 = db.BankBranches.Create();
             BankBranh1.BranchName = BankBranch.Text;
             BankBranh1.IdBank     = BankName.EditValue.ToString();
             db.BankBranches.Add(BankBranh1);
             db.SaveChanges();
             BankBranch.Text = "";
             splashScreenManager1.CloseWaitForm();
         }
     }
 }
コード例 #12
0
        private void update_Click(object sender, EventArgs e)
        {
            if (VendName.Text.Equals("") || VendName.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء ادخال اسم العميل");
            }
            else if (VendBalance.Text.Equals("") || VendBalance.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء الرصيد الابتدائي");
            }
            else if (VendLedger.Text.Equals("") || VendLedger.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار حساب الاستاذ");
            }
            else if (VendSupplementingAccount.Text.Equals("") || VendSupplementingAccount.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار الحساب المكمل");
            }
            else
            {
                splashScreenManager1.ShowWaitForm();
                Thread.Sleep(1000);
                //Wait pleaseWait = new Wait();
                //Application.DoEvents();
                //pleaseWait.Show();
                save.Visible   = false;
                news.Visible   = true;
                update.Visible = true;
                VendorSet Sup = new VendorSet();
                //InitializeComponent();
                using (var db = new AccountingSystem())
                {
                    try
                    {
                        var VendorSet = db.VendorSets.First(x => x.VendorId.Equals(VendCode.Text));
                        VendorSet.VendorId                   = VendCode.Text;
                        VendorSet.VendorName                 = VendName.Text;
                        VendorSet.VendorStartBalance         = VendBalance.Text;
                        VendorSet.VendorStartBlnsDate        = VendDateBalance.Value.ToString();
                        VendorSet.VendorTypeOfBalance        = VendTypeBalance.Text;
                        VendorSet.VendorStatus               = VendStatus.Checked.ToString();
                        VendorSet.VendorBranch               = VendResponsbile.Text;
                        VendorSet.VendorBranchCurrency       = VendCurrency.Text;
                        VendorSet.VendorSupplementingAccount = VendSupplementingAccount.EditValue.ToString();
                        VendorSet.VendorLedger               = VendLedger.EditValue.ToString();
                        VendorSet.VendorCompanyName          = VendNameCompany.Text;
                        VendorSet.VendorResponsible          = VendBranch.Text;
                        VendorSet.VendorArea                 = VendArea.Text;
                        VendorSet.VendorAddress              = VendAddress.Text;
                        VendorSet.VendorPhone1               = VendPhone1.Text;
                        VendorSet.VendorPhone2               = VendPhone2.Text;
                        VendorSet.VendorWebsite              = VendWebsite.Text;
                        VendorSet.VendorEmail                = VendEmail.Text;
                        VendorSet.VendorBankNoAccount        = VendBankNoAccount.Text;
                        VendorSet.VendorBankName             = VendBankName.Text;
                        VendorSet.VendorBankBranach          = VendBankBranch.Text;
                        db.Entry(VendorSet).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();
            }
        }
コード例 #13
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (cmbCustomerID.EditValue == null)
            {
                MessageBox.Show("الرجاء إختيار العميل ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbCustomerID.Focus();
                return;
            }
            else if (cmbCurreny.EditValue == null)
            {
                MessageBox.Show("الرجاء إختيار  العملة ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbCurreny.Focus();
                return;
            }
            else if (cmbPaymentType.EditValue == null)
            {
                MessageBox.Show("الرجاء إختيار طريقة الدفع ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbPaymentType.Focus();
                return;
            }
            if (gridView1.RowCount == 0)
            {
                MessageBox.Show("الرجاء ادخال تفاصيل الفاتورة ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error);
                gridView1.Focus();
                return;
            }
            if (int.Parse(txtInvoiceNo.Tag.ToString()) == 0)
            {
                using (var db = new AccountingSystem())
                {
                    var InvoiceEntity = db.SalesInvoices.Create();
                    InvoiceEntity.InvoiceDate = DateTime.Parse(txtInvoiceDate.Text);
                    InvoiceEntity.InoviceNo   = "inv";
                    InvoiceEntity.CustomerID  = int.Parse(cmbCustomerID.EditValue.ToString());
                    InvoiceEntity.CurrencyID  = int.Parse(cmbCurreny.EditValue.ToString());
                    InvoiceEntity.Rate        = double.Parse(txtRate.Text);
                    InvoiceEntity.PaymentType = int.Parse(cmbPaymentType.EditValue.ToString());
                    if (InvoiceEntity.PaymentType == 2)
                    {
                        InvoiceEntity.ChequeNo   = txtChequeNo.Text;
                        InvoiceEntity.ChequeDate = DateTime.Parse(txtChequeDate.Text);
                    }
                    InvoiceEntity.Discount = double.Parse(txtDiscount.Text);
                    InvoiceEntity.Tax      = double.Parse(txtTax.Text);
                    InvoiceEntity.Notes    = txtNotes.Text;
                    InvoiceEntity.UserID   = 1;
                    if (chkCancel.Checked)
                    {
                        InvoiceEntity.Canceled = 1;
                    }
                    else
                    {
                        InvoiceEntity.Canceled = 0;
                    }
                    if (chkPaid.Checked)
                    {
                        InvoiceEntity.Paid = 1;
                    }
                    else
                    {
                        InvoiceEntity.Paid = 0;
                    }
                    try
                    {
                        db.SalesInvoices.Add(InvoiceEntity);
                        db.SaveChanges();
                        txtInvoiceNo.Tag = InvoiceEntity.Id;
                        MessageBox.Show("تم الحفظ بنجاح ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception dbEx)
                    {
                        Exception raise = dbEx;
                        var       val   = dbEx.InnerException;
                        MessageBox.Show(val.ToString());
                    }
                }
            }
            else if (int.Parse(txtInvoiceNo.Tag.ToString()) != 0)
            {
                try
                {
                    using (var db = new AccountingSystem())
                    {
                        int Invoiceid     = int.Parse(txtInvoiceNo.Tag.ToString());
                        var InvoiceEntity = db.SalesInvoices.First(i => i.Id == Invoiceid);
                        InvoiceEntity.InoviceNo   = InvoiceEntity.InoviceNo;
                        InvoiceEntity.InvoiceDate = DateTime.Parse(txtInvoiceDate.Text);
                        InvoiceEntity.CustomerID  = int.Parse(cmbCustomerID.EditValue.ToString());
                        InvoiceEntity.CurrencyID  = int.Parse(cmbCurreny.EditValue.ToString());
                        InvoiceEntity.Rate        = int.Parse(txtRate.Text);
                        if (InvoiceEntity.PaymentType == 2)
                        {
                            InvoiceEntity.ChequeNo   = txtChequeNo.Text;
                            InvoiceEntity.ChequeDate = DateTime.Parse(txtChequeDate.Text);
                        }
                        InvoiceEntity.Discount = double.Parse(txtDiscount.Text);
                        InvoiceEntity.Tax      = double.Parse(txtTax.Text);
                        InvoiceEntity.UserID   = 1;
                        InvoiceEntity.Notes    = txtNotes.Text;
                        if (chkCancel.Checked)
                        {
                            InvoiceEntity.Canceled = 1;
                        }
                        else
                        {
                            InvoiceEntity.Canceled = 0;
                        }
                        if (chkPaid.Checked)
                        {
                            InvoiceEntity.Paid = 1;
                        }
                        else
                        {
                            InvoiceEntity.Paid = 0;
                        }
                        db.SaveChanges();

                        /*if (int.Parse(txtInvoiceNo.Tag.ToString()) != 0) {
                         *  dbContext.SaveChanges();
                         * }*/
                        MessageBox.Show("تم الحفظ بنجاح ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception dbEx)
                {
                    Exception raise = dbEx;
                    var       val   = dbEx.InnerException;
                    MessageBox.Show(val.ToString());
                }
            }
            try
            {
                using (var db = new AccountingSystem())
                {
                    int Invoiceid = int.Parse(txtInvoiceNo.Tag.ToString());
                    if (gridView1 != null)
                    {
                        if (int.Parse(txtInvoiceNo.Tag.ToString()) != 0)
                        {
                            dbContext.Database.ExecuteSqlCommand("DELETE FROM SaleInvoiceDetails WHERE SalesInvoicesId=" + int.Parse(txtInvoiceNo.Tag.ToString()));
                        }
                    }
                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        var InvoiceDetailsEntity = db.SaleInvoiceDetails.Create();
                        InvoiceDetailsEntity.ItemID          = int.Parse(gridView1.GetRowCellValue(i, "ItemID").ToString());
                        InvoiceDetailsEntity.Quantity        = int.Parse(gridView1.GetRowCellValue(i, "Quantity").ToString());
                        InvoiceDetailsEntity.Unit            = gridView1.GetRowCellValue(i, "Unit").ToString();
                        InvoiceDetailsEntity.Price           = Double.Parse(gridView1.GetRowCellValue(i, "Price").ToString());
                        InvoiceDetailsEntity.SalesInvoicesId = int.Parse(txtInvoiceNo.Tag.ToString());
                        db.SaleInvoiceDetails.Add(InvoiceDetailsEntity);//add details in master object
                    }
                    db.SaveChanges();
                    DisplayInvoice(Invoiceid);
                }
            }
            catch (Exception dbEx)
            {
                Exception raise = dbEx;
                var       val   = dbEx.InnerException;
                MessageBox.Show(val.ToString());
            }
        }
コード例 #14
0
ファイル: StoresForm.cs プロジェクト: MazinKarar/photoshop
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            string ErrorMessage = "";

            if (GroupName.Text.Equals(""))
            {
                ErrorMessage = "الرجاء ادخال الأسم";
            }
            else if (StoreMobile.Text.Equals(""))
            {
                ErrorMessage = "الرجاء ادخال التلفون";
            }
            else if (StoreSize.Text.Equals(""))
            {
                ErrorMessage = "الرجاء ادخال المساحة";
            }
            else if (StoreAddress.Text.Equals(""))
            {
                ErrorMessage = "الرجاء ادخال العنوان";
            }
            else if (StoreBranch.Text.Equals(""))
            {
                ErrorMessage = "الرجاء اختيار الفرع";
            }

            using (var db = new AccountingSystem())
            {
                var StoreEntity = db.Wharehouses.Create();

                if (ErrorMessage.Equals(""))
                {
                    StoreEntity.StoreName = GroupName.Text;
                    StoreEntity.Status    = StoreStatus.Checked;
                    StoreEntity.Mobile    = StoreMobile.Text;
                    StoreEntity.Size      = int.Parse(StoreSize.Text);
                    StoreEntity.Address   = StoreAddress.Text;
                    StoreEntity.BranchID  = int.Parse(StoreBranch.Text);

                    if (isEditForm)
                    {
                        StoreEntity.Id = i;
                        db.Entry(StoreEntity).State = System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        db.Wharehouses.Add(StoreEntity);
                    }

                    try
                    {
                        db.SaveChanges();

                        if (!isEditForm)
                        {
                            GroupName.Text      = "";
                            StoreStatus.Checked = false;
                            StoreMobile.Text    = "";
                            StoreSize.Text      = "";
                            StoreAddress.Text   = "";
                            StoreBranch.Text    = "";
                            GroupId.Text        = (int.Parse(GroupId.Text) + 1) + "";
                        }
                    }
                    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());
                    }
                }
                else
                {
                    MessageBox.Show(ErrorMessage);
                }
            }
        }
コード例 #15
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            using (var db = new AccountingSystem())
            {
                var debenturedetails = db.debenturedetails.Create(); //Master Object
                var Debenture        = db.debentures.Create();       //Master Object
                Debenture.DebentureNo   = DebentureNo.Text;
                Debenture.Notes         = note.Text;
                Debenture.remarks       = nodes.Text;
                Debenture.MDate         = DateTime.Now;
                Debenture.UserID        = 1;
                Debenture.Sequence      = 1;
                Debenture.Amount        = 1;
                Debenture.DebentureDate = date.DateTime;

                if (DetGridView != null && !isEditForm)
                {
                    for (int b = 0; b < gridView1.RowCount; b++)
                    {
                        Purchase.debenturedetail DetailsEntity = new Purchase.debenturedetail();

                        var x = int.Parse(gridView1.GetRowCellValue(b, "Amount").ToString());
                        var y = int.Parse(gridView1.GetRowCellValue(b, "Payed").ToString());
                        DetailsEntity.Amount    = int.Parse(gridView1.GetRowCellValue(b, "Amount").ToString());
                        DetailsEntity.Payed     = int.Parse(gridView1.GetRowCellValue(b, "Payed").ToString());
                        DetailsEntity.AccountID = int.Parse(gridView1.GetRowCellValue(b, "AccountID").ToString());
                        DetailsEntity.ValueDate = DateTime.Now;
                        Debenture.debenturedetails.Add(DetailsEntity);//add details in master object
                    }
                }
                string Message = "";
                if (DebentureNo.Text.Equals(""))
                {
                    MessageBox.Show("الرجاء ادخال الرقم القيد", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (note.Text.Equals(""))
                {
                    MessageBox.Show("الرجاء ادخال البيان", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                if (double.Parse(textcrd.Text) == 0 || double.Parse(textdebt.Text) == 0 || double.Parse(textcrd.Text) != double.Parse(textdebt.Text))
                {
                    MessageBox.Show("مجموع القيود الدائنة لايساوي المدينة", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    gridView1.Focus();
                    return;
                }
                else
                {
                    if (!isEditForm)
                    {
                        db.debentures.Add(Debenture);
                    }
                    else
                    {
                        int i = int.Parse(Id);
                        //   MessageBox.Show(i.ToString());
                        var Debentur = db.debentures.First(x => x.DebentureID.Equals(i));
                        Debentur.DebentureNo   = DebentureNo.Text;
                        Debentur.Notes         = note.Text;
                        Debentur.MDate         = DateTime.Now;
                        Debentur.remarks       = nodes.Text;
                        Debentur.UserID        = 1;
                        Debentur.Sequence      = 1;
                        Debentur.Amount        = 1;
                        Debentur.DebentureDate = date.DateTime;

                        var widgets = db.debenturedetails.Where(x => x.DebentureID.Equals(i));
                        foreach (debenturedetail widget in widgets)
                        {
                            db.debenturedetails.Remove(widget);
                        }
                        if (DetGridView != null)
                        {
                            for (int b = 0; b < gridView1.RowCount; b++)
                            {
                                Purchase.debenturedetail DetailsEntity = new Purchase.debenturedetail();
                                var x = int.Parse(gridView1.GetRowCellValue(b, "Amount").ToString());
                                var y = int.Parse(gridView1.GetRowCellValue(b, "Payed").ToString());
                                DetailsEntity.Amount    = int.Parse(gridView1.GetRowCellValue(b, "Amount").ToString());
                                DetailsEntity.Payed     = int.Parse(gridView1.GetRowCellValue(b, "Payed").ToString());
                                DetailsEntity.AccountID = int.Parse(gridView1.GetRowCellValue(b, "AccountID").ToString());
                                DetailsEntity.ValueDate = DateTime.Now;
                                Debentur.debenturedetails.Add(DetailsEntity);    //add details in master object
                            }
                        }
                        //  Debentur.debenturedetails.Add(DetailsEntity);
                        db.Entry(Debentur).State = System.Data.Entity.EntityState.Modified;
                    }

                    try
                    {
                        db.SaveChanges();
                        if (isEditForm)
                        {
                            Message = "تم التعديل بنجاح";
                        }
                        if (!isEditForm)
                        {
                            Message       = "تم الحفظ بنجاح";
                            note.Text     = "";
                            date.DateTime = DateTime.Now;
                            textcrd.Text  = 0 + "";
                            textcrd.Text  = 0 + "";
                            textdebt.Text = 0 + "";
                            sumcrd.Text   = 0 + "";
                            sumdebt.Text  = 0 + "";
                            nodes.Text    = "";
                            for (int b = 0; b < gridView1.RowCount; b++)
                            {
                                gridView1.SelectRow(b);
                                gridView1.DeleteRow(b);
                                gridView1.SelectAll();
                                gridView1.DeleteSelectedRows();
                            }
                            using (var dbs = new AccountingSystem())
                            {
                                var dc = dbs.debentures.ToList().Max(i => Convert.ToInt32(i.DebentureNo));
                                DebentureNo.Text = (int.Parse(dc.ToString()) + 1) + "";
                            }
                        }
                    }
                    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());
                        MessageBox.Show("هذا الحساب غير موجود", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //throw raise;
                    }
                }
                if (Message != "")
                {
                    MessageBox.Show(Message);
                }
            }
        }
コード例 #16
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (SubName.Text.Equals("") || SubName.Text.Equals(" "))
     {
         DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء ادخال اسم العميل");
     }
     else if (SubBalance.Text.Equals("") || SubBalance.Text.Equals(" "))
     {
         DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء الرصيد الابتدائي");
     }
     else if (SupLedger.Text.Equals("") || SupLedger.Text.Equals(" "))
     {
         DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار حساب الاستاذ");
     }
     else if (SupSupplementingAccount.Text.Equals("") || SupSupplementingAccount.Text.Equals(" "))
     {
         DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار الحساب المكمل");
     }
     else
     {
         splashScreenManager1.ShowWaitForm();
         Thread.Sleep(1000);
         news.Visible   = true;
         save.Visible   = false;
         update.Visible = true;
         using (var db = new AccountingSystem())
         {
             SupplierSet dd = new SupplierSet();
             //var SupplierSet = db.SupplierSets.Create();
             dd.SupplierId                   = SubCode.Text;
             dd.SupplierName                 = SubName.Text;
             dd.SupplierStartBalance         = SubBalance.Text;
             dd.SupplierStartBlnsDate        = SubDateBalance.Value.ToString();
             dd.SupplierTypeOfBalance        = SubTypeBalance.Text;
             dd.SupplierStatus               = SubStatus.Checked.ToString();
             dd.SupplierBranch               = SupBranch.Text;
             dd.SupplierBranchCurrency       = SupCurrency.Text;
             dd.SupplierSupplementingAccount = SupSupplementingAccount.EditValue.ToString();
             dd.SupplierLedger               = SupLedger.EditValue.ToString();
             dd.SupplierCompanyName          = SubNameCompany.Text;
             dd.SupplierResponsible          = SubResponsbile.Text;
             dd.SupplierArea                 = SubArea.Text;
             dd.SupplierAddress              = SubAddress.Text;
             dd.SupplierPhone1               = SubPhone1.Text;
             dd.SupplierPhone2               = SubPhone2.Text;
             dd.SupplierWebsite              = SubWebsite.Text;
             dd.SupplierEmail                = SubEmail.Text;
             dd.SupplierBankNoAccount        = SubBankNoAccount.Text;
             dd.SupplierBankName             = SubBankName.Text;
             dd.SupplierBankBranach          = SubBankBranch.Text;
             db.SupplierSets.Add(dd);
             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();
     }
 }
コード例 #17
0
ファイル: GroupForms.cs プロジェクト: MazinKarar/photoshop
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (GroupName.Text.Trim().Equals(String.Empty))
            {
                MessageBox.Show("الرجاء ادخال اسم المجموعة");
            }
            else
            {
                using (var db = new AccountingSystem())
                {
                    var groupEntity = db.ItemGroups.Create();

                    groupEntity.Name = GroupName.Text;

                    groupEntity.Type = groupStatus.Checked ? 1 : 0;

                    try
                    {
                        if (isEditForm)
                        {
                            groupEntity.Id = i;
                            db.Entry(groupEntity).State = System.Data.Entity.EntityState.Modified;
                        }
                        else
                        {
                            db.ItemGroups.Add(groupEntity);
                        }

                        db.SaveChanges();

                        if (!isEditForm)
                        {
                            GroupName.Text      = "";
                            GroupId.Text        = (int.Parse(GroupId.Text) + 1) + "";
                            groupStatus.Checked = false;
                        }
                    }
                    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());
                    }
                }
            }
        }
コード例 #18
0
ファイル: AddUser.cs プロジェクト: MazinKarar/photoshop
        private void update_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
            {
                save.Visible   = false;
                news.Visible   = true;
                update.Visible = true;
                VendorSet Sup = new VendorSet();
                //InitializeComponent();
                splashScreenManager1.ShowWaitForm();
                Thread.Sleep(1000);
                using (var db = new AccountingSystem())
                {
                    try
                    {
                        var User = db.Users.First(x => x.UCode.Equals(Code.Text));
                        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.Text;

                        db.Entry(User).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();
            }
        }
コード例 #19
0
        private void save_Click(object sender, EventArgs e)
        {
            if (VendName.Text.Equals("") || VendName.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء ادخال اسم العميل");
            }
            else if (VendBalance.Text.Equals("") || VendBalance.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء الرصيد الابتدائي");
            }
            else if (VendLedger.Text.Equals("") || VendLedger.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار حساب الاستاذ");
            }
            else if (VendSupplementingAccount.Text.Equals("") || VendSupplementingAccount.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار الحساب المكمل");
            }
            else
            {
                splashScreenManager1.ShowWaitForm();
                Thread.Sleep(1000);
                news.Visible   = true;
                save.Visible   = false;
                update.Visible = true;
                using (var db = new AccountingSystem())
                {
                    var VendorSet = db.VendorSets.Create();
                    VendorSet.VendorId             = VendCode.Text;
                    VendorSet.VendorName           = VendName.Text;
                    VendorSet.VendorStartBalance   = VendBalance.Text;
                    VendorSet.VendorStartBlnsDate  = VendDateBalance.Value.ToString();
                    VendorSet.VendorTypeOfBalance  = VendTypeBalance.Text;
                    VendorSet.VendorStatus         = VendStatus.Checked.ToString();
                    VendorSet.VendorBranch         = VendResponsbile.Text;
                    VendorSet.VendorBranchCurrency = VendCurrency.Text;
                    // VendorSet.VendorSupplementingAccount = VendSupplementingAccount.EditValue.ToString();
                    VendorSet.VendorLedger = VendLedger.EditValue.ToString();

                    VendorSet.VendorSupplementingAccount = VendSupplementingAccount.EditValue.ToString();
                    VendorSet.VendorCompanyName          = VendNameCompany.Text;
                    VendorSet.VendorResponsible          = VendBranch.Text;
                    VendorSet.VendorArea          = VendArea.Text;
                    VendorSet.VendorAddress       = VendAddress.Text;
                    VendorSet.VendorPhone1        = VendPhone1.Text;
                    VendorSet.VendorPhone2        = VendPhone2.Text;
                    VendorSet.VendorWebsite       = VendWebsite.Text;
                    VendorSet.VendorEmail         = VendEmail.Text;
                    VendorSet.VendorBankNoAccount = VendBankNoAccount.Text;
                    VendorSet.VendorBankName      = VendBankName.Text;
                    VendorSet.VendorBankBranach   = VendBankBranch.Text;
                    db.VendorSets.Add(VendorSet);
                    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();
            }
        }
コード例 #20
0
        private void update_Click(object sender, EventArgs e)
        {
            if (SubName.Text.Equals("") || SubName.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء ادخال اسم العميل");
            }
            else if (SubBalance.Text.Equals("") || SubBalance.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء الرصيد الابتدائي");
            }
            else if (SupLedger.Text.Equals("") || SupLedger.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار حساب الاستاذ");
            }
            else if (SupSupplementingAccount.Text.Equals("") || SupSupplementingAccount.Text.Equals(" "))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("الرجاء اختيار الحساب المكمل");
            }
            else
            {
                splashScreenManager1.ShowWaitForm();
                Thread.Sleep(1000);
                //Wait pleaseWait = new Wait();
                //Application.DoEvents();
                //pleaseWait.Show();
                save.Visible   = false;
                news.Visible   = true;
                update.Visible = true;
                SupplierSet Sup = new SupplierSet();
                //InitializeComponent();
                using (var db = new AccountingSystem())
                {
                    try
                    {
                        var SupplierSet = db.SupplierSets.First(x => x.SupplierId.Equals(SubCode.Text));
                        SupplierSet.SupplierId                   = SubCode.Text;
                        SupplierSet.SupplierName                 = SubName.Text;
                        SupplierSet.SupplierStartBalance         = SubBalance.Text;
                        SupplierSet.SupplierStartBlnsDate        = SubDateBalance.Value.ToString();
                        SupplierSet.SupplierTypeOfBalance        = SubTypeBalance.Text;
                        SupplierSet.SupplierStatus               = SubStatus.Checked.ToString();
                        SupplierSet.SupplierBranch               = SupBranch.Text;
                        SupplierSet.SupplierBranchCurrency       = SupCurrency.Text;
                        SupplierSet.SupplierSupplementingAccount = SupSupplementingAccount.EditValue.ToString();
                        SupplierSet.SupplierLedger               = SupLedger.EditValue.ToString();
                        SupplierSet.SupplierCompanyName          = SubNameCompany.Text;
                        SupplierSet.SupplierResponsible          = SubResponsbile.Text;
                        SupplierSet.SupplierArea                 = SubArea.Text;
                        SupplierSet.SupplierAddress              = SubAddress.Text;
                        SupplierSet.SupplierPhone1               = SubPhone1.Text;
                        SupplierSet.SupplierPhone2               = SubPhone2.Text;
                        SupplierSet.SupplierWebsite              = SubWebsite.Text;
                        SupplierSet.SupplierEmail                = SubEmail.Text;
                        SupplierSet.SupplierBankNoAccount        = SubBankNoAccount.Text;
                        SupplierSet.SupplierBankName             = SubBankName.Text;
                        SupplierSet.SupplierBankBranach          = SubBankBranch.Text;
                        db.Entry(SupplierSet).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();
            }
            //pleaseWait. ;
            //pleaseWait.Close(TimeSpan.FromSeconds(0));
            //MessageBox.Show("تم التحديث بنجاح ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }