public ActionResult AddEmp() { teethLabEntities db = new teethLabEntities(); string name = Request.Form["name"]; employee emp = new employee(); emp.name = name; db.employees.Add(emp); db.SaveChanges(); return Redirect(Url.Action("Index", "Employee")); }
public ActionResult register() { string name = Request.Form["name"]; string password = Request.Form["password"]; string passwordConfirm = Request.Form["confirmPassword"]; teethLabEntities db = new teethLabEntities(); if (db.users.Where(o => o.name == name).Count() > 0) { TempData["error"] = "الاسم موجود مسبقآ , رجاء اختيار اسم اخر"; return Redirect(Url.Action("viewRegister", "user")); } if (password != passwordConfirm) { TempData["error"] = "الرقم السري غير مطابق"; return Redirect(Url.Action("viewRegister", "user")); } user user = new user(); user.name = name; user.password = password; db.users.Add(user); db.SaveChanges(); TempData["error"] = "تمت الاضافه بنجاح"; return Redirect(Url.Action("viewRegister", "user")); }
public void DeleteEmp() { int empId = int.Parse(Request.Form["id"]); teethLabEntities db = new teethLabEntities(); db.Entry(db.employees.Find(empId)).State = System.Data.EntityState.Deleted; db.SaveChanges(); Response.Write("success"); }
public ActionResult AddSup() { teethLabEntities db = new teethLabEntities(); string name = Request.Form["name"]; supplier sup = new supplier(); sup.name = name; db.suppliers.Add(sup); db.SaveChanges(); return Redirect(Url.Action("Index", "Supplier")); }
public ActionResult AddCom() { teethLabEntities db = new teethLabEntities(); string name = Request.Form["name"]; company comp = new company(); comp.name = name; db.companies.Add(comp); db.SaveChanges(); return Redirect(Url.Action("viewAllCompanies", "Company")); }
public ActionResult login() { string name = Request.Form["name"]; string password = Request.Form["password"]; teethLabEntities db = new teethLabEntities(); if (db.users.Where(u => u.name == name && u.password == password).Count() > 0) { user user = db.users.Where(u => u.name == name && u.password == password).First(); Session.Add("userId", user.id); return Redirect(Url.Action("Index" , "Home")); } TempData["error"] = "الاسم او الرقم السري غير صحيح"; return Redirect(Url.Action("viewLogin", "user")); }
public void activateDoc() { teethLabEntities db = new teethLabEntities(); int docId = int.Parse(Request.Form["id"]); doctor doc = db.doctors.Find(docId); db.Entry(doc).State = System.Data.EntityState.Modified; if (doc.isActive) { doc.isActive = false; } else { doc.isActive = true; } db.SaveChanges(); Response.Write("success"); }
public ActionResult addDoc() { string name = Request.Form["name"]; string address = Request.Form["address"]; int supplierId = int.Parse(Request.Form["supplier"]); teethLabEntities db = new teethLabEntities(); doctor doc = new doctor(); doc.name = name; doc.address = address; doc.depit = 0; doc.isActive = false; if (supplierId != 0) doc.supplierId = supplierId; db.doctors.Add(doc); db.SaveChanges(); return Redirect(Url.Action("Index", "Doctor")); }
public void addNewCase(string casename, int caseDefaultPrice) { teethLabEntities db = new teethLabEntities(); @case cas = new @case(); cas.name = casename; cas.defaultPrice = caseDefaultPrice; db.Entry(cas).State = System.Data.EntityState.Added; db.cases.Add(cas); db.SaveChanges(); this.addDefaultCasePrices(cas); }
public void addDefaultCasePrices(@case cas) { teethLabEntities db = new teethLabEntities(); List<doctor> docs = db.doctors.Where(d=>d.isActive==true). ToList(); foreach (doctor doc in docs) { this.addNewCasePrice(doc.id, cas.id, cas.defaultPrice); } }
public ActionResult viewCurrentCases() { teethLabEntities db = new teethLabEntities(); List<@case> cases = db.cases.ToList(); ViewData["cases"] = cases; return View(); }
private List<employee> getEmpsByName(string name) { teethLabEntities db = new teethLabEntities(); if (db.employees.Where(e => e.name.Contains(name)).Count() > 0) { return db.employees.Where(e => e.name.Contains(name)).ToList(); } return null; }
public void export() { int cost = 0; try { cost = int.Parse(Request.Form["cost"]); } catch (Exception e) { return; } int id = 0; try { id = int.Parse(Request.Form["id"]); } catch (Exception e) { } string name = Request.Form["name"]; if (name == "" || name == null) { return; } string type = Request.Form["type"]; teethLabEntities db = new teethLabEntities(); int dayId = 0; DateTime day; CultureInfo enUS = new CultureInfo("en-US"); DateTime.TryParseExact(Request.Form["day"], "yyyy-MM-dd", enUS, DateTimeStyles.None, out day); moneyDay md = new moneyDay(); if (db.moneyDays.Where(o => o.day.Year == day.Year && o.day.Month == day.Month && o.day.Day == day.Day).Count() > 0) { md = db.moneyDays.Where(o => o.day.Year == day.Year && o.day.Month == day.Month && o.day.Day == day.Day ).First(); md.credit -= cost; db.Entry(md).State = System.Data.EntityState.Modified; } else { return; } db.SaveChanges(); dayId = md.id; db = new teethLabEntities(); money m = new money(); m.dayId = dayId; m.fromTo = name; m.type = "export"; m.value = cost; m.recieveDate = DateTime.Now; if (type == "new") { } else if (type == "Doctor") { m.doctorId = id; } else if (type == "Company") { m.companyId = id; } else if (type == "Employee") { m.employeeId = id; } db.Entry(m).State = System.Data.EntityState.Added; db.moneys.Add(m); db.SaveChanges(); db = new teethLabEntities(); if (type == "Company") { product p = new product(); p.companyId = id; p.enterDate = day; p.name = name;// p.isFinished = false; p.price = cost; db.Entry(p).State = System.Data.EntityState.Added; } else if (type == "Doctor") { doctor doc = db.doctors.Find(id); db.Entry(doc).State = System.Data.EntityState.Modified; doc.depit += cost; } db.SaveChanges(); Response.Write("success"); }
// // GET: /Money/ // sadrat w wardat public ActionResult Index() { teethLabEntities db = new teethLabEntities(); List<doctor> doctors = db.doctors.Where(d => d.isActive == true).ToList(); ViewData["doctors"] = doctors; ViewData["emps"] = db.employees.ToList(); ViewData["companies"] = db.companies.ToList(); DateTime now = DateTime.Now; int credit = 0; if (db.moneyDays.Where(o => o.day.Year == now.Year && o.day.Month == now.Month && o.day.Day == now.Day ).Count() <= 0) { //get last day credit int lastId = db.moneyDays.Max(o => o.id); credit = 0; if (lastId != 0) { credit = db.moneyDays.Find(lastId).credit; } moneyDay md = new moneyDay(); md.credit = credit; md.day = now; db.moneyDays.Add(md); db.SaveChanges(); } else { credit = db.moneyDays.Where(o => o.day.Year == now.Year && o.day.Month == now.Month && o.day.Day == now.Day ).First().credit; } ViewData["credit"] = credit; return View(); }
public void editCase(int id, string casename, int defaultPrice) { teethLabEntities db = new teethLabEntities(); @case cas = db.cases.Find(id); cas.name = casename; cas.defaultPrice = defaultPrice; db.Entry(cas).State = System.Data.EntityState.Modified; db.SaveChanges(); }
//reference from #inputBtn , #outPrint in follow up cases, public void addCase() { try { int doctorId = int.Parse(Request.Form["doctorId"]); int caseId = int.Parse(Request.Form["caseId"]); string caseColor = Request.Form["caseColor"]; string patientName = Request.Form["patientName"]; string notes = Request.Form["notes"]; DateTime recieveDate; CultureInfo enUS = new CultureInfo("en-US"); DateTime.TryParseExact(Request.Form["recieveDate"], "yyyy-MM-dd", enUS, DateTimeStyles.None, out recieveDate); string caseTeeth = Request.Form["caseTeeth"]; DateTime enterdate; enUS = new CultureInfo("en-US"); DateTime.TryParseExact(Request.Form["day"], "yyyy-MM-dd", enUS, DateTimeStyles.None, out enterdate); teethLabEntities db = new teethLabEntities(); //get price int price = db.caseDoctorPrices.Where(o => o.doctorId == doctorId && o.caseId == caseId).First().price ; //get last case number string newMonth = Request.Form["newMonth"]; int caseNumber = this.NewCaseNumber(); int numCases = int .Parse( Request.Form["numCases"]); string year = DateTime.Now.Year.ToString(); string month = DateTime.Now.Month.ToString(); if (int.Parse(month) < 10) { month = "0" + month; } string day = DateTime.Now.Day.ToString(); if (int.Parse(day) < 10) { day = "0" + day; } price *= numCases; string action = Request.Form["action"]; transaction tran = new transaction(); if (action == "inputProva") { int id = int.Parse(Request.Form["transId"]); tran = db.transactions.Find(id); tran.notes = notes + "*Case Input Prova at " + DateTime.Now.ToString("yyyy-MM-dd") + "*"; tran.isOut = false; tran.prova = true; } else if (action == "inputCase") { tran = new transaction(); tran.caseNumber = caseNumber; tran.notes = notes; tran.isOut = false; tran.prova = false; tran.recieveDate = enterdate; } else if (action == "outCase") { int id = int.Parse(Request.Form["transId"]); tran = db.transactions.Find(id); tran.notes = notes + "*Case Out at " + DateTime.Now.ToString("yyyy-MM-dd") + "*"; tran.isOut = true; tran.prova = false; Session["transId"] = id; } else if (action == "outProva") { int id = int.Parse(Request.Form["transId"]); tran = db.transactions.Find(id); tran.prova = true; tran.notes = notes + "*Case Out Prova at " + DateTime.Now.ToString("yyyy-MM-dd") + "*"; tran.isOut = true; } else { return; } tran.caseTeeth = caseTeeth; tran.caseColor = caseColor; tran.price = price; tran.patientName = patientName; tran.toRecieveDate = recieveDate; tran.caseId = caseId; tran.doctorId = doctorId; db.transactions.Add(tran); if (action == "inputProva" || action == "outCase" || action == "outProva") { db.Entry(tran).State = System.Data.EntityState.Modified; } else if (action == "inputCase" ) { db.Entry(tran).State = System.Data.EntityState.Added; } db.SaveChanges(); Response.Write("success," + price + "," + recieveDate.Month+"/"+recieveDate.Day+"/"+caseNumber); } catch (Exception e) { Response.Write("error"); } }
// // GET: /Supplier/ // all suppliers , add and delete public ActionResult Index() { teethLabEntities db = new teethLabEntities(); ViewData["suppliers"] = db.suppliers.ToList(); return View(); }
//view sadrat and wardat in specific day public ActionResult viewMoneyDays() { teethLabEntities db = new teethLabEntities(); List<doctor> doctors = db.doctors.Where(d => d.isActive == true).ToList(); ViewData["doctors"] = doctors; ViewData["emps"] = db.employees.ToList(); ViewData["companies"] = db.companies.ToList(); this.newDay(); ViewData["credit"] = this.currentCredit; ViewData["moneyDay"] = this.currentMoneyDay; return View(); }
private List<company> getCompaniesByName(string name) { teethLabEntities db = new teethLabEntities(); if (db.companies.Where(c => c.name.Contains(name)).Count() > 0) { return db.companies.Where(c => c.name.Contains(name)).ToList(); } return null; }
/// <summary> /// addd , delete company /// </summary> /// <returns></returns> public ActionResult viewAllCompanies() { teethLabEntities db = new teethLabEntities(); ViewData["companies"] = db.companies.ToList(); return View(); }
private void newDay() { moneyDay md = null; DateTime day; FileStream fs = new FileStream(Server.MapPath("~") + "/Content/files/startdate.txt", FileMode.Open); StreamReader sr = new StreamReader(fs); string date = sr.ReadToEnd(); sr.Close(); fs.Close(); System.Globalization.CultureInfo enUS = new System.Globalization.CultureInfo("en-US"); DateTime.TryParseExact(date, "yyyy-MM-dd", enUS, System.Globalization.DateTimeStyles.None, out day); teethLabEntities db = new teethLabEntities(); int credit = 0; if (db.moneyDays.Where(o => o.day.Year == day.Year && o.day.Month == day.Month && o.day.Day == day.Day ).Count() > 0) { md = db.moneyDays.Where(o => o.day.Year == day.Year && o.day.Month == day.Month && o.day.Day == day.Day).First(); credit = md.credit; } else { //get last day credit int lastId = db.moneyDays.Max(o => o.id); credit = 0; if (lastId != 0) { credit = db.moneyDays.Find(lastId).credit; } md = new moneyDay(); md.credit = credit; md.day = day; db.moneyDays.Add(md); db.SaveChanges(); } this.currentMoneyDay = md; this.currentCredit = credit; }
public void addNewCasePrice(int docId , int caseId , int price ) { caseDoctorPrice cp = new caseDoctorPrice(); cp.caseId = caseId; cp.doctorId = docId; cp.price = price; teethLabEntities db = new teethLabEntities(); db.caseDoctorPrices.Add(cp); db.SaveChanges(); }
public void DeleteCaseById(int caseid) { teethLabEntities db = new teethLabEntities(); @case cas = db.cases.Find(caseid); if (cas != null) { db.Entry(cas).State = System.Data.EntityState.Deleted; db.SaveChanges(); } }
public void getCaseByNumber() { try { int caseNumber = int.Parse(Request.Form["number"]); int caseDay = int.Parse(Request.Form["day"]); int caseMonth = int.Parse(Request.Form["month"]); teethLabEntities db = new teethLabEntities(); db.Configuration.ProxyCreationEnabled = false; transaction trans = db.transactions.Where(c => c.caseNumber == caseNumber && c.recieveDate.Day == caseDay && c.recieveDate.Month == caseMonth && c.recieveDate.Year == DateTime.Now.Year).First(); Response.Write("success^" + JsonConvert.SerializeObject(trans )); Json(trans, JsonRequestBehavior.AllowGet); //Json.Write(trans, Response.Output); } catch (Exception e) { } }
public ActionResult MoneyDays() { DateTime day; CultureInfo enUS = new CultureInfo("en-US"); DateTime.TryParseExact(Request.Form["day"], "yyyy-MM-dd", enUS, DateTimeStyles.None, out day); teethLabEntities db = new teethLabEntities(); moneyDay md = null; if (db.moneyDays.Where(o => o.day.Year == day.Year && o.day.Month == day.Month && o.day.Day == day.Day ).Count() > 0) { md = db.moneyDays.Where(o => o.day.Year == day.Year && o.day.Month == day.Month && o.day.Day == day.Day).First(); } TempData["moneyDay"] = md; return Redirect(Url.Action("viewMoneyDays", "Money")); }
// // GET: /Transaction/ /// <summary> /// add case /// </summary> /// <returns></returns> public ActionResult Index() { if (Request.Form["day"] != "" && Request.Form["day"] != null) { DateTime day ; CultureInfo enUS = new CultureInfo("en-US"); DateTime.TryParseExact(Request.Form["day"], "yyyy-MM-dd", enUS, DateTimeStyles.None, out day); ViewData["date"] = day; } else { ViewData["date"] = DateTime.Now; } teethLabEntities db = new teethLabEntities(); List<doctor> doctors = db.doctors.Where(d => d.isActive == true).ToList(); List<teethLab.@case> cases = db.cases.ToList(); ViewData["doctors"] = doctors; ViewData["cases"] = cases; return View(); }
// // GET: /Employee/ /// <summary> /// add , delete employees /// </summary> /// <returns></returns> public ActionResult Index() { teethLabEntities db = new teethLabEntities(); ViewData["emps"] = db.employees.ToList(); return View(); }
public int NewCaseNumber() { teethLabEntities db = new teethLabEntities(); int lastCaseNumber; if (this.monthChanged()) { lastCaseNumber = 0; } else { lastCaseNumber = db.transactions.Max(o => o.caseNumber); } lastCaseNumber++; return lastCaseNumber; }
public void getCaseById() { try { int caseId = int.Parse(Request.Form["caseId"]); teethLabEntities db = new teethLabEntities(); if (db.transactions.Where(c => c.caseNumber == caseId).Count() > 0) { db.Configuration.ProxyCreationEnabled = false; transaction trans = db.transactions.Where(c => c.caseNumber == caseId).First(); Response.Write("success^" + JsonConvert.SerializeObject(trans)); } }catch(Exception e){ } }
private List<doctor> getDocsByName(string name) { teethLabEntities db = new teethLabEntities(); if (db.doctors.Where(d => d.name.Contains(name)).Count() > 0) { return db.doctors.Where(d => d.name.Contains(name)).ToList(); } return null; }