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