private void txtUnit_KeyPress(object sender, KeyPressEventArgs e) { DialogResult dr = MessageBox.Show("Bạn có muốn cập nhật không?", "Cập nhật", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { Medicine medicine = FillToEntity(); if (medicine.Id == 0) { medicineRepository.Insert(medicine); } else { medicineRepository.Update(medicine); } this.Close(); } }
private void btnSynch_Click(object sender, System.EventArgs e) { if (this.Clinic == null || this.Clinic.Id == 0) { return; } var dialogResult = Medical.Forms.UI.MessageDialog.Instance.ShowMessage(this, "Q009", this.Clinic.Name); if (dialogResult == DialogResult.No) { return; } // Update tu server List <TableChange> lstServer = tableChangeServerRep.GetByClinicId(1); Medicine _clientEntiy; Medicine _serverEntity; if (lstServer.Count > 0) { foreach (TableChange ent in lstServer) { switch (ent.TableName.ToString()) { case "Medicine": _serverEntity = medicineServerRep.GetById(ent.Id); if (ent.Action.Equals("I")) { if ((Medicine)medicineRep.GetById(ent.Id) == null) { _clientEntiy = new Medicine(); _clientEntiy = medicineRep.CopyEntity(_clientEntiy, _serverEntity); medicineRep.Insert(_clientEntiy); } } if (ent.Action.Equals("U")) { if ((Medicine)medicineRep.GetById(ent.Id) != null) { _clientEntiy = medicineRep.GetById(ent.Id); _clientEntiy = medicineRep.CopyEntity(_serverEntity, _clientEntiy); medicineRep.Update(_clientEntiy); } } break; case "Clinic": break; } } } }
public void InsertMedicine_WhenCalled_AddToMedicineListAndDatabase() { var newMedicine = new medicine() { medicine_name = "thuoc test", entry_unit = "Hop", entry_price = 20000, expiry_day = DateTime.ParseExact("20-10-2020", "dd-MM-yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None), quantity_in_entry_unit = 100, unit_exchange_ratio = 100, quantity_in_sale_unit = 100 * 100, entry_day = DateTime.Now, sale_unit = "Vien", sale_price_per_unit = 1000, is_active = true }; _sut.Insert(newMedicine); Assert.IsTrue(_sut.GetAll().Contains(newMedicine)); _stubContext.Verify(c => c.medicines.Add(newMedicine), Times.Once); _stubContext.Verify(c => c.SaveChanges(), Times.Once); }
public int InsertMed(Medicine med) { return(medRepo.Insert(med)); }