Exemplo n.º 1
0
        public DataTable Fill()
        {
            try
            {
                using (SqlConnection con = _connect.ConnectToDatabase())
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        command.Connection     = con;
                        command.CommandType    = CommandType.StoredProcedure;
                        command.CommandTimeout = 1200;
                        command.CommandText    = @"dbo.sp_FillGrid_Cutomers";

                        DataTable      DT  = new DataTable();
                        SqlDataAdapter SDA = new SqlDataAdapter(command);
                        SDA.Fill(DT);
                        return(DT);
                    }
                }
            }
            catch (Exception ex)
            {
                _write.Write(ex.ToString());
                throw ex;
            }
        }
Exemplo n.º 2
0
        public DataTable Filter(ComboBox cbFilter, TextBox text)
        {
            try
            {
                using (SqlConnection con = _connect.ConnectToDatabase())
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        command.Connection     = con;
                        command.CommandType    = CommandType.StoredProcedure;
                        command.CommandTimeout = 1200;
                        command.CommandText    = @"dbo.sp_Filter_Customer";

                        command.Parameters.AddWithValue(@"filter", cbFilter.SelectedItem.ToString());
                        command.Parameters.AddWithValue(@"text", text.Text);

                        DataTable      DT  = new DataTable();
                        SqlDataAdapter SDA = new SqlDataAdapter(command);
                        SDA.Fill(DT);
                        return(DT);
                    }
                }
            }
            catch (Exception ex)
            {
                _write.Write(ex.ToString());
                throw ex;
            }
        }
Exemplo n.º 3
0
        public void Delete(Customer.Customer cus)
        {
            try
            {
                using (SqlConnection con = _connect.ConnectToDatabase())
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        command.Connection     = con;
                        command.CommandType    = CommandType.StoredProcedure;
                        command.CommandTimeout = 1200;
                        command.CommandText    = @"dbo.sp_Delete_Customer";

                        command.Parameters.AddWithValue(@"id", cus.ID);

                        con.Open();
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                _write.Write(ex.ToString());
                throw ex;
            }
        }
Exemplo n.º 4
0
        public void Insert(Customer cus)
        {
            try
            {
                using (SqlConnection con = _connect.ConnectToDatabase())
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        command.Connection     = con;
                        command.CommandType    = CommandType.StoredProcedure;
                        command.CommandTimeout = 1200;
                        command.CommandText    = @"dbo.sp_Insert_Customer";

                        command.Parameters.AddWithValue(@"name", cus.Name);
                        command.Parameters.AddWithValue(@"surname", cus.Surname);
                        command.Parameters.AddWithValue(@"telephone", cus.Telephone);
                        command.Parameters.AddWithValue(@"address", cus.Address);

                        con.Open();
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                _write.Write(ex.ToString());
                throw ex;
            }
        }