private void cbbCategory_SelectedIndexChanged(object sender, EventArgs e) { string CategoryName = cbbCategory.SelectedItem.ToString(); DataTable dtIDCategory = AdminSettingController.IDCategory_Find(CategoryName).Tables[0]; string IDCategory = dtIDCategory.Rows[0][0].ToString(); DataTable dtSubCategory = AdminSettingController.SubCategory_Show(IDCategory).Tables[0]; cbbSubCategory.Items.Clear(); foreach (DataRow dr in dtSubCategory.Rows) { string SubCategoryName = dr["SubCategoryName"].ToString(); cbbSubCategory.Items.Add(SubCategoryName); } }
private void btnAddItems_Click(object sender, EventArgs e) { string ItemName = txtItemName.Text.Trim(); float ImportPrice = float.Parse(txtImportPrice.Text.Trim()); float SalePrice = float.Parse(txtSalePrice.Text.Trim()); string Description = txtDescription.Text.Trim(); string Orgin = txtOrgin.Text.Trim(); if (ItemImageName == "") { ItemImageName = "noImage.png"; } string Image = ItemImageName; string CategoryName = cbbCategory.SelectedItem.ToString(); DataTable dtIDCategory = AdminSettingController.IDCategory_Find(CategoryName).Tables[0]; string IDCategory = dtIDCategory.Rows[0][0].ToString(); string SubCategoryName = cbbSubCategory.SelectedItem.ToString(); DataTable dtIDSubcategory = AdminSettingController.IDSubCategory_Find(SubCategoryName).Tables[0]; string IDSubCategory = dtIDSubcategory.Rows[0][0].ToString(); bool check = AdminSettingController.AddItem(UserName, PassWord, ItemName, ImportPrice, SalePrice, Description, Orgin, IDCategory, IDSubCategory, Image, ref err); if (check == true) { DialogResult dialogResult; dialogResult = MessageBox.Show("Bạn đã thêm món ăn thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); if (dialogResult == DialogResult.OK) { txtItemName.Clear(); txtImportPrice.Clear(); txtSalePrice.Clear(); txtDescription.Clear(); txtOrgin.Clear(); cbbCategory.Items.Clear(); cbbCategory.Text = "Chọn loại"; cbbSubCategory.Items.Clear(); cbbSubCategory.Text = "Chọn danh mục"; ptBImageProduct.Image = null; } } else { MessageBox.Show("Đăng ký thất bại, xin thử lại lần nữa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void BtnCategory_Click(object sender, EventArgs e) { pnPanel.Controls.Clear(); this.pnPanel.Visible = true; Guna.UI.WinForms.GunaButton btn = sender as Guna.UI.WinForms.GunaButton; Guna.UI.WinForms.GunaPanel pn = new Guna.UI.WinForms.GunaPanel(); string CategoryName = btn.Text; if (CategoryName == "Rau") { pn.Location = new Point(3, 4); pnPanel.Location = new Point(233, 215); } if (CategoryName == "Củ") { pn.Location = new Point(3, 4);//38); pnPanel.Location = new Point(233, 249); } if (CategoryName == "Quả") { pn.Location = new Point(3, 4);//72); pnPanel.Location = new Point(233, 283); } if (CategoryName == "Hạt giống") { pn.Location = new Point(3, 4);//106); pnPanel.Location = new Point(233, 317); } if (CategoryName == "Phân bón") { pn.Location = new Point(3, 4);//140); pnPanel.Location = new Point(233, 351); } string IDCategory = AdminSettingController.IDCategory_Find(CategoryName).Tables[0].Rows[0][0].ToString(); DataTable dtSubCategory = AdminSettingController.SubCategory_Show(IDCategory).Tables[0]; pn.BackColor = Color.Silver; pn.Width = 217; pnPanel.Controls.Add(pn); int ybtn = 0; int count = 0; foreach (DataRow dr in dtSubCategory.Rows) { Guna.UI.WinForms.GunaButton btnSubCategory = new Guna.UI.WinForms.GunaButton(); btnSubCategory.Location = new Point(0, ybtn); btnSubCategory.Size = new Size(215, 35); btnSubCategory.Animated = true; btnSubCategory.BackColor = Color.Transparent; btnSubCategory.BaseColor = Color.Silver; btnSubCategory.BorderColor = Color.Black; btnSubCategory.ForeColor = Color.Black; btnSubCategory.BorderSize = 1; btnSubCategory.Cursor = Cursors.Hand; btnSubCategory.Font = new Font("Tahoma", 13, FontStyle.Bold); btnSubCategory.Image = null; btnSubCategory.OnHoverBaseColor = Color.DarkGray; btnSubCategory.Radius = 5; btnSubCategory.TextAlign = HorizontalAlignment.Center; btnSubCategory.Text = dr["SubCategoryName"].ToString(); btnSubCategory.Click += BtnSubCategory_Click; ybtn += 34; count++; pn.Controls.Add(btnSubCategory); } pn.Height = 35 * count; pnPanel.Height = 37 * count; }