Example #1
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();
     }
 }
Example #2
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);
        }