示例#1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            try
            {
                Utility     utl       = new Utility();
                DaftarTable newDaftar = new DaftarTable();

                if (!inputValidation())
                {
                    return;
                }

                newDaftar.Refund      = Convert.ToInt64(this.refundTextBox.Text);
                newDaftar.AccountType = YeKe.ApplyCorrectYeKe(this.AccountTypeComboBox.Text);

                newDaftar.BillDetailCode = Convert.ToInt64(this.billDetailCodetextBox.Text);
                newDaftar.CodeBudget     = Convert.ToInt64(this.BudgetCodetextBox.Text);
                newDaftar.Date           = (this.dateMaskedTextBox.Text);

                newDaftar.RealDate           = utl.changeToRealDate(newDaftar.Date);
                newDaftar.Deposit            = Convert.ToInt64(this.DepositTextBox.Text);
                newDaftar.DepositDetail      = Convert.ToInt64(this.DepositDetailtextBox.Text);
                newDaftar.DepositOwnerDetail = YeKe.ApplyCorrectYeKe(this.DepositOwnerDetailTextBox.Text);

                if (login.permission)
                {
                    var item = (ComboboxItem)placeComboBox.SelectedItem;
                    login.cityID        = item.Value;
                    newDaftar.Id        = utl.idGenerator(login.cityID, newDaftar.Date, newDaftar.BillDetailCode);
                    newDaftar.CityID    = login.cityID;
                    newDaftar.PlaceName = item.Text;
                }
                else
                {
                    newDaftar.Id        = utl.idGenerator(login.cityID, newDaftar.Date, newDaftar.BillDetailCode);
                    newDaftar.CityID    = login.cityID;
                    newDaftar.PlaceName = login.cityName;
                }



                SqlManipulator sql = new SqlManipulator();
                if (sql.isRestricted(newDaftar, login.permission))
                {
                    MessageBox.Show("دسترسی شما به این تاریخ توسط مدیر سیستم محدود شده است", "خطا",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                ;

                Reporter rpt = new Reporter(sql.addRow(newDaftar), (int)errorImages.info);
                rpt.Show();


                form.refreshLastState(this.lastState, pageNumber, false);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Data.ToString(),
                                "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                MessageBox.Show("ورودی های  خود را کنترل نمایید");
            }
        }