public static AppointmentE getAppointmentByID(int id) { AppointmentE temp = null; SqlCommand com = new SqlCommand("getAppointmentByID", Connection.Con); // Prodecure com.CommandType = CommandType.StoredProcedure; com.Parameters.Add(new SqlParameter("@id", id)); if (com.Connection.State == ConnectionState.Closed) { com.Connection.Open(); } SqlDataReader rd = com.ExecuteReader(); if (rd.HasRows) { if (rd.Read()) { temp = new AppointmentE { AppointmentID = Convert.ToInt32(rd["AppointmentID"]), AppointmentContent = rd["AppointmentContent"].ToString(), UserID = Convert.ToInt32(rd["UserID"]), DietitianID = Convert.ToInt32(rd["DietitianID"]), AppointmentDate = rd["AppointmentDate"] == DBNull.Value ? DateTime.MinValue : DateTime.Parse(rd["AppointmentDate"].ToString()), }; } } com.Dispose(); com.Connection.Close(); return(temp); }
public static int InsertAppointment(AppointmentE appointment) { int appointmentID = 0; SqlCommand com = new SqlCommand("InsertAppointment", Connection.Con); // Prodecure com.CommandType = CommandType.StoredProcedure; com.Parameters.Add(new SqlParameter("@dietitianID", appointment.DietitianID)); com.Parameters.Add(new SqlParameter("@userID", appointment.UserID)); if (appointment.AppointmentDate == DateTime.MinValue) { com.Parameters.Add(new SqlParameter("@appointmentDate", DBNull.Value)); } else { com.Parameters.Add(new SqlParameter("@appointmentDate", appointment.AppointmentDate)); } com.Parameters.Add(new SqlParameter("@appointmentContent", appointment.AppointmentContent)); if (com.Connection.State == ConnectionState.Closed) { com.Connection.Open(); } SqlDataReader rd = com.ExecuteReader(); if (rd.HasRows) { rd.Read(); appointmentID = Convert.ToInt32(rd[0]); } com.Dispose(); com.Connection.Close(); return(appointmentID); }
protected void saveAppointment_Click(object sender, EventArgs e) { AppointmentE appointment = new AppointmentE(); appointment.UserID = (Session["user"] as Entity.UserE).UserID; appointment.AppointmentContent = appointment_textbox.Text; appointment.AppointmentDate = DateTime.Parse(appointmentBox.Text); if (Convert.ToInt32(ddlDietitians.Text) != 0) { appointment.DietitianID = Convert.ToInt32(ddlDietitians.Text); BusinessLayers.Business.insertAppointment(appointment); error.Text = "Success Appointment"; error.Visible = true; } else { error.Text = "Please select dietitian"; error.Visible = true; } PaymentE pay = new PaymentE(); pay.DietitianID = Convert.ToInt32(ddlDietitians.Text); pay.UserID = (Session["user"] as Entity.UserE).UserID; pay.Fee = "50"; BusinessLayers.Business.insertPayment(pay); }
public static void UpdateAppointment(AppointmentE obj) { SqlCommand com = new SqlCommand("UpdateAppointment", Connection.Con); // Prodecure com.CommandType = CommandType.StoredProcedure; com.Parameters.Add(new SqlParameter("@appointmentDate", obj.AppointmentDate)); com.Parameters.Add(new SqlParameter("@dietitianID", obj.DietitianID)); com.Parameters.Add(new SqlParameter("@appointmentContent", obj.AppointmentContent)); com.Parameters.Add(new SqlParameter("@userID", obj.UserID)); com.Parameters.Add(new SqlParameter("@id", obj.AppointmentID)); if (com.Connection.State == ConnectionState.Closed) { com.Connection.Open(); } SqlDataReader rd = com.ExecuteReader(); com.Dispose(); com.Connection.Close(); }
public static void updateAppointment(AppointmentE obj) { AppointmentC.UpdateAppointment(obj); }
public static int insertAppointment(AppointmentE obj) { return(AppointmentC.InsertAppointment(obj)); }