/// <summary>
        /// ثبت سال مالی جديد
        /// </summary>
        /// <param name="model">
        /// مدل پايه سال مالی
        /// </param>
        /// <returns></returns>
        public Models.ActionResultModelBinding InsertFiscalYear(Models.FiscalYear model)
        {
            try
            {
                using (var repo = new Repository.Repository(this, "usp_insertFiscalYear"))
                {
                    repo.cmd.Parameters.AddWithValue("@title", model.Title);
                    repo.cmd.Parameters.AddWithValue("@startDate", model.StartDate);
                    repo.cmd.Parameters.AddWithValue("@endDate", model.EndDate);
                    repo.cmd.Parameters.AddWithValue("@taxable", model.Taxable);
                    repo.cmd.Parameters.AddWithValue("@taxes", model.Taxes);
                    repo.cmd.Parameters.AddWithValue("@duties", model.Duties);
                    repo.cmd.Parameters.AddWithValue("@is_active", model.IsActive);

                    repo.ExecuteNonQuery();
                    return(new Models.ActionResultModelBinding
                    {
                        Message = repo.rMsg,
                        Status = repo.rCode == 1 ? Models.ActionResult.Success : Models.ActionResult.Failed
                    });
                }
            }
            catch (Exception c)
            {
                return(new Models.ActionResultModelBinding
                {
                    Message = c.Message,
                    Status = Models.ActionResult.Failed
                });
            }
        }
Ejemplo n.º 2
0
        private void insertButton_Click(object sender, RoutedEventArgs e)
        {
            Models.ActionResultModelBinding result = null;
            try
            {
                Models.FiscalYear newFiscalYear = new Models.FiscalYear
                {
                    Title     = txtTitle.Text,
                    StartDate = txtStartDate.Text,
                    EndDate   = txtEndDate.Text,
                    Taxable   = chkTaxable.IsChecked.Value,
                    Taxes     = Convert.ToDecimal(string.IsNullOrEmpty(txtTaxes.Text) ? "0":txtTaxes.Text),
                    Duties    = Convert.ToDecimal(string.IsNullOrEmpty(txtDuties.Text) ? "0":txtDuties.Text),
                    IsActive  = chkIsInactive.IsChecked.Value ? false:true,
                };

                /// var errors = newFiscalYear.Validate(null);
                //if (errors.Count() > 0)
                //{
                //    foreach (var item in errors)
                //    {
                //        MessageBox.Show(item.ErrorMessage);
                //    }
                //}
                //else
                using (var controller = new Controllers.FiscalYearController())
                {
                    result = controller.InsertFiscalYear(newFiscalYear);
                }
            }
            catch (Exception c)
            {
                MessageBox.Show(c.Message);
                return;
            }
            finally
            {
                if (result != null)
                {
                    MessageBox.Show(result.Message);
                    if (result.Status == Models.ActionResult.Success)
                    {
                        GetFiscalYears();
                    }
                }
            }
        }
        public W_EditFiscalYear(Models.FiscalYear model)
        {
            InitializeComponent();

            _model = model;
            if (model != null)
            {
                txtId.Text              = model.Id.ToString();
                txtTitle.Text           = model.Title;
                txtStartDate.Text       = model.StartDate;
                txtEndDate.Text         = model.EndDate;
                txtTaxes.Text           = model.Taxes.ToString("N2");
                txtDuties.Text          = model.Duties.ToString("N2");
                chkIsInactive.IsChecked = model.IsActive ? false:true;
                chkTaxable.IsChecked    = model.Taxable;
            }
        }