private void btnEdit_Click(object sender, EventArgs e) { string id = txtId.Text; if (!string.IsNullOrEmpty(id)) { var drink = drinkController.Get(Int32.Parse(id)); drink.Name = txtName.Text; drink.Descript = txtDescript.Text; drink.DrinkCategoryId = GetCategoryId(); drink.Price = (txtPrice.Text == "") ? 0 : decimal.Parse(txtPrice.Text); byte[] img = null; if (!string.IsNullOrEmpty(fileImg)) { img = ImageStatic.ConvertImg2Binary(pictureBox1.BackgroundImage); } if (img != null) { drink.Img = img; } drinkController.Update(drink); MessageBox.Show("You updated drink successfully", "Notification"); loadTable(); } }
private void btnAdd_Click(object sender, EventArgs e) { string name = txtName.Text; var categoryId = GetCategoryId(); string descript = txtDescript.Text; decimal price = (txtPrice.Text == "")? 0 : decimal.Parse(txtPrice.Text); byte[] img = null; if (!string.IsNullOrEmpty(fileImg)) { img = ImageStatic.ConvertImg2Binary(pictureBox1.BackgroundImage); } var drink = new DrinkDto { Name = name, DrinkCategoryId = categoryId, Descript = descript, Price = price, Img = img, Status = true }; drinkController.Create(drink); MessageBox.Show("You added drink successfully", "Notification"); loadTable(); }
private void txtId_TextChanged(object sender, EventArgs e) { if (dataGridView1.SelectedCells.Count > 0 && !string.IsNullOrEmpty(txtId.Text)) { string position = (string)dataGridView1.SelectedCells[0].OwningRow.Cells["Position"].Value; cbxPosition.SelectedItem = position; bool status = (bool)dataGridView1.SelectedCells[0].OwningRow.Cells["Status"].Value; if (status == false) { changeVisibleBtn(true, false); } else { changeVisibleBtn(false, true); } bool gender = (bool)dataGridView1.SelectedCells[0].OwningRow.Cells["Gender"].Value; if (gender) { radMale.Checked = true; } else { radFemale.Checked = true; } int id = (int)dataGridView1.SelectedCells[0].OwningRow.Cells["Id"].Value; var accController = new AccountController(); var acc = accController.GetByStaffId(id); btnCreateAcc.Visible = (acc == null && status == true) ? true : false; byte[] img = (byte[])dataGridView1.SelectedCells[0].OwningRow.Cells["Img"].Value; if (img != null) { picImg.BackgroundImage = ImageStatic.ConvertBinary2Img(img); } else { picImg.BackgroundImage = null; } } }
private void txtId_TextChanged(object sender, EventArgs e) { if (dataGridView1.SelectedCells.Count > 0 && !string.IsNullOrEmpty(txtId.Text)) { int id = (int)dataGridView1.SelectedCells[0].OwningRow.Cells["DrinkCategoryId"].Value; int index = -1; int i = 0; foreach (DrinkCategoryDto c in cbxCategory.Items) { if (c.Id == id) { index = i; break; } i++; } cbxCategory.SelectedIndex = index; bool status = (bool)dataGridView1.SelectedCells[0].OwningRow.Cells["Status"].Value; if (status == false) { changeVisibleBtn(true, false); } else { changeVisibleBtn(false, true); } byte[] img = (byte[])dataGridView1.SelectedCells[0].OwningRow.Cells["Img"].Value; if (img != null) { pictureBox1.BackgroundImage = ImageStatic.ConvertBinary2Img(img); } else { pictureBox1.BackgroundImage = null; } } else { pictureBox1.BackgroundImage = null; } }
private void Create_pnl(DrinkDto drink) { var pic = new PictureBox(); pic.Width = 235; pic.Height = 235; pic.BackgroundImageLayout = ImageLayout.Stretch; pic.Cursor = Cursors.Hand; Image img = null; if (drink.Img != null) { img = ImageStatic.ConvertBinary2Img(drink.Img); } pic.BackgroundImage = img; var _lblname = new Label(); _lblname.Text = drink.Name; _lblname.Dock = DockStyle.Bottom; _lblname.Height = 55; _lblname.TextAlign = ContentAlignment.MiddleCenter; _lblname.BackColor = Color.FromArgb(241, 242, 246); _lblname.ForeColor = Color.FromArgb(0, 0, 0); _lblname.Font = new Font("Segoe UI Symbol", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); pic.Controls.Add(_lblname); var _lblprice = new Label(); _lblprice.Text = drink.Price.ToString("#,##"); _lblprice.TextAlign = ContentAlignment.MiddleCenter; _lblprice.Height = 35; _lblprice.Width = 100; _lblprice.BackColor = Color.FromArgb(55, 66, 250); _lblprice.ForeColor = Color.FromArgb(255, 255, 255); _lblprice.Font = new Font("Segoe UI Symbol", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); pic.Controls.Add(_lblprice); flowLayoutPanel1.Controls.Add(pic); pic.Tag = drink.Id.ToString(); pic.Click += new EventHandler(OnClick); }
private void btnAdd_Click(object sender, EventArgs e) { string name = txtName.Text; bool gender = GetGender(); string email = txtEmail.Text; string phone = txtPhone.Text; var date = dateTimePicker1.Value; string street = txtStreet.Text; string ward = txtWard.Text; string city = txtCity.Text; string position = cbxPosition.SelectedItem.ToString(); decimal salary = (txtSalary.Text == "") ? 0 : decimal.Parse(txtSalary.Text); byte[] img = null; if (!string.IsNullOrEmpty(fileImg)) { img = ImageStatic.ConvertImg2Binary(picImg.BackgroundImage); } staffController.Create( new StaffDto { Name = name, Gender = gender, Email = email, Phone = phone, DateOfBirth = date, Street = street, Ward = ward, City = city, Position = position, Salary = salary, Img = img, Status = true }); MessageBox.Show("You added staff successfully", "Notification"); loadTable(); }
private void btnEdit_Click(object sender, EventArgs e) { string id = txtId.Text; if (!string.IsNullOrEmpty(id)) { var staff = staffController.Get(Int32.Parse(id)); staff.Name = txtName.Text; staff.Gender = GetGender(); staff.Email = txtEmail.Text; staff.DateOfBirth = dateTimePicker1.Value; staff.Phone = txtPhone.Text; staff.Street = txtStreet.Text; staff.Ward = txtWard.Text; staff.City = txtCity.Text; staff.Position = cbxPosition.SelectedItem.ToString(); staff.Salary = (txtSalary.Text == "") ? 0 : decimal.Parse(txtSalary.Text); byte[] img = null; if (!string.IsNullOrEmpty(fileImg)) { img = ImageStatic.ConvertImg2Binary(picImg.BackgroundImage); } if (img != null) { staff.Img = img; } staffController.Update(staff); MessageBox.Show("You updated staff successfully", "Notification"); loadTable(); } }
public static void AddPath(this ImageStatic img, string dirPath) { img.Sprite = img.Full; img.Full = dirPath + @"\" + img.Full; }