Beispiel #1
0
    public Bus_Info_Info View_Bus_TaxOfGivenMonth(int bus_id, int month, int year)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("View_Bus_TaxOfGivenMonth", con);

        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter p = new SqlParameter();

        p       = cmd.Parameters.Add("@bus_id", SqlDbType.Int);
        p.Value = bus_id;//select bus_id of given reg no.ie:   vsp.viewvehiclthroughbusregno(regno);
        p       = cmd.Parameters.Add("@month", SqlDbType.Int);
        p.Value = month;
        p       = cmd.Parameters.Add("@year", SqlDbType.Int);
        p.Value = year;

        SqlDataReader read = cmd.ExecuteReader();
        Bus_Info_Info inf  = new Bus_Info_Info();

        if (read.Read())
        {
            inf.Tax      = float.Parse(read["tax"].ToString());
            inf.Tax_Date = int.Parse(read["tax_date"].ToString());
        }
        else
        {
            inf.Tax_Date = int.Parse("1000");  //To show no tax in that month.
        }


        read.Close();
        con.Close();
        return(inf);
    }
Beispiel #2
0
    public void Update_Bus_Tax(Bus_Info_Info inf)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("Update_Bus_Tax", con);

        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter p = new SqlParameter();

        p       = cmd.Parameters.Add("@bus_id", SqlDbType.Int);
        p.Value = inf.Bus_Id;//select bus_id of given reg no.ie:   vsp.viewvehiclthroughbusregno(regno);
        p       = cmd.Parameters.Add("@tax_info_id", SqlDbType.Int);
        p.Value = inf.Tax_Info_Id;

        p       = cmd.Parameters.Add("@tax", SqlDbType.Float);
        p.Value = inf.Tax;
        p       = cmd.Parameters.Add("@tax_date", SqlDbType.Int);
        p.Value = inf.Tax_Date;
        p       = cmd.Parameters.Add("@month", SqlDbType.Int);
        p.Value = inf.Month;
        p       = cmd.Parameters.Add("@year", SqlDbType.Int);
        p.Value = inf.Year;

        cmd.ExecuteNonQuery();

        con.Close();
    }