コード例 #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();
            }
        }