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"));
 }
Exemple #2
0
        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 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"));
        }
Exemple #8
0
        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 changeCasePrice()
 {
     teethLabEntities db = new teethLabEntities();
     int docId = int.Parse(Request.Form["docId"]);
     int caseId = int.Parse(Request.Form["caseId"]);
     int price = int.Parse(Request.Form["price"]);
     caseDoctorPrice cp = null;
     if (db.caseDoctorPrices.Where(o => o.caseId == caseId && o.doctorId == docId).Count() > 0)
     {
         cp = db.caseDoctorPrices.Where(o => o.caseId == caseId && o.doctorId == docId).First();
         db.Entry(cp).State = System.Data.EntityState.Modified;
         cp.price = price;
     }
     else
     {
         cp = new caseDoctorPrice();
         cp.doctorId = docId;
         cp.caseId = caseId;
         cp.price = price;
         db.Entry(cp).State = System.Data.EntityState.Added;
     }
     db.SaveChanges();
     Response.Write("success");
 }
Exemple #10
0
 public void deleteDoc()
 {
     teethLabEntities db = new teethLabEntities();
     int docId = int.Parse(Request.Form["id"]);
     db.Entry(db.doctors.Find(docId)).State = System.Data.EntityState.Deleted;
     db.SaveChanges();
     Response.Write("success");
 }
 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();
 }
 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 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 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);
        }
        //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");
            }
        }
Exemple #16
0
        public ActionResult editDoc()
        {
            string name = Request.Form["name"];
            string address = Request.Form["address"];
            int supplierId = int.Parse(Request.Form["supplier"]);
            int docId = int.Parse(Request.Form["id"]);
            teethLabEntities db = new teethLabEntities();
            doctor doc = db.doctors.Find(docId);
            doc.name = name;
            doc.address = address;

            if (supplierId != 0)
                doc.supplierId = supplierId;
            db.Entry(db.doctors.Find(docId)).State = System.Data.EntityState.Modified;
            db.SaveChanges();

            return Redirect(Url.Action("Index", "Doctor"));
        }
Exemple #17
0
 public void changeCase()
 {
     teethLabEntities db = new teethLabEntities();
     int transId = int.Parse(Request.Form["transId"]);
     transaction trans = db.transactions.Find(transId);
     db.Entry(trans).State = System.Data.EntityState.Modified;
     if (trans.isOut == true)
     {
         trans.isOut = false;
     }
     else
     {
         trans.isOut = true;
     }
     db.SaveChanges();
     Response.Write("success");
 }
Exemple #18
0
        //
        // 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();
        }
Exemple #19
0
        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");
        }
Exemple #20
0
        public void import()
        {
            //test changes in source control
            int cost, id = 0, receiptno = 0;
            try
            {
                receiptno = int.Parse(Request.Form["receiptno"]);
                cost = int.Parse(Request.Form["cost"]);
            }
            catch (Exception e)
            {
                Response.Write("Please enter cost and reciept number");
                return;
            }
            if (Request.Form["id"] != "" && Request.Form["id"] != null)
            {
                id = int.Parse(Request.Form["id"]);
            }
            string name = Request.Form["name"];

            if (Request.Form["day"] == "" || Request.Form["day"] == null)
            {
                Response.Write("you must select day first");

                return;
            }
            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();
            int dayId = 0;
            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
            {
                Response.Write("you must select day first");
                return;
            }

            db.SaveChanges();
            dayId = md.id;
            db = new teethLabEntities();

            money m = new money();
            m.dayId = dayId;
            if (id != 0)
            {
                m.doctorId = id;
                try
                {
                    m.fromTo = name;
                }
                catch (Exception e)
                {
                    m.fromTo = "طبيب";
                }
            }
            else if (name != "" || name != null)
            {
                m.fromTo = name;
            }
            if (db.moneys.Where(o => o.receiptno == receiptno).Count() > 0)
            {
                Response.Write("receipt number cannot duplicated");
                return;
            }
            m.receiptno = receiptno;
            m.type = "import";
            m.recieveDate = DateTime.Now;
            m.value = cost;
            db.Entry(m).State = System.Data.EntityState.Added;
            db.moneys.Add(m);
            db.SaveChanges();
            if (id != 0)
            {
                db = new teethLabEntities();
                doctor doc = db.doctors.Find(id);
                doc.depit -= cost;
                db.Entry(doc).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }
            Response.Write("success");
        }
Exemple #21
0
        public void addnewdoctor()
        {
            string name = Request.Form["name"];
            string address = Request.Form["address"];
            string phones = Request.Form["phones"];
            string products = Request.Form["products"];
            bool active = bool.Parse(Request.Form["activate"]);
            if (name == "" || name == null
                || address == "" || address == null
                || products == "" || products == null
                )
            {
                return;
            }

            string action = Request.Form["action"];

            teethLabEntities db = new teethLabEntities();

            doctor newdoc = null;
            if (action == "add")
            {
                newdoc = new teethLab.doctor();
            }
            else if (action == "edit")
            {
                int id = int.Parse(Request.Form["doctorid"]);
                newdoc = db.doctors.Find(id);
            }

            newdoc.name = name;
            newdoc.address = address;
            newdoc.isActive = active;
            doctormodel dm = new doctormodel();

            if (action == "add")
            {
                dm.addnewdoctor(newdoc);

            }

            if (action == "edit")
            {
                dm.deletealldoctorphones(newdoc.id);
                db.Entry(newdoc).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }

            string[] allphones = phones.Split(',');
            for (int i = 0; i < allphones.Length - 1; i++)
            {
                doctorPhone dp = new doctorPhone();
                dp.phone = allphones[i];
                dp.doctorId = newdoc.id;
                if (!dm.addnewdoctorphone(dp))
                {
                    return;
                }
            }

            if (action == "add")
            {
                string[] allproducts = products.Split('^');
                for (int i = 0; i < allproducts.Length - 1; i++)
                {
                    caseDoctorPrice cp = new caseDoctorPrice();
                    cp.caseId = int.Parse(allproducts[i].Split(',')[0]);
                    cp.doctorId = newdoc.id;
                    cp.price = int.Parse(allproducts[i].Split(',')[1]);
                    dm.addnewcaseprice(cp);
                }
            }
            else if (action == "edit")
            {
                string[] allproducts = products.Split('^');
                 db = new teethLabEntities();
                for (int i = 0; i < allproducts.Length - 1; i++)
                {
                    int id=int.Parse(allproducts[i].Split(',')[0]);

                    caseDoctorPrice cp =db.caseDoctorPrices.Find(id);
                    cp.price = int.Parse(allproducts[i].Split(',')[1]);
                    db.Entry(cp).State = System.Data.EntityState.Modified;
                }
                db.SaveChanges();
            }

            Response.Write("success");
        }