public string addBDVisitType(VisitType _visitType) { try { var Query = _contextDatabase.BDVisitTypes.Where(a => a.VisitTypeID == _visitType.VisitTypeID).FirstOrDefault(); if (Query != null) { Query.VisitTypeName = _visitType.VisitTypeName; _contextDatabase.SaveChanges(); return "Added sucsessfully"; } else { BDVisitType _bDVisitType = new BDVisitType(); _bDVisitType.VisitTypeName = _visitType.VisitTypeName; _contextDatabase.BDVisitTypes.Add(_bDVisitType); _contextDatabase.SaveChanges(); return "Edited succesfuy"; } } catch (Exception ex) { return "Erorr on add"; throw; } }
private void btn_Save_Click(object sender, EventArgs e) { if (ValidateUI()) { if (Mode == "Add") { VisitType _bdvisitType = new VisitType(); _bdvisitType.VisitTypeName = tbx_VisitName.Text.ToString(); string _message = _bdvisitType.addBDVisitType(_bdvisitType); FillVisitTypeCombo(); MessageBox.Show(_message); } else if (Mode == "Edit") { _SelectedVisitType.VisitTypeName = tbx_VisitName.Text.ToString(); string _message = visitType.addBDVisitType(_SelectedVisitType); FillVisitTypeCombo(); MessageBox.Show(_message); } ControlUI("Select"); Mode = "Select"; } else { MessageBox.Show("برجاء ادخال بيانات صحيحه اولا"); } }
public string addBDVisitType(VisitType _visitType) { try { var Query = _contextDatabase.BDVisitTypes.Where(a => a.VisitTypeID == _visitType.VisitTypeID).FirstOrDefault(); if (Query != null) { Query.VisitTypeName = _visitType.VisitTypeName; _contextDatabase.SaveChanges(); return("Added sucsessfully"); } else { BDVisitType _bDVisitType = new BDVisitType(); _bDVisitType.VisitTypeName = _visitType.VisitTypeName; _contextDatabase.BDVisitTypes.Add(_bDVisitType); _contextDatabase.SaveChanges(); return("Edited succesfuy"); } } catch (Exception ex) { return("Erorr on add"); throw; } }
public string deleteBDVisitType(VisitType _visitType) { try { var _bDvisitType = _contextDatabase.BDVisitTypes.Single(a => a.VisitTypeID == _visitType.VisitTypeID); _contextDatabase.BDVisitTypes.Remove(_bDvisitType); _contextDatabase.SaveChanges(); return "Sucessfully deleted"; } catch (Exception ex) { return "Error on delete"; } }
public string deleteBDVisitType(VisitType _visitType) { try { var _bDvisitType = _contextDatabase.BDVisitTypes.Single(a => a.VisitTypeID == _visitType.VisitTypeID); _contextDatabase.BDVisitTypes.Remove(_bDvisitType); _contextDatabase.SaveChanges(); return("Sucessfully deleted"); } catch (Exception ex) { return("Error on delete"); } }
private void Fillcbx_VisitType() { VisitType _visitType = new VisitType(); _AllVisits = _visitType.GetVisitsWithPrics(DateTime.Now.Date); cbx_VisitType.DataSource = null; cbx_VisitType.DataSource = _AllVisits; cbx_VisitType.DisplayMember = "VisitTypeName"; cbx_VisitType.ValueMember = "VisitTypeID"; cbx_VisitType.SelectedIndex = -1; PhysicianPrice = 0; VisitPrice = 0; }