Example #1
0
        public InventoryInsDeatilRepositoryTests()
        {
            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;
            _InventoryInsDeatil = new Repositories.InventoryInsDeatilRepository();
            EInventoryInsDeatil = new Entities.InventoryInsDeatil()
            {
                InventoryInsHeaderId = 1,
                ProductId            = 1,
                Amount = 1,
            };
        }
Example #2
0
 private void btnAddToList_Click(object sender, EventArgs e)
 {
     if (txtamount.Text == string.Empty && txttitle.Text == string.Empty)
     {
         MessageBox.Show("مقادیر را وارذ کنید", "پیام سیستم");
     }
     else
     {
         decimal amount;
         if (decimal.TryParse(txtamount.Text, out amount))
         {
             object obj = pro.GetAmount(_product.ProductId);
             if (obj is decimal)
             {
                 var ProductExist      = (decimal)obj;
                 var InventoryCapacity = pro.Capacity(_product.ProductCategoryId);
                 var NewProductExist   = ProductExist + amount;
                 if (NewProductExist <= InventoryCapacity)
                 {
                     var InentoryDeatiles = new Entities.InventoryInsDeatil()
                     {
                         Amount    = amount,
                         ProductId = _product.ProductId,
                     };
                     grid.AddItem(InentoryDeatiles);
                     grid.ResetBindings();
                     txtamount.Text = string.Empty;
                 }
                 else
                 {
                     MessageBox.Show("انبار ظرفیت ندارد", "پیام سیستم");
                 }
             }
             else
             {
                 MessageBox.Show("مشکل در بررسی ظرفیت", "پیام سیستم");
             }
         }
         else
         {
             MessageBox.Show("مقادیر وارد شده نامتعبراست", "پیام سیستم");
         }
     }
 }