Пример #1
0
        /// <summary>
        /// This method saves the Item details in the database
        /// </summary>

        protected void btnSave_Click(object sender, EventArgs e)
        {
            IItem     objItem = BOFactory.ViewItemBOFactory.CreateItemobject();
            IAdminBLL objBLL  = AdminBLLFactory.CreateAdminBLLObject();
            int       itemId  = Convert.ToInt32(Request.QueryString["ItemID"]);

            try
            {
                if (itemId != 0)
                {
                    objItem.ItemName     = txtItemName.Text;
                    objItem.ItemID       = itemId;
                    objItem.ItemCategory = Convert.ToInt32(ddlCategory.SelectedValue);
                    objItem.ItemQuantity = Convert.ToInt32(txtItemQuantity.Text);
                    //objItem.ItemClosingCount = Convert.ToInt32(txtItemClosingCount.Text);
                    objItem.ItemDiscount = Convert.ToInt32(txtItemDiscount.Text);
                    objItem.ItemPrice    = Convert.ToInt32(txtItemPrice.Text);

                    bool update = objBLL.UpdateItemDetails(objItem);
                    lblShowItemId.Text = "Item Details updated successfully.";
                }
                else if (Convert.ToInt32(txtItemDiscount.Text) > 50)
                {
                    lblShowItemId.Text  = "";
                    lblShowMessage.Text = "Discount cannot be more than 50%";
                }
                else
                {
                    lblShowMessage.Text  = "";
                    objItem.ItemName     = txtItemName.Text;
                    objItem.ItemCategory = Convert.ToInt32(ddlCategory.SelectedValue);
                    objItem.ItemQuantity = Convert.ToInt32(txtItemQuantity.Text);
                    //objItem.ItemClosingCount = Convert.ToInt32(txtItemClosingCount.Text);
                    objItem.ItemDiscount = Convert.ToInt32(txtItemDiscount.Text);
                    objItem.ItemPrice    = Convert.ToInt32(txtItemPrice.Text);
                    bool itemID = objBLL.AddItemDetails(objItem);
                    lblShowItemId.Text = "Item details saved successfully. The Item ID is " + objItem.ItemID;
                }
            }
            catch (Exception ex)
            {
                lblShowItemId.Text = "An error occurred while saving item details";
            }
            finally
            {
                objItem = null;
                objBLL  = null;
            }
        }