public ActionResult Edit(int id, OPDViewModel model) { try { OPD opd = new OPD() { PhoneNumber = model.PhoneNumber, PIC = model.PIC, Id = model.Id, ParentId = model.ParentId, Title = model.Title, Form = model.Form, Structure = model.Structure }; var response = _opdLogic.Edit(opd); if (response.IsError == true) { foreach (var item in response.ErrorCodes) { ModelState.AddModelError(string.Empty, item); } PrepareSelectList(); OPDFactory.InitializeContainers(); return(View(model)); } return(RedirectToAction("View", new { id = model.Id })); } catch { return(View()); } }
public OPD Edit(OPD entity) { var opd = _db.OPDs.Find(entity.Id); _db.Entry(opd).CurrentValues.SetValues(entity); _db.SaveChanges(); return(opd); }
public ResponseMessage Create(OPD entity) { ResponseMessage response = new ResponseMessage(); if (_repository.IsOPDExist(entity.Title)) { response.IsError = true; response.ErrorCodes.Add("OPD Already Exist"); return(response); } _repository.Create(entity); return(response); }
private static void CreateOption(int?value, StringBuilder result, OPD item) { if (value.HasValue) { if (item.Id == value) { result.Append("<option selected = \"selected\" value=\"" + item.Id + "\">" + item.Title + "</option>"); } else { result.Append("<option value=\"" + item.Id + "\">" + item.Title + "</option>"); } } else { result.Append("<option value=\"" + item.Id + "\">" + item.Title + "</option>"); } }
private static void CreateNodes(List <OPD> opds, List <NodeViewModel> nodes, OPD item) { NodeViewModel node = new NodeViewModel(); node.text = item.Title; node.href = "/OPD/View/" + item.Id; nodes.Add(node); var childs = opds.Where(c => c.ParentId == item.Id).ToList(); if (childs.Count > 0) { node.nodes = new List <NodeViewModel>(); foreach (var child in childs) { CreateNodes(opds, node.nodes, child); } } }
private static void CreateChild(IEnumerable <OPD> data, int?value, StringBuilder result, OPD item) { if (data.Any(c => c.ParentId == item.Id)) { var childs = data.Where(c => c.ParentId == item.Id).ToList(); foreach (var child in childs) { child.Title = "--- " + child.Title; CreateOption(value, result, child); } } }
public void Create(OPD entity) { _db.OPDs.Add(entity); _db.SaveChanges(); }
private void SyncButton_Click(object sender, EventArgs e) { if (File.Exists("hospitalDb.db")) { IList <PatientInformation> p = new List <PatientInformation>(); DataSet dt = new DataSet(); con = new SQLiteConnection("Data Source=hospitalDb.db);Version=3"); string cstring = "select * from PatientInfo where Flag=@flag"; cmd = new SQLiteCommand(cstring, con); con.Open(); cmd.Parameters.AddWithValue("@flag", true); SQLiteDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { int idd, id1; PatientInformation pi = new PatientInformation(); id1 = reader.GetInt32(0); pi.FirstName = reader.GetString(1); pi.MiddleName = reader.GetString(2); pi.LastName = reader.GetString(3); pi.FullName = reader.GetString(4); pi.IsLessThan5Years = reader.GetBoolean(5); pi.Age = reader.GetInt32(6); pi.Weight = reader.GetString(7); pi.Sex = reader.GetString(8); pi.District = reader.GetString(9); pi.Municipality = reader.GetString(10); pi.Ward = reader.GetString(11); pi.Village = reader.GetString(12); pi.Caste = reader.GetString(13); pi.GuardianName = reader.GetString(14); pi.ContactNumber = reader.GetString(15); pi.AddedDate = reader.GetDateTime(16); pi.AddedBy = reader.GetString(17); db.patientInformations.Add(pi); db.SaveChanges(); idd = pi.Id; //opd string cstring11 = "select * from OPDTable where Flag=@flag1 AND IsFirstTime=@isfirst AND PID=@id1"; cmd = new SQLiteCommand(cstring11, con); cmd.Parameters.AddWithValue("@flag1", true); cmd.Parameters.AddWithValue("@id1", id1); cmd.Parameters.AddWithValue("@isfirst", false); SQLiteDataReader reader11 = cmd.ExecuteReader(); while (reader11.Read()) { OPD pi1 = new OPD(); pi1.IsTB = reader11.GetBoolean(1); pi1.DiagnosticInvestigation = reader11.GetString(2); pi1.ProvisionalDiagnosis = reader11.GetString(3); pi1.ICDCode = reader11.GetString(4); pi1.TreatmentAndAdvice = reader11.GetString(5); pi1.SurgicalProcedure = reader11.GetString(6); pi1.IsGenderViolence = reader11.GetBoolean(7); pi1.FreeServiceCode = reader11.GetString(8); pi1.IsNewPatient = reader11.GetBoolean(9); pi1.ReferredTo = reader11.GetString(10); pi1.NSHI_Number = reader11.GetString(11); pi1.Claim_Code = reader11.GetString(12); pi1.PAN = reader11.GetString(13); pi1.PatientInformationId = idd; pi1.AddedDate = reader11.GetDateTime(15); pi1.AddedBy = reader11.GetString(16); db.OPDs.Add(pi1); db.SaveChanges(); //main string cstring2 = "select * from MainTable where Flag=@flag2 AND IsFirstTime=@isfirst AND PID=@id2"; cmd = new SQLiteCommand(cstring2, con); cmd.Parameters.AddWithValue("@flag2", true); cmd.Parameters.AddWithValue("@id2", id1); cmd.Parameters.AddWithValue("@isfirst", false); SQLiteDataReader reader2 = cmd.ExecuteReader(); while (reader2.Read()) { MRegister pi2 = new MRegister(); pi2.ServiceType = reader2.GetString(1); pi2.IsFree = reader2.GetBoolean(2); pi2.IsNewPatient = reader2.GetBoolean(3); pi2.Cost = reader2.GetDouble(4); pi2.Deposited_Amount = reader2.GetDouble(5); pi2.ReferredFrom = reader2.GetString(6); pi2.PatientInformationId = idd; pi2.AddedDate = reader2.GetDateTime(8); pi2.AddedBy = reader2.GetString(9); db.mainRegisterss.Add(pi2); db.SaveChanges(); } } } //opd isfirst string cstring1 = "select * from OPDTable where Flag=@flag1 AND IsFirstTime=@isfirst"; cmd = new SQLiteCommand(cstring1, con); cmd.Parameters.AddWithValue("@flag1", true); cmd.Parameters.AddWithValue("@isfirst", true); SQLiteDataReader reader1 = cmd.ExecuteReader(); while (reader1.Read()) { OPD pi1 = new OPD(); pi1.IsTB = reader1.GetBoolean(1); pi1.DiagnosticInvestigation = reader1.GetString(2); pi1.ProvisionalDiagnosis = reader1.GetString(3); pi1.ICDCode = reader1.GetString(4); pi1.TreatmentAndAdvice = reader1.GetString(5); pi1.SurgicalProcedure = reader1.GetString(6); pi1.IsGenderViolence = reader1.GetBoolean(7); pi1.FreeServiceCode = reader1.GetString(8); pi1.IsNewPatient = reader1.GetBoolean(9); pi1.ReferredTo = reader1.GetString(10); pi1.NSHI_Number = reader1.GetString(11); pi1.Claim_Code = reader1.GetString(12); pi1.PAN = reader1.GetString(13); pi1.PatientInformationId = reader1.GetInt32(14); pi1.AddedDate = reader1.GetDateTime(15); pi1.AddedBy = reader1.GetString(16); db.OPDs.Add(pi1); db.SaveChanges(); } //main is first string cstring22 = "select * from MainTable where Flag=@flag2 AND IsFirstTime=@isfirst "; cmd = new SQLiteCommand(cstring22, con); cmd.Parameters.AddWithValue("@flag2", true); cmd.Parameters.AddWithValue("@isfirst", true); SQLiteDataReader reader22 = cmd.ExecuteReader(); while (reader22.Read()) { MRegister pi2 = new MRegister(); pi2.ServiceType = reader22.GetString(1); pi2.IsFree = reader22.GetBoolean(2); pi2.IsNewPatient = reader22.GetBoolean(3); pi2.Cost = reader22.GetDouble(4); pi2.Deposited_Amount = reader22.GetDouble(5); pi2.ReferredFrom = reader22.GetString(6); pi2.PatientInformationId = reader22.GetInt32(7); pi2.AddedDate = reader22.GetDateTime(8); pi2.AddedBy = reader22.GetString(9); db.mainRegisterss.Add(pi2); db.SaveChanges(); } //string cmdstring10000 = "delete from PatientInfo"; //cmd = new SQLiteCommand(cmdstring10000, con); //cmd.ExecuteNonQuery(); //billing details string cmdstring = "update patientInfo set Flag= @flagg where Flag=@flag"; cmd = new SQLiteCommand(cmdstring, con); cmd.Parameters.AddWithValue("@flagg", false); cmd.Parameters.AddWithValue("@flag", true); cmd.ExecuteNonQuery(); // con.Close(); // MessageBox.Show("success"); //string cmdstring100 = "delete from OPDTable"; //cmd = new SQLiteCommand(cmdstring100, con); //cmd.ExecuteNonQuery(); string cmdstring1 = "update OPDTable set Flag= @flagg1 where Flag=@flag1"; cmd = new SQLiteCommand(cmdstring1, con); cmd.Parameters.AddWithValue("@flagg1", false); cmd.Parameters.AddWithValue("@flag1", true); cmd.ExecuteNonQuery(); //main //string cmdstring1000 = "delete from MainTable"; //cmd = new SQLiteCommand(cmdstring1000, con); //cmd.ExecuteNonQuery(); // main table string cmdstring3 = "update MainTable set Flag= @flagg2 where Flag=@flag2"; cmd = new SQLiteCommand(cmdstring3, con); cmd.Parameters.AddWithValue("@flagg2", false); cmd.Parameters.AddWithValue("@flag2", true); cmd.ExecuteNonQuery(); con.Close(); } //billing if (File.Exists("hospitalBillDb.db")) { con = new SQLiteConnection("Data Source=hospitalBillDb.db);Version=3"); string cstring5 = "Select * from BillingDetails"; cmd = new SQLiteCommand(cstring5, con); con.Open(); SQLiteDataReader reader4 = cmd.ExecuteReader(); while (reader4.Read()) { int idd; int id1; BillingDetails pi = new BillingDetails(); id1 = reader4.GetInt32(0); pi.GrandTotal = reader4.GetDouble(1); pi.Discount = reader4.GetDouble(2); pi.DiscountDescription = reader4.GetString(3); pi.AddedDate = reader4.GetDateTime(4); pi.AddedBy = reader4.GetString(5); pi.PatientInformationId = reader4.GetInt32(6); db.BillDetails.Add(pi); db.SaveChanges(); idd = pi.id; //bill con = new SQLiteConnection("Data Source=hospitalBillDb.db);Version=3"); string cstring4 = "Select * from Billing where Bid=@id"; cmd = new SQLiteCommand(cstring4, con); con.Open(); cmd.Parameters.AddWithValue("@id", id1); SQLiteDataReader reader3 = cmd.ExecuteReader(); while (reader3.Read()) { AllBilling ppp = new AllBilling(); ppp.Name = reader3.GetString(1); ppp.Type = reader3.GetString(2); ppp.Price = reader3.GetDouble(3); ppp.Quantity = reader3.GetDouble(4); ppp.AddedDate = reader3.GetDateTime(5); pi.AddedBy = reader3.GetString(6); ppp.PatientInformationId = idd; db.Bills.Add(ppp); db.SaveChanges(); } } string cmdstring1001 = "delete from Billing"; cmd = new SQLiteCommand(cmdstring1001, con); cmd.ExecuteNonQuery(); //billing details string cmdstring10001 = "delete from BillingDetails"; cmd = new SQLiteCommand(cmdstring10001, con); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Success"); } }
public static AppOpd CreateUPdateNewForm(AppOpd source) { using (var dbcontext = new HMSEntities()) { //dicount check if (source.Discount != null && source.Discount > 0) { var doc = dbcontext.AspNetUsers.FirstOrDefault(docobj => docobj.Id == source.DoctorId); if (doc != null && source.Discount > doc.Fee) { return(null); } } if (source.Mode == "cusinfo") { var patient = dbcontext.OPDs.FirstOrDefault(form => form.Id == source.Id); var allrecs = dbcontext.OPDs.Where(o => o.PatientNo == patient.PatientNo).ToList(); if (allrecs.Any()) { foreach (var dbOb in allrecs) { dbOb.Name = source.Name; dbOb.GuardianName = source.GuardianName; dbOb.Age = source.Age; dbOb.Gender = source.Gender; dbOb.CNIC = source.CNIC; dbOb.Address = source.Address; dbOb.Phone = source.Phone; dbOb.MartialStatus = source.MartialStatus; dbOb.Discount = source.Discount; dbOb.DiscountBy = source.DiscountBy; dbOb.InsuranceNo = source.InsuranceNo; dbcontext.OPDs.AddOrUpdate(dbOb); } dbcontext.SaveChanges(); return(GetOpdById(source.Id.ToString())); } } var dbObj = dbcontext.OPDs.FirstOrDefault(form => form.Id == source.Id); if (dbObj == null) { dbObj = new OPD { DateTime = DateTime.Now, Name = source.Name, DailyNo = source.DailyNo, PatientNo = source.PatientNo, VisitNo = source.VisitNo, MartialStatus = source.MartialStatus, Address = source.Address, Age = source.Age, CNIC = source.CNIC, DoctorId = source.DoctorId, Gender = source.Gender, GuardianName = source.GuardianName, Phone = source.Phone, Status = true, InsuranceNo = source.InsuranceNo, Discount = source.Discount, DiscountBy = source.DiscountBy }; dbcontext.OPDs.Add(dbObj); dbcontext.SaveChanges(); return(GetOpdById(dbObj.Id.ToString())); } else { if (source.Mode == "edit") { dbObj.DoctorId = source.DoctorId; dbObj.Name = source.Name; dbObj.GuardianName = source.GuardianName; dbObj.Age = source.Age; dbObj.Gender = source.Gender; dbObj.CNIC = source.CNIC; dbObj.Address = source.Address; dbObj.Phone = source.Phone; dbObj.MartialStatus = source.MartialStatus; dbObj.Discount = source.Discount; dbObj.DiscountBy = source.DiscountBy; dbObj.InsuranceNo = source.InsuranceNo; dbcontext.OPDs.AddOrUpdate(dbObj); dbcontext.SaveChanges(); } return(GetOpdById(dbObj.Id.ToString())); } } return(null); }