Example #1
0
        public CarrierObject GetCarrierById(int id)
        {
            CarrierObject carrier = new CarrierObject();

            try
            {
                db.OpenConnection();

                string     sql       = $"Select * From tbl_Carrier WHERE ID = '{id}'";
                SqlCommand myCommand = new SqlCommand(sql, db._connection);

                using (SqlDataReader myDataReader = myCommand.ExecuteReader())
                {
                    while (myDataReader.Read())
                    {
                        carrier.carrierId = int.Parse(myDataReader["ID"].ToString());
                        carrier.carrier   = myDataReader["Carrier"].ToString();
                        carrier.service   = myDataReader["Service"].ToString();
                        carrier.price     = decimal.Parse(myDataReader["Price"].ToString());
                    }
                }
            }
            catch
            {
                return(null);
            }
            finally
            {
                db.CloseConnection();
            }



            return(carrier);
        }
Example #2
0
        public void UppdateCarier(CarrierObject carrier, int id)
        {
            try
            {
                db.OpenConnection();

                string sql = $"UPDATE tbl_Carrier SET Carrier = '{carrier.carrier}', Service = '{carrier.service}', Price = '{carrier.price}' WHERE ID = '{id}'";

                SqlCommand insertCmd = new SqlCommand(sql, db._connection);
                insertCmd.ExecuteNonQuery();
            }
            catch
            {
                //TODO Exeption
            }
            finally
            {
                db.CloseConnection();
            }
        }
Example #3
0
        public void AddCarrier(CarrierObject carrier)
        {
            try
            {
                db.OpenConnection();

                string sql = $"Insert Into tbl_Carrier (Carrier, Service, Price ) Values('{carrier.carrier}', '{carrier.service}', '{carrier.price}' )";

                SqlCommand insertCmd = new SqlCommand(sql, db._connection);
                insertCmd.ExecuteNonQuery();
            }
            catch
            {
                //TODO exeption
            }
            finally
            {
                db.CloseConnection();
            }
        }