Exemplo n.º 1
0
 public Editor(RepositortAbstracts.IProductCategory catrepo, RepositortAbstracts.IProductUnit unit, RepositortAbstracts.IProductParameter paramsRepo, RepositortAbstracts.IProductParameterValue Pvalue)
 {
     this.catrepo    = catrepo;
     this.unit       = unit;
     this.Pvalue     = Pvalue;
     this.paramsRepo = paramsRepo;
     _OldParameterId = Entity.ProductCategoryId;
 }
        public ProductParameterRepositoryTests()
        {
            var contaxt     = new DataLayer.InventoryDBContext();
            var relateduser = contaxt.Users.FirstOrDefault(u => u.Username.Equals("admin"));
            var identity    = new GenericIdentity(relateduser.Username);
            var roles       = relateduser.Roles.Select(p => p.Title).ToArray();
            var principal   = new GenericPrincipal(identity, roles);

            System.Threading.Thread.CurrentPrincipal = principal;
            _ProductParameter = new Repositories.ProductParameterRepository();
            EProductParameter = new Entities.ProductParameter()
            {
                ProductCategoryId = 1,
                Key         = "Key",
                Title       = "Title",
                Description = "Description",
            };
        }
Exemplo n.º 3
0
        public List(RepositortAbstracts.IProductParameter paramsRepo)
        {
            this.paramsRepo = paramsRepo;

            AddAction("افزودن", btn =>
            {
                var result = viewEngine.ViewInForm <view.ProductParameter.Editor>(null, true);
                if (result.DialogResult == DialogResult.OK)
                {
                    result.Entity.ProductCategoryId = ParentCategoryId;
                    if (paramsRepo.Add(result.Entity))
                    {
                        MessageBox.Show("پارامتر با موفقیت ثبت شد", "پیام سیستم");
                        grid.AddItem(result.Entity);
                        grid.ResetBindings();
                    }
                    else
                    {
                        MessageBox.Show("مشکل در پارامتر شرکت به وجود آمد", "پیام سیستم");
                    }
                }
            });
            AddAction("ویرایش", btn =>
            {
                var result = viewEngine.ViewInForm <view.ProductParameter.Editor>(editor =>
                {
                    editor.Entity = grid.CurrentItem;
                }, true);
                if (result.DialogResult == DialogResult.OK)
                {
                    if (paramsRepo.Update(result.Entity))
                    {
                        MessageBox.Show("پارامتر با موفقیت ویرایش شد", "پیام سیستم");
                        grid.ResetBindings();
                    }
                    else
                    {
                        MessageBox.Show("مشکل در ویرایش پارامتر به وجود آمد", "پیام سیستم");
                    }
                }
            });
            AddAction("حذف", btn =>
            {
                if (grid.CurrentItem == null)
                {
                    return;
                }
                if (MessageBox.Show("آیا میخواهید حذف کنید ؟", "پیام سیستم", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    int dn = paramsRepo.CanDelete(grid.CurrentItem.ProductParameterId);
                    if (dn != 0)
                    {
                        MessageBox.Show("این مورد به علت وابستگی به" + dn + "مواردامکان پاک شدن ندارد", "پیام سیستم");
                    }
                    else
                    {
                        if (paramsRepo.Delete(grid.CurrentItem.ProductParameterId))
                        {
                            MessageBox.Show("پارامتر با موفقیت حذف شد", "پیام سیستم");
                            grid.RemoveCurrent();
                            grid.ResetBindings();
                        }
                        else
                        {
                            MessageBox.Show("مشکل در حذف پارامتر به وجود آمد", "پیام سیستم");
                        }
                    }
                }
            });
        }