Esempio n. 1
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            Items _Items = new Items();

            _Items.Code         = txtCode.Text;
            _Items.Name         = txtName.Text;
            _Items.ReorderLevel = 5;
            _Items.Size         = SizeDropDownList.SelectedItem.ToString();
            _Items.CategoriesId = Convert.ToInt32(CategoriesDropDownList.SelectedValue);

            if (CategoriesDropDownList.SelectedIndex > 0)
            {
                if (SizeDropDownList.SelectedIndex > 0)
                {
                    decimal AlreadyExistCaegory = _ItemRepository.AlreadyExistName(_Items);
                    if (AlreadyExistCaegory >= 1)
                    {
                        ShowMessage("This Item Already Here!!!...", MessageType.Warning);
                    }
                    else
                    {
                        int Savesuccess = _ItemRepository.Add(_Items);
                        if (Savesuccess > 0)
                        {
                            ShowMessage("Successfully Saved Item....", MessageType.Success);
                            LoadItem();
                            AutoCodeGenerate();
                            GetAllCategories();
                            txtName.Text = "";
                            CategoriesDropDownList.ClearSelection();
                            SizeDropDownList.ClearSelection();
                            //Response.Redirect(Request.Url.AbsoluteUri);
                        }
                        else
                        {
                            ShowMessage("Failed Saving Item", MessageType.Warning);
                        }
                    }
                }
                else
                {
                    ShowMessage("Select Size", MessageType.Warning);
                    SizeDropDownList.Focus();
                }
            }
            else
            {
                ShowMessage("At First Select Catgeory", MessageType.Warning);
                CategoriesDropDownList.Focus();
            }
        }
    protected void UpdateButton_Click(object sender, EventArgs e)
    {
        if (ProductDropDownList.SelectedValue == "0")
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Please select product.')", true);
            ColorDropDownList.Focus();
            return;
        }
        if (ColorDropDownList.SelectedValue == "")
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Please select Color.')", true);
            ColorDropDownList.Focus();
            return;
        }
        if (SizeDropDownList.SelectedValue == "0")
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Please select Size.')", true);
            SizeDropDownList.Focus();
            return;
        }
        decimal productValue = 0m;

        if (!Decimal.TryParse(ProductCostTextBox.Text, out productValue))
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Please enter correct product cost.')", true);
            ProductCostTextBox.Focus();
            return;
        }


        int typeIndex = Convert.ToInt32(Request.QueryString["typeIndex"]);
        int editIndex = Convert.ToInt32(Request.QueryString["editIndex"]);
        var orderItem = GetSubOrders(typeIndex).ElementAt(editIndex);

        orderItem.ExchangeTypeID             = Convert.ToInt32(TypesDropDownList.SelectedValue);
        orderItem.ExchangeCombinationID      = Convert.ToInt32(SizeDropDownList.SelectedValue);
        orderItem.ExchangeLensID             = Convert.ToInt32(LensDropDownList.SelectedValue);
        orderItem.ExchangePrescriptionLensID = Convert.ToInt32(PrescriptionDropDownList.SelectedValue);
        orderItem.ExchangeProductValue       = productValue;

        string description = "";

        if (TypesDropDownList.SelectedValue != "" && TypesDropDownList.SelectedValue != "0")
        {
            description = description + TypesDropDownList.SelectedItem.Text;
        }
        if (ProductDropDownList.SelectedValue != "" && ProductDropDownList.SelectedValue != "0")
        {
            description = description + ", " + ProductDropDownList.SelectedItem.Text;
        }
        if (ColorDropDownList.SelectedValue != "" && ColorDropDownList.SelectedValue != "0")
        {
            description = description + " - " + ColorDropDownList.SelectedItem.Text;
        }
        if (SizeDropDownList.SelectedValue != "" && SizeDropDownList.SelectedValue != "0")
        {
            description = description + " - " + SizeDropDownList.SelectedItem.Text;
        }
        if (LensDropDownList.SelectedValue != "" && LensDropDownList.SelectedValue != "0")
        {
            description = description + "<br />Lens: " + LensDropDownList.SelectedItem.Text;
        }
        if (PrescriptionDropDownList.SelectedValue != "" && PrescriptionDropDownList.SelectedValue != "0")
        {
            description = description + "<br />RX: " + PrescriptionDropDownList.SelectedItem.Text;
            UpdatePrescription(ref PrescriptionPanel, ref orderItem);
            description = description + "<br />" + orderItem.ExchangePrescriptionLensSizes;
        }

        orderItem.ExchangeData = string.Format("{0}:{1};{2}:{3};{4}:{5};{6}:{7};{8}:{9};{10}:{11};{12}:{13}", TypesDropDownList.SelectedValue, TypesDropDownList.SelectedItem.Text, ProductDropDownList.SelectedValue, ProductDropDownList.SelectedItem.Text, ColorDropDownList.SelectedValue, ColorDropDownList.SelectedItem.Text, SizeDropDownList.SelectedValue, SizeDropDownList.SelectedItem.Text, LensDropDownList.SelectedValue, LensDropDownList.SelectedItem.Text, PrescriptionDropDownList.SelectedValue, PrescriptionDropDownList.SelectedItem.Text, ProductCostTextBox.Text, orderItem.ExchangePrescriptionLensSizes);
        orderItem.ExchangeProductDescription = "<br/><strong>Exchange with :</strong>" + description;

        NotificationLiteral.Text = "Updated.";
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "hideExchangePopupControl();", true);
    }