private void btnEditUseMedicine_Click(object sender, RoutedEventArgs e) { UserMedicine use = useMedicineDataGrid.SelectedItem as UserMedicine; AddUseMedicine addUse = new AddUseMedicine(use); addUse.ShowDialog(); List <UserMedicine> listUse = DataManager.getInstance().getAllUseMedicine(); useMedicineDataGrid.DataContext = listUse; }
public void SubmitUserMedicine(UserMedicine usermedicine, int userID) { usermedicine.userID = userID; Debug.Write("medicineID = " + usermedicine.medicineID); Debug.Write("userID = " + usermedicine.userID); String apiUrlUserMedicine = apiUrl + "/usermedicine"; requestHelper.PostDataAsync(usermedicine, apiUrlUserMedicine); }
public HttpResponseMessage addUserMedicine([FromBody] UserMedicine newMedicine) { try { return(Request.CreateResponse(HttpStatusCode.OK, UserMedicineBl.addUserMedicine(newMedicine))); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public AddUseMedicine(UserMedicine use) { InitializeComponent(); if (use == null) { btnEditUseMedicine.Visibility = Visibility.Hidden; } else { btnAddUseMedicine.Visibility = Visibility.Hidden; DataContext = use; lblTitle.Content = "CHỈNH SỬA CÁCH DÙNG"; } }
//Quan ly cach dung static public List <UserMedicine> getAllUseMedicine() { DataTable dt = Active.select("select * from use_medicine where is_delete = " + 0); List <UserMedicine> listUseMedicine = new List <UserMedicine>(); for (int i = 0; i < dt.Rows.Count; i++) { UserMedicine use = new UserMedicine(); use.id = Convert.ToInt32(dt.Rows[i]["id"]); use.name = dt.Rows[i]["name"].ToString(); use.detail = dt.Rows[i]["detail"].ToString(); listUseMedicine.Add(use); } return(listUseMedicine); }
public static bool deleteMedicine(UserMedicine medicine) { try { UserMedicines userMedicine = Converters.UserMedicineConvert.UserMedicineToEntity(medicine); userMedicine = Connect.DB.UserMedicines.Single(m => m.id == medicine.id); // userMedicine = Connect.DB.UserMedicines.Attach(userMedicine); Connect.DB.UserMedicines.Remove(userMedicine); Connect.DB.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public static int addUserMedicine(UserMedicine newMedicine) { try { //לא שומר var med = UserMedicineConvert.UserMedicineToEntity(newMedicine); Connect.DB.UserMedicines.Add(med); Connect.DB.SaveChanges(); return(med.id); } catch (Exception e) { return(-1); } }
public static bool updateStack(UserMedicine newMedicine) { try { var userMedicine = Connect.DB.UserMedicines.FirstOrDefault(m => m.medicineId == newMedicine.medicineId && m.userId.ToString().Equals(newMedicine.userId.ToString())); userMedicine.unitsInStock = newMedicine.unitsInStock; Connect.DB.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public static UserMedicines UserMedicineToEntity(UserMedicine userMedicineModel) { UserMedicines medicin = new UserMedicines() { id = userMedicineModel.id, amount = userMedicineModel.amount, frequency = userMedicineModel.frequency, fromDate = userMedicineModel.fromDate, medicineId = userMedicineModel.medicineId, timesADay = userMedicineModel.timesADay, toDate = userMedicineModel.toDate, userId = userMedicineModel.userId, unitsInStock = userMedicineModel.unitsInStock, }; return(medicin); }
//ונקציה המוסיפה תרופה למשתמש כולל התראות public static bool addUserMedicineIncludeAlerts(UserMedicineAlert userMedicineAlert) { bool x = false; try { var usermedicine = new UserMedicine(); usermedicine.medicineId = long.Parse(userMedicineAlert.medicineId); usermedicine.userId = long.Parse(userMedicineAlert.userId); DateTime d = ToDateTime(userMedicineAlert.fromDate); usermedicine.fromDate = d; d = ToDateTime(userMedicineAlert.toDate); usermedicine.toDate = d; usermedicine.amount = userMedicineAlert.amount; usermedicine.timesADay = userMedicineAlert.timesADay; usermedicine.unitsInStock = userMedicineAlert.unitsInStock; usermedicine.frequency = userMedicineAlert.frequency; var userMedicineId = addUserMedicine(usermedicine); if (ToDateTime(userMedicineAlert.fromDate) == DateTime.Today) { x = true; } for (int i = 0; i < userMedicineAlert.timesADay; i++) { var alert = new Alerts() { hour = userMedicineAlert.listOfHours[i], userMedicineId = userMedicineId, }; bool a = addAlert(alert, x); } //push notification //פונקציה כל 5 דקות ותפקידה לעבור על האלרטים היומיים ויביא מחרוזת של הודעה למשתמש return(true); } catch (Exception e) { return(false); } }
private void btnEditUseMedicine_Click(object sender, RoutedEventArgs e) { //Validation //Kiem tra cach dung da ton tai chua List <UserMedicine> listUse = DataManager.getInstance().getAllUseMedicine(); foreach (var u in listUse) { if (u.name == txtNameUseMedicine.Text) { MessageBox.Show("Tên cách dùng đã tồn tại. Vui lòng nhập tên khác!"); return; } } //Kiem tra cac truong du lieu da nhap du chua if (txtNameUseMedicine.Text == "") { MessageBox.Show("Vui lòng nhập tên cách dùng!"); return; } //Thoa man cac dieu kien tien hanh cap nhat du lieu User currentUser = new User(); currentUser = (User)Application.Current.Properties["UserInfo"]; UserMedicine editUse = new UserMedicine(); editUse.id = Convert.ToInt32(txtUseId.Text); editUse.name = txtNameUseMedicine.Text; editUse.detail = txtDetailUseMedicine.Text; try { int id = DataManager.getInstance().updateUseMedicine(editUse, currentUser.id); MessageBox.Show("Cập nhật cách dùng thành công!"); Close(); } catch { MessageBox.Show("Cập nhật cách dùng thất bại!"); } }
public static bool editUserMedicine(UserMedicine newMedicine) { try { var userMedicine = Connect.DB.UserMedicines.Single(m => m.id == newMedicine.id); userMedicine.amount = newMedicine.amount; userMedicine.frequency = newMedicine.frequency; userMedicine.fromDate = newMedicine.fromDate; userMedicine.toDate = newMedicine.toDate; userMedicine.medicineId = newMedicine.medicineId; userMedicine.timesADay = newMedicine.timesADay; userMedicine.unitsInStock = newMedicine.unitsInStock; alerts = userMedicine.Alerts.ToList(); Connect.DB.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
private void btnDeleteUseMedicine_Click(object sender, RoutedEventArgs e) { UserMedicine item = useMedicineDataGrid.SelectedItem as UserMedicine; int countPrescription = DataManager.getInstance().countPrescriptionByUseID(item.id); if (countPrescription > 0) { MessageBox.Show("Có đơn thuốc đang sử dụng cách dùng này. Không thể xóa được!"); return; } try { User currentUser = new User(); currentUser = (User)Application.Current.Properties["UserInfo"]; int id = DataManager.getInstance().deleteUseMedicine(item.id, currentUser.id); MessageBox.Show("Xóa cách dùng thành công!"); List <UserMedicine> listUse = DataManager.getInstance().getAllUseMedicine(); useMedicineDataGrid.DataContext = listUse; } catch { MessageBox.Show("Xóa cách dùng thất bại!"); } }
static public int updateUseMedicine(UserMedicine use, int user_change) { int id = Active.update("UPDATE use_medicine SET name = N'" + use.name + "', detail = '" + use.detail + "', user_change = '" + user_change + "' where id = " + use.id + ""); return(id); }
public int insertUseMedicine(UserMedicine use, int user_update) { return(DataHelper.insertUseMedicine(use, user_update)); }
public int updateUseMedicine(UserMedicine use, int user_change) { return(DataHelper.updateUseMedicine(use, user_change)); }
static public int insertUseMedicine(UserMedicine use, int user_update) { int id = Active.insert("INSERT INTO use_medicine(name, detail, user_change) VALUES (N'" + use.name + "',N'" + use.detail + "','" + user_update + "')"); return(id); }