private void buttonAddProduct_Click(object sender, EventArgs e) { try { if (txtLibelle.Text == "" || txtPrice.Text == "" || txtQuantity.Text == "" || txtRef.Text == "") { msgs = new CustomMessageBox("All fields Must be Filled"); lblPrice.Visible = true; msgs.ShowDialog(); return; } if (!int.TryParse(txtQuantity.Text, out parsed)) { msgs = new CustomMessageBox("Enter a numeric Value !"); msgs.ShowDialog(); lblQuantity.Visible = true; return; } if (!float.TryParse(txtPrice.Text, out floatParsed)) { msgs = new CustomMessageBox("Enter a numeric Value !"); msgs.ShowDialog(); return; } var q = (from x in cnx.PRODUCTs where x.REFERENCE == txtRef.Text select x).Count(); if (q > 0) { msgs = new CustomMessageBox("Reference Already Exists !"); msgs.ShowDialog(); return; } else { PRODUCT pr = new PRODUCT(); pr.REFERENCE = txtRef.Text; pr.NAME = txtLibelle.Text; pr.PRICE = float.Parse(txtPrice.Text); pr.QUANTITY = int.Parse(txtQuantity.Text); pr.IDADMINS = IDAdmin; pr.images = imgName; pr.ADDDATE = DateTime.Now; cnx.PRODUCTs.InsertOnSubmit(pr); if (imgName != "") { File.Copy(imageLocation, Application.StartupPath + @"\images\" + pr.REFERENCE + imgName); } cnx.SubmitChanges(); msgs = new CustomMessageBox("Added Successfully !"); msgs.ShowDialog(); clearFields(); loadData(); } } catch { msgs = new CustomMessageBox("Something Went Wrong !"); msgs.ShowDialog(); } }
partial void DeletePRODUCT(PRODUCT instance);
partial void UpdatePRODUCT(PRODUCT instance);
partial void InsertPRODUCT(PRODUCT instance);
private void detach_PRODUCTs(PRODUCT entity) { this.SendPropertyChanging(); entity.LOGIN = null; }
private void attach_PRODUCTs(PRODUCT entity) { this.SendPropertyChanging(); entity.LOGIN = this; }