コード例 #1
0
        private void btnDeleteSheet_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Would you like to delete this Product Pack Size?", "Delete Product Pack Size", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                try
                {
                    Pack_Size prodT2 = new Pack_Size();
                    prodT2 = db.Pack_Size.Find(tempID);

                    db.Pack_Size.Remove(prodT2);
                    db.SaveChanges();

                    int    packSize        = prodT2.Pack_Size_ID;
                    string Pack_Size_Value = Convert.ToString(prodT2);
                    MessageBox.Show("Pack Size Successfully Deleted");
                    this.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("Pack Size deleted, Pack size is in use");
                }
            }
        }
コード例 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateIfPackSizeExists(rtxtDescription.Text) == true)
                {
                    MessageBox.Show("Pack Size exists");
                    correct = false;
                }
                correct = true;
                Pack_Size packS = new Pack_Size();

                if (rtxtDescription.Text == "")
                {
                    lblPackSize.Visible = true;

                    //MessageBox.Show("Please Enter Product pack size details");
                    correct = false;
                }

                if (correct == true)
                {
                    packS.Pack_Size_Description = rtxtDescription.Text;
                    db.Pack_Size.Add(packS);

                    db.SaveChanges();

                    int    Pack_Size_ID = packS.Pack_Size_ID;
                    string ProdT_value  = Convert.ToString(packS);
                    MessageBox.Show("Product Pack Size Successfully Added");
                    this.Close();
                }
            }
            catch
            {
            }
        }