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 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(); } }