Beispiel #1
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            DTO_FOOD_CATEGORY food_category_DTO = new DTO_FOOD_CATEGORY();

            food_category_DTO.ID_CAT  = txbID.Text;
            food_category_DTO.NAMECAT = txbName.Text;
            bool result = food_category_BUS.Insert(food_category_DTO);

            if (result)
            {
                MessageBox.Show("Inserted...", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                String nextID = "";
                food_category_BUS.NextID(ref nextID);
                txbID.Text = nextID.ToString();
            }
            else
            {
                MessageBox.Show("Error...", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        public bool Insert(DTO_FOOD_CATEGORY food_category)
        {
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO [FOOD_CATEGORY] VALUES(@ID_CAT, @NAMECAT)", conn);
                cmd.Parameters.AddWithValue("@ID_CAT", food_category.ID_CAT);
                cmd.Parameters.AddWithValue("@NAMECAT", food_category.NAMECAT);
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }

            catch (Exception e)
            { }

            finally
            {
                conn.Close();
            }

            return(false);
        }
Beispiel #3
0
 public bool Insert(DTO_FOOD_CATEGORY dal)
 {
     return(food_category.Insert(dal));
 }