示例#1
0
        public static Boolean Delete(ItemTO clsItem)
        {
            String myConnection = "Server=localhost;Database=gerenciadornf;Uid=root;Pwd=;";

            MySqlConnection connection = new MySqlConnection(myConnection);
            MySqlCommand cmd;
            connection.Open();

            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("DELETE FROM Item WHERE IDItem=@IDItem");

                cmd = connection.CreateCommand();

                cmd.CommandText = strSql.ToString();
                cmd.Parameters.AddWithValue("@IDItem", clsItem.IDItem);

                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
 protected void gvwItem_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     ItemTO clsItem = new ItemTO();
     Int32 ID = (Int32)gvwItem.DataKeys[e.RowIndex].Value;
     clsItem = ItemBLL.GetItemByID(ID);
     ItemBLL.Delete(clsItem);
     LoadGrid();
 }
示例#3
0
        public static ItemTO GetItemByID(int IDItem)
        {
            try
            {

                ItemTO clsItem = new ItemTO();

                String myConnection = "Server=localhost;Database=gerenciadornf;Uid=root;Pwd=;";

                MySqlConnection connection = new MySqlConnection(myConnection);
                MySqlCommand cmd;
                connection.Open();

                string strSql = "SELECT Item.* FROM Item WHERE Item.IDItem = @IDItem";

                cmd = connection.CreateCommand();
                cmd.CommandText = strSql;
                cmd.Parameters.AddWithValue("@IDItem", IDItem);
                cmd.ExecuteNonQuery();

                MySqlDataReader adap = cmd.ExecuteReader();
                while (adap.Read())
                {
                    clsItem.IDItem = Convert.ToInt32(adap["IDItem"]);
                    clsItem.Nome = adap["nome"].ToString();
                    clsItem.Descricao = adap["Descricao"].ToString();

                }

                return clsItem;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {

            }
        }
示例#4
0
        public static void insert(ItemTO clsItem)
        {
            String myConnection = "Server=localhost;Database=gerenciadornf;Uid=root;Pwd=;";

            MySqlConnection connection = new MySqlConnection(myConnection);
            MySqlCommand cmd;
            connection.Open();

            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("INSERT INTO Item(IDItem, Nome, Descricao) ");
                strSql.Append("VALUES (@IDItem, @Nome, @Descricao); ");
                strSql.Append("SELECT Item.* FROM Item WHERE Item.IDItem=@@IDENTITY;");

                cmd = connection.CreateCommand();

                cmd.CommandText = strSql.ToString();
                cmd.Parameters.AddWithValue("@IDItem", clsItem.IDItem);
                cmd.Parameters.AddWithValue("@Nome", clsItem.Nome );
                cmd.Parameters.AddWithValue("@Descricao", clsItem.Descricao);

                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
示例#5
0
        public static List<ItemTO> listaItemAll()
        {
            try
            {
                List<ItemTO> clsItems = new List<ItemTO>();

                String myConnection = "Server=localhost;Database=gerenciadornf;Uid=root;Pwd=;";

                MySqlConnection connection = new MySqlConnection(myConnection);
                MySqlCommand cmd;
                connection.Open();

                string strSql = "SELECT Item.* FROM Item";

                cmd = connection.CreateCommand();
                cmd.CommandText = strSql;
                cmd.ExecuteNonQuery();

                MySqlDataReader adap = cmd.ExecuteReader();

                while (adap.Read())
                {
                    ItemTO clsItem = new ItemTO();

                    clsItem.IDItem = Convert.ToInt32(adap["IDItem"]);
                    clsItem.Nome = adap["nome"].ToString();
                    clsItem.Descricao = adap["Descricao"].ToString();

                    clsItems.Add(clsItem);
                }

                return clsItems;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {

            }
        }
 private void PopulaDados()
 {
     clsItem = this.Item;
     txtNome.Text = clsItem.Nome;
     txtDescricao.Text = clsItem.Descricao;
 }
 protected void Load()
 {
     clsItem = this.Item;
     clsItem.Nome = txtNome.Text;
     clsItem.Descricao = txtDescricao.Text;
 }
示例#8
0
 public static Boolean Update(ItemTO clsItem)
 {
     return ItemDAL.Update(clsItem);
 }
示例#9
0
 public static void insert(ItemTO clsItem)
 {
     ItemDAL.insert(clsItem);
 }
示例#10
0
 public static Boolean Delete(ItemTO clsItem)
 {
     return ItemDAL.Delete(clsItem);
 }