Ejemplo n.º 1
0
        private void AddUpdateItem()
        {
            errorProvider1.Clear();
            lblMessage.Clear();

            string itemName = txtItemName.Text.Trim();
            string itemDesc = txtaDesc.Text.Trim();
            string message  = string.Empty;



            if (itemName == string.Empty)
            {
                message = MessageManager.GetMessage("33");
                errorProvider1.SetError(txtItemName, message);
                lblMessage.SetMessage(message);
                return;
            }

            if (itemDesc == string.Empty)
            {
                message = MessageManager.GetMessage("34");
                errorProvider1.SetError(txtaDesc, message);
                lblMessage.SetMessage(message);
                return;
            }

            if (_itemId != 0)
            {
                if (_itemManagement.UpdateItem(_itemId, itemDesc, SessionParameters.UserID.ToString(), System.DateTime.Now.ToShortDateString()))
                {
                    lblMessage.SetMessage(MessageManager.GetMessage("35"));
                    Clear();
                }
                else
                {
                    lblMessage.SetMessage(MessageManager.GetMessage("36"));
                }
            }
            else
            {
                if (!_itemManagement.ItemExist(itemName))
                {
                    if (_itemManagement.AddNewItem(itemName, itemDesc, SessionParameters.UserID, System.DateTime.Now.ToShortDateString()))
                    {
                        lblMessage.SetMessage(MessageManager.GetMessage("38", itemName));
                        Clear();
                    }
                    else
                    {
                        lblMessage.SetMessage(MessageManager.GetMessage("36"));
                    }
                }
                else
                {
                    lblMessage.SetMessage(MessageManager.GetMessage("37", itemName));
                }
            }


            LoadData(string.Empty, string.Empty);
        }