public void EditTransport(mst_transport mst) { try { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { string query = @"UPDATE mst_transport SET pickup_point = @pickup_point, transport_fees = @transport_fees, transport_number = @transport_number, bl_apr = @bl_apr, bl_may = @bl_may, bl_jun = @bl_jun, bl_jul = @bl_jul, bl_aug = @bl_aug, bl_sep = @bl_sep, bl_oct = @bl_oct, bl_nov = @bl_nov, bl_dec = @bl_dec, bl_jan = @bl_jan, bl_feb = @bl_feb, bl_mar = @bl_mar WHERE pickup_id = @pickup_id AND session = @session"; con.Execute(query, mst); } } catch (Exception ex) { throw ex; } }
public void AddTransport(mst_transport mst) { try { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { string query = "INSERT INTO mst_transport (session,pickup_id,pickup_point,transport_fees,transport_number,bl_apr,bl_may,bl_jun,bl_jul,bl_aug,bl_sep,bl_oct,bl_nov,bl_dec,bl_jan,bl_feb,bl_mar) VALUES (@session,@pickup_id,@pickup_point,@transport_fees,@transport_number,@bl_apr,@bl_may,@bl_jun,@bl_jul,@bl_aug,@bl_sep,@bl_oct,@bl_nov,@bl_dec,@bl_jan,@bl_feb,@bl_mar)"; string maxid = @"SELECT IFNULL(MAX(pickup_id), 0) + 1 FROM mst_transport WHERE session = (SELECT session FROM mst_session WHERE session_active = 'Y')"; // var id = con.Query<mst_section>(maxid).ToString().Trim(); int id = con.ExecuteScalar <int>(maxid); if (id == 1) { id = 1000; } mst.pickup_id = id; mst.pickup_point = mst.pickup_point.Trim(); string query1 = @"SELECT session FROM mst_session WHERE session_active = 'Y'"; mst.session = con.Query <string>(query1).SingleOrDefault(); //mst.session = sess.findActive_finalSession(); con.Execute(query, new { mst.session, mst.pickup_id, mst.pickup_point, mst.transport_fees, mst.transport_number, mst.bl_apr, mst.bl_may, mst.bl_jun, mst.bl_jul, mst.bl_aug, mst.bl_sep, mst.bl_oct, mst.bl_nov, mst.bl_dec, mst.bl_jan, mst.bl_feb, mst.bl_mar }); } } catch (Exception ex) { throw ex; } }