public class Machines { [Key] public int AutoKey; public string MachineGroup; public DateTime StartDate; public DateTime EndDate; public int Duration; public List<Machines> SqlAccessParameter(DateTime startDate, DateTime endDate) { string connstr = "Data Source=USER-BILGISAYAR;Initial Catalog=Report;Integrated Security=True"; SqlConnection myConnection = new SqlConnection(connstr); myConnection.Open(); SqlCommand myCommand = new SqlCommand("DateRange", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add("@SP_startDate", SqlDbType.DateTime).Value = startDate; myCommand.Parameters.Add("@SP_endDate", SqlDbType.DateTime).Value = endDate; SqlDataAdapter dataAdapter = new SqlDataAdapter(); myCommand.ExecuteNonQuery(); dataAdapter.SelectCommand = myCommand; DataSet dSet = new DataSet(); dataAdapter.Fill(dSet); myConnection.Close(); List<Machines> machinePost = new List<Machines>(); foreach (DataRow row in dSet.Tables[0].Rows) { Machines mac = new Machines(); mac.AutoKey = (int)row["AUTOKEY"]; mac.MachineGroup = (string)row["MACHINEGROUP"]; mac.Duration = (int)row["DURATION"]; mac.StartDate = (DateTime)row["STARTTIME"]; mac.EndDate = (DateTime)row["ENDTIME"]; machinePost.Add(mac); } return machinePost; } }
public ActionResult MachineParameter() { Machines model = new Machines(); return View(model); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)