private void frmComboView_Load(object sender, EventArgs e) { listBox1.Text = ""; // MessageBox.Show(Convert.ToString(listBox1.Items.Count)); cmbComboType.ValueMember = "Combo_Type_ID"; cmbComboType.DisplayMember = "Combo_Description"; cmbComboType.DataSource = db.Combo_Type.ToList(); var items = from obj in db.Menu_Item join obj2 in db.Menu_Item_Price on obj.Menu_Item_ID equals obj2.Menu_Price_ID select new { ItemID = obj.Menu_Item_ID, ItemName = obj.Menu_Item_Name, ItemPrice = obj2.Menu_Price, ItemDescription = obj.Menu_Item_Description }; dgvMenu.ForeColor = Color.Black; dgvMenu.DataSource = items.ToList(); dgvMenu.ClearSelection(); var items2 = from obj in db.Stock_Item join obj2 in db.Stock_Price on obj.Stock_ID equals obj2.Stock_Price_ID select new { ItemID = obj.Stock_ID, ItemName = obj.Stock_Item_Name, ItemPrice = obj2.Stock_Price1, ItemDescription = obj.Stock_Item_Description }; dgvProd.ForeColor = Color.Black; dgvProd.DataSource = items2.ToList(); dgvProd.ClearSelection(); int id = Globals.Combopassing; Combo selItem = db.Comboes.FirstOrDefault(c => c.Combo_ID == id); string[] vals = Regex.Split(selItem.Combo_Description, "\n"); for (int i = 0; i < vals.Length; i++) { listBox1.Items.Add(vals[i]); //MessageBox.Show(vals[i]); } ItemsPicture pic = db.ItemsPictures.FirstOrDefault(c => c.Combo_Item_ID == id); // Image n = (Bitmap)((new ImageConverter()).ConvertFrom(pic.imageVar)); pbxCombo.Image = Globals.converBinToImage(pic.imageVar); txtComboName.Text = selItem.Combo_Name; txtComboPrice.Text = Convert.ToString(selItem.Combo_Price); Globals.browse = false; }
private void update_Employee_Details_Load(object sender, EventArgs e) { MmasweEntities5 db = new MmasweEntities5(); int id = Globals.Employeepassing; try { Employee EmEdited = db.Employees.FirstOrDefault(c => c.Employee_ID == id); txtName.Text = EmEdited.Employee_Name; txtSurname.Text = EmEdited.Employee_Surname; txtAddress.Text = EmEdited.Adress; txtNextOfKin.Text = EmEdited.Next_Of_Kin_Name; txtNKC.Text = EmEdited.Next_Of_Kin_Contact_Number.ToString(); txtEmail.Text = EmEdited.Email_Adress; txtIdNumber.Text = EmEdited.Employee_ID.ToString(); ItemsPicture pic = db.ItemsPictures.FirstOrDefault(c => c.EmployeeID == id); // Image n = (Bitmap)((new ImageConverter()).ConvertFrom(pic.imageVar)); pictureBox1.Image = Globals.converBinToImage(pic.imageVar); } catch (Exception i) { MessageBox.Show(i.ToString()); } }
private void button2_Click(object sender, EventArgs e) { // saveFileDialog1.InitialDirectory = @"C:\Users\phindulo\Pictures"; //if(saveFileDialog1.ShowDialog() == DialogResult.OK) //{ // pictureBox1.Image.Save(saveFileDialog1.FileName); try { ItemsPicture itempic = new ItemsPicture(); { itempic.ItemName = Globals.emNameImage; itempic.imageVar = Globals.ConvertImageToBinary(pictureBox1.Image); itempic.ImageID = Globals.imageIdEmployee; itempic.EmployeeID = Globals.imageIdEmployee; db.ItemsPictures.Add(itempic); db.SaveChanges(); Globals.imageIdEmployee = 0; Globals.emNameImage = ""; Globals.refresher = true; this.Close(); } } catch (Exception i) { MessageBox.Show(i.ToString()); } // } }
private void button7_Click(object sender, EventArgs e) { string phrase = txtMenuPrice.Text; int number; bool isNumeric = int.TryParse(phrase, out number); if (isNumeric == true) { int id = Globals.MenuCombopassing; Menu_Item item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id); Menu_Item_Type type = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Description == cmbMenuItemType.Text); Menu_Item_Price price = db.Menu_Item_Price.FirstOrDefault(c => c.Menu_Price_ID == id); price.Menu_Price = Convert.ToDouble(txtMenuPrice.Text); // db.Menu_Item_Price.Add(price); item.Menu_Item_Name = txtMenuItemName.Text; item.Menu_Item_Description = richDescription.Text; item.Menu_Item_Type_ID = type.Menu_Item_Type_ID; item.Menu_Item_Price = price.Menu_Price; item.Menu_Price_ID = price.Menu_Price_ID; //item.fileName =fileName = ConvertImageToBinary(pictureBox1.Image); // db.Menu_Item.Add(item); //item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_Name == txtMenuItemName.Text); ItemsPicture itempic = db.ItemsPictures.FirstOrDefault(c => c.Menu_Item_ID == id); { if ((Globals.browse == true) && (itempic != null)) { itempic.ItemName = Globals.fileName; itempic.imageVar = Globals.ConvertImageToBinary(pictureBox1.Image); // itempic.ImageID = item.Combo_ID; // Globals.browse = false; } } //itempic.ImageID = item.Menu_Item_ID; // itempic.Menu_Item_ID = item.Menu_Item_ID; //db.ItemsPictures.Add(itempic); db.SaveChanges(); Globals.refresher = true; MessageBox.Show("Menu item updated successfully"); this.Close(); } else { MessageBox.Show("Error: Values entered is not in correct format(not numeric)"); } }
private /*async*/ void button7_Click(object sender, EventArgs e) { string phrase = txtMenuPrice.Text; int number; bool isNumeric = int.TryParse(phrase, out number); if (isNumeric == true) { Menu_Item item = new Menu_Item(); Menu_Item_Type type = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Description == cmbMenuItemType.Text); Menu_Item_Price price = new Menu_Item_Price(); price.Menu_Price = Convert.ToDouble(txtMenuPrice.Text); db.Menu_Item_Price.Add(price); item.Menu_Item_Name = txtMenuItemName.Text; item.Menu_Item_Description = richDescription.Text; item.Menu_Item_Type_ID = type.Menu_Item_Type_ID; item.Menu_Item_Price = price.Menu_Price; item.Menu_Price_ID = price.Menu_Price_ID; //item.fileName =fileName = ConvertImageToBinary(pictureBox1.Image); db.Menu_Item.Add(item); //item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_Name == txtMenuItemName.Text); ItemsPicture itempic = new ItemsPicture(); { itempic.ItemName = item.Menu_Item_Name; itempic.imageVar = Globals.ConvertImageToBinary(pictureBox1.Image); itempic.ImageID = item.Menu_Item_ID; itempic.Menu_Item_ID = item.Menu_Item_ID; db.ItemsPictures.Add(itempic); //db.SaveChanges(); } db.SaveChanges(); Globals.refresher = true; MessageBox.Show("Menu item added successfully"); txtMenuItemName.Text = ""; txtMenuPrice.Text = ""; richDescription.Text = ""; pictureBox1.Image = null; } else { MessageBox.Show("Error: Values entered is not in correct format(not numeric)"); } }
private void button9_Click(object sender, EventArgs e) { int dent = id2; ItemsPicture pic = db.ItemsPictures.FirstOrDefault(c => c.ImageID == dent); if (pic != null) { pbx2.Image = Globals.converBinToImage(pic.imageVar); int rowindex = dgvDDisplayImages.CurrentCell.RowIndex; dynamic val = dgvDDisplayImages.Rows[rowindex].Cells[1].Value; lbl2.Text = val; } else { MessageBox.Show("Picture not found"); } }
private void frmMaintain_Menu_Item_Load(object sender, EventArgs e) { cmbMenuItemType.ValueMember = "Menu_Item_Type_ID"; cmbMenuItemType.DisplayMember = "Menu_Item_Description"; cmbMenuItemType.DataSource = db.Menu_Item_Type.ToList(); int id = Globals.MenuCombopassing; ItemsPicture pic = db.ItemsPictures.FirstOrDefault(c => c.Menu_Item_ID == id); // Image n = (Bitmap)((new ImageConverter()).ConvertFrom(pic.imageVar)); Menu_Item item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id); Menu_Item_Price price = db.Menu_Item_Price.FirstOrDefault(c => c.Menu_Price_ID == id); Menu_Item_Type type = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Type_ID == item.Menu_Item_Type_ID); pictureBox1.Image = Globals.converBinToImage(pic.imageVar); txtMenuItemName.Text = item.Menu_Item_Name; txtMenuPrice.Text = Convert.ToString(price.Menu_Price); cmbMenuItemType.Text = type.Menu_Item_Description; richDescription.Text = item.Menu_Item_Description; Globals.browse = false; }
private void btnSaveCombo_Click(object sender, EventArgs e) { if (pbxCombo.Image != null) { string phrase = txtComboPrice.Text; double number; bool isNumeric = double.TryParse(phrase, out number); if (isNumeric == true) { if ((Convert.ToDouble(txtComboPrice.Text) > 0) && (txtComboName.Text != "")) { if ((listBox1.Items.Count > 0) /*&& (listBox1.Text != "")*/) { int id = Globals.Combopassing; Combo_Price price = db.Combo_Price.FirstOrDefault(c => c.Combo_Price_ID == id); price.Combo_Price1 = Convert.ToDouble(txtComboPrice.Text); price.Combo_Price_Date = DateTime.Today; //db.Combo_Price.Add(price); int num = listBox1.Items.Count; string str = ""; for (int i = 0; i < num; i++) { str = str + listBox1.Items[i].ToString(); } Combo_Type type = db.Combo_Type.FirstOrDefault(c => c.Combo_Description == cmbComboType.Text); Combo item = db.Comboes.FirstOrDefault(c => c.Combo_Price_ID == id); item.Combo_Name = txtComboName.Text; item.Combo_Price = Convert.ToDouble(txtComboPrice.Text); item.Combo_Description = str; item.Combo_Type_ID = type.Combo_Type_ID; item.Combo_Price_ID = price.Combo_Price_ID; //MessageBox.Show(item.Combo_Description); // db.Comboes.Add(item); ItemsPicture itempic = db.ItemsPictures.FirstOrDefault(c => c.Combo_Item_ID == id); { if (Globals.browse == true) { itempic.ItemName = Globals.fileName; itempic.imageVar = Globals.ConvertImageToBinary(pbxCombo.Image); // itempic.ImageID = item.Combo_ID; // Globals.browse = false; } } db.SaveChanges(); MessageBox.Show("Combo item updated successfully"); Globals.refresher = true; this.Close(); } else { MessageBox.Show("Error:No items added"); } } else { MessageBox.Show("Error:Price value too large OR less thatn zero/Combo name field is empty"); } } else { MessageBox.Show("Error: Price not in correct format"); } } else { MessageBox.Show("Upload a picture"); } }