예제 #1
0
        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();
            }
        }
예제 #2
0
 partial void DeletePRODUCT(PRODUCT instance);
예제 #3
0
 partial void UpdatePRODUCT(PRODUCT instance);
예제 #4
0
 partial void InsertPRODUCT(PRODUCT instance);
예제 #5
0
 private void detach_PRODUCTs(PRODUCT entity)
 {
     this.SendPropertyChanging();
     entity.LOGIN = null;
 }
예제 #6
0
 private void attach_PRODUCTs(PRODUCT entity)
 {
     this.SendPropertyChanging();
     entity.LOGIN = this;
 }