Example #1
0
 /// <summary>
 /// ثبت حساب معین جديد
 /// </summary>
 /// <param name="model">
 /// مدل پايه حساب معین
 /// </param>
 /// <returns></returns>
 public Models.ActionResultModelBinding InsertMoinAccount(Models.Moin model)
 {
     try
     {
         using (var repo = new Repository.Repository(this, "usp_insertAccountingMoein"))
         {
             repo.cmd.Parameters.AddWithValue("@code", model.Code);
             repo.cmd.Parameters.AddWithValue("@title", model.Title);
             repo.cmd.Parameters.AddWithValue("@natureId", model.NatureId);
             repo.cmd.Parameters.AddWithValue("@isDefault", model.IsDefault);
             repo.cmd.Parameters.AddWithValue("@isPermanent", model.IsPermanent);
             repo.cmd.Parameters.AddWithValue("@kolId", model.KolId);
             var param = repo.cmd.Parameters.AddWithValue("@tafiliGroupList", model.TafsiliGroupBinding);
             param.SqlDbType = System.Data.SqlDbType.Structured;
             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
         });
     }
 }
Example #2
0
 /// <summary>
 /// حذف يك حساب معین
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public Models.ActionResultModelBinding RemoveMoinAccount(Models.Moin model, bool confirmDeleteSubdivision)
 {
     try
     {
         using (var repo = new Repository.Repository(this, "usp_deleteAccountingMoin"))
         {
             repo.cmd.Parameters.AddWithValue("@id", model.Id);
             // repo.cmd.Parameters.AddWithValue("@confirmDeleteSubdivision", confirmDeleteSubdivision);
             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
         });
     }
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Models.ActionResultModelBinding result = null;
     try
     {
         Models.Moin newMoinAccountObject = new Models.Moin
         {
             Id          = model.Id,
             Code        = txtCode.Text,
             Title       = txtTitle.Text,
             NatureId    = cmbNature.SelectedValue == null ? default(short) : (short)cmbNature.SelectedValue,
             IsDefault   = chkIsDefault.IsChecked.Value,
             IsPermanent = chkIsTemprory.IsChecked.Value ? false : true,
             KolId       = kolSelector.lblValue.Tag != null ? (int)((Tuple <long, string>)kolSelector.lblValue.Tag).Item1:0,
         };
         newMoinAccountObject.SetDataTable(tafsiliGroupSelector.lblValue.Tag != null ? (List <long>)tafsiliGroupSelector.lblValue.Tag : new List <long>());
         var errors = newMoinAccountObject.Validate(null);
         if (errors.Count() > 0)
         {
             foreach (var item in errors)
             {
                 MessageBox.Show(item.ErrorMessage);
             }
         }
         else
         {
             using (var controller = new Controllers.MoinController())
             {
                 result = controller.UpdateMoinAccount(newMoinAccountObject);
             }
         }
     }
     catch (Exception c)
     {
         MessageBox.Show(c.Message);
         return;
     }
     finally
     {
         if (result != null)
         {
             MessageBox.Show(result.Message);
             if (result.Status == Models.ActionResult.Success)
             {
                 Close();
             }
         }
     }
 }
 public W_EditMoin(Models.Moin _model)
 {
     InitializeComponent();
     FillNatureComboBox();
     kolSelector.Type          = Models.Common.SelectorType.KolAccounts;
     tafsiliGroupSelector.Type = Models.Common.SelectorType.TafsiliGroup;
     model = _model;
     kolSelector.lblValue.Content          = _model.KolTitle;
     kolSelector.lblValue.Tag              = new Tuple <long, string>(model.KolId, model.KolCode);
     tafsiliGroupSelector.lblValue.Content = model.TafsiliGroupBindingString;
     tafsiliGroupSelector.lblValue.Tag     = model.TafsiliGroupBinding;
     txtParentCode.Text      = model.KolCode;
     txtCode.Text            = model.Code;
     txtTitle.Text           = model.Title;
     cmbNature.SelectedValue = model.NatureId;
     chkIsDefault.IsChecked  = model.IsDefault;
 }