public bool addService(Service rt, out string ServiceId)
 {
     var result = serviceDAT.addService(rt);
     if (result.Rows[0].ItemArray[0].ToString() == "0")
     {
         ServiceId = result.Rows[0].ItemArray[1].ToString();
         return true;
     }
     ServiceId = "";
     return false;
 }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (txtId.Text == string.Empty)
            {
                MessageBox.Show("You don't choose a service to edit!", "Infomations", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                Service rt = new Service()
                {
                    Id = txtId.Text,
                    Name = txtName.Text,
                    Price = decimal.Parse(txtPrice.Text.Trim()),
                    Unit = txtUnit.Text.Trim()
                };

                ServiceEdit ServiceEdit = new ServiceEdit(rt);
                ServiceEdit.EditCompletedHandler += FormServiceEdit_Completed;
                ServiceEdit.ShowDialog();
            }
        }
        public DataTable addService(Service rt)
        {
            try
            {
                int param = 3;

                string[] name = new string[param];
                object[] value = new object[param];

                name[0] = "@p_NAME"; value[0] = rt.Name;
                name[1] = "@p_PRICE"; value[1] = rt.Price;
                name[2] = "@p_UNIT"; value[2] = rt.Unit;

                return this.ExcuteStoreProcedure("Service_Ins", name, value);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Message = {1}", ex.Message);
            }

            return null;
        }
 public DataTable searchService(Service rt)
 {
     return serviceDAT.searchService(rt);
 }
 public bool updateService(Service rt)
 {
     return serviceDAT.updateService(rt);
 }
 public bool updateService(Service rt)
 {
     try
     {
         string sql = "Update Service set name = N'" + rt.Name + "', price = " + rt.Price.ToString().Replace(',', '.') + ",  unit = " + rt.Unit + "' where id = '" + rt.Id.Trim() + "'";
         int result = this.ExecuteNonQuery(sql);
         if (result != 0)
         {
             return true;
         }
     }
     catch (System.Exception ex)
     {
         Console.WriteLine("Message = {1}", ex.Message);
     }
     return false;
 }
        public DataTable searchService(Service rt)
        {
            try
            {
                string[] names = new string[5];
                object[] values = new object[5];

                names[0] = "@p_ID"; values[0] = rt.Id;
                names[1] = "@p_NAME"; values[1] = rt.Name;
                names[2] = "@p_PRICE"; values[2] = rt.Price;
                names[3] = "@p_UNIT"; values[3] = rt.Unit;
                names[4] = "@p_TOP"; values[4] = 0;

                return this.ExcuteStoreProcedure("Service_Search", names, values);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Message = {1}", ex.Message);
            }

            return null;
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (btnSearch.Text == "Reset")
            {
                this.resetUI();
                this.changeModeEditUI(true);
            }
            else
            {
                Service rt = new Service()
                {
                    Id = txtId.Text.Trim(),
                    Name = txtName.Text.Trim(),
                    Price = decimal.Parse(txtPrice.Text.Trim() == "" ? "0" : txtPrice.Text.Trim()),
                    Unit = txtUnit.Text.Trim()
                };

                this.dgvService.DataSource = serviceBLT.searchService(rt);
            }
        }