Пример #1
0
        public IActionResult AddToStore(CreateInventoryItemViewModel model)
        {
            if (ModelState.IsValid)
            {
                var article = _unitOfWork.Articles.FindArticleById(model.ArticleId);

                if (article == null)
                {
                    ModelState.AddModelError(string.Empty, "Artikel not found`");
                    return(View(model));
                }

                var inventoryItem = model.ToModel();
                inventoryItem.Article = article;
                if (!string.IsNullOrWhiteSpace(model.Note))
                {
                    var note = new ItemNote
                    {
                        Text      = model.Note,
                        CreatedAt = DateTime.Now,
                        UserId    = _userManager.GetUserId(User),
                    };
                    inventoryItem.Notes.Add(note);
                }
                _unitOfWork.Inventories.AddInventoryItem(inventoryItem);
                _unitOfWork.SaveChanges();
                return(RedirectToAction("Index", "Inventory"));
            }

            model.Article = _unitOfWork.Articles.FindArticleById(model.ArticleId);
            return(View(model));
        }
Пример #2
0
        public Boolean update()
        {
            string qryStringMember;

            qryStringMember = "UPDATE tbl_item set " +
                              "item_name=@item_name, " +
                              "category=@category, " +
                              "brand=@brand, model=@model, " +
                              "selling_price=@selling_price, wholesale_price=@wholesale_price, " +
                              "description=@description, item_note=@item_note, " +
                              "supplier_id=@supplier_id " + "WHERE item_id=@item_id";
            try
            {
                Connect.CnSql = new MySqlConnection(Connect.ConnStr);
                Connect.CnSql = new MySqlConnection(Connect.ConnStr);
                Connect.CnSql.Open();
                Connect.CmSql = new MySqlCommand(qryStringMember, Connect.CnSql);
                Connect.CmSql.Parameters.AddWithValue("@item_name", ItemName.Trim());
                Connect.CmSql.Parameters.AddWithValue("@category", Category.Trim());
                Connect.CmSql.Parameters.AddWithValue("@brand", Brand.Trim());
                Connect.CmSql.Parameters.AddWithValue("@model", Model.Trim());
                Connect.CmSql.Parameters.AddWithValue("@selling_price", SellingPrice);
                Connect.CmSql.Parameters.AddWithValue("@wholesale_price", WholesalePrice);
                Connect.CmSql.Parameters.AddWithValue("@description", Description.Trim());
                Connect.CmSql.Parameters.AddWithValue("@item_note", ItemNote.Trim());
                Connect.CmSql.Parameters.AddWithValue("@supplier_id", SupplierId);
                Connect.CmSql.Parameters.AddWithValue("@item_id", ItemId);

                Trans = Connect.CnSql.BeginTransaction();
                Connect.CmSql.Transaction = Trans;
                Connect.CmSql.ExecuteNonQuery();
                Trans.Commit();

                return(true);
            }

            catch (MySqlException e)
            {
                XtraMessageBox.Show(e.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Trans.Rollback();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "General Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Trans.Rollback();
            }
            finally
            {
                Connect.CnSql.Close();
                Connect.CnSql.Dispose();
                Connect.CmSql.Dispose();
                Connect.CmSql = null;
                Connect.DrSql = null;
            }

            return(false);
        }
        public ItemNote Save(ItemNote itemNote)
        {
            var url     = string.Format("ItemNote/Save?apikey={0}&companyid={1}", _apiKey, _companyId);
            var request = new RestRequest(url, Method.POST)
            {
                JsonSerializer = new JsonSerializer()
            };

            request.RequestFormat = DataFormat.Json;
            request.AddBody(itemNote);
            var response = _client.Execute <ItemNote>(request);

            return(response.Data);
        }
        public void SaveItemNote()
        {
            var itemNote = new ItemNote
            {
                ItemId         = 0,
                Status         = true,
                ActionDate     = DateTime.Now,
                EntryDate      = DateTime.Now,
                HasAttachments = false,
                Subject        = "A note about this item",
                Note           = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi at scelerisque tortor."
            };

            var newItemNote = Api.ItemNoteRequest.Save(itemNote);
        }
Пример #5
0
        public Boolean add()
        {
            string qryStringMember;

            qryStringMember = "Insert into tbl_item (item_id, item_name, category, model, brand, selling_price, wholesale_price, description, item_note, date_added, supplier_id) VALUES (@item_id, @item_name, @category, @model, @brand, @selling_price, @wholesale_price, @description, @item_note, NOW(), @supplier_id)";

            try
            {
                Connect.CnSql = new MySqlConnection(Connect.ConnStr);
                Connect.CnSql.Open(); Connect.CmSql = new MySqlCommand(qryStringMember, Connect.CnSql);
                Connect.CmSql.Parameters.AddWithValue("@item_id", ItemId.Trim());
                Connect.CmSql.Parameters.AddWithValue("@item_name", ItemName.Trim());
                Connect.CmSql.Parameters.AddWithValue("@category", Category.Trim());
                Connect.CmSql.Parameters.AddWithValue("@model", Model.Trim());
                Connect.CmSql.Parameters.AddWithValue("@brand", Brand.Trim());
                Connect.CmSql.Parameters.AddWithValue("@selling_price", SellingPrice);
                Connect.CmSql.Parameters.AddWithValue("@wholesale_price", WholesalePrice);
                Connect.CmSql.Parameters.AddWithValue("@description", Description.Trim());
                Connect.CmSql.Parameters.AddWithValue("@item_note", ItemNote.Trim());
                Connect.CmSql.Parameters.AddWithValue("@supplier_id", SupplierId);

                Trans = Connect.CnSql.BeginTransaction();
                Connect.CmSql.Transaction = Trans;
                Connect.CmSql.ExecuteNonQuery();
                Trans.Commit();
                return(true);
            }
            catch (MySqlException e)
            {
                XtraMessageBox.Show(e.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Trans.Rollback();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "General Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Trans.Rollback();
            }
            finally
            {
                Connect.CnSql.Close();
                Connect.CnSql.Dispose();
                Connect.CmSql.Dispose();
                Connect.CmSql = null;
                Connect.DrSql = null;
            }
            return(false);
        }
Пример #6
0
        public Models.OperationReturnModel <bool> AddItem(ItemNote newNote)
        {
            Models.OperationReturnModel <bool> retVal = new Models.OperationReturnModel <bool>();
            try
            {
                _listService.SaveItem(this.AuthenticatedUser, this.SelectedUserContext, ListType.Notes, 0, new ListItemModel()
                {
                    ItemNumber = newNote.ItemNumber,
                    CatalogId  = newNote.CatalogId,
                    Notes      = newNote.Note
                });
                retVal.SuccessResponse = true;
                retVal.IsSuccess       = retVal.SuccessResponse;
            }
            catch (Exception ex)
            {
                _log.WriteErrorLog("AddItem", ex);
                retVal.ErrorMessage = ex.Message;
                retVal.IsSuccess    = false;
            }

            return(retVal);
        }