예제 #1
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");
        }
예제 #2
0
        public void getDoctorById()
        {
            string id = Request.Form["id"];
            doctormodel doc = new doctormodel();
            doctor doct = doc.getdoctorbyid(int.Parse(id));
            if (doct != null)
            {
                Response.Write(doct.name + "," + doct.address + ","+doct.isActive+ "&");
                List<doctorPhone> docphones = doct.doctorPhones.ToList();
                if (docphones != null && docphones.Count > 0)
                {
                    foreach (doctorPhone docphone in docphones)
                    {
                        Response.Write(docphone.phone + "^");
                    }

                }
                Response.Write("&");
                List<caseDoctorPrice> docprices = doc.getDoctorPrices(doct.id);
                if (docprices != null && docprices.Count > 0)
                {
                    foreach (caseDoctorPrice price in docprices)
                    {
                        Response.Write([email protected] + "," + price.price + "," + price.id + "^");
                    }
                }
            }
        }
예제 #3
0
 public void getDoctorByName()
 {
     string val = Request.Form["val"];
     doctormodel doc = new doctormodel();
     List<doctor> docs = doc.getdoctorbyname(val);
     if (docs != null && docs.Count > 0)
     {
         foreach (doctor docc in docs)
         {
             Response.Write(docc.id + "," + docc.name + "&");
         }
     }
 }
예제 #4
0
 public void getallcases()
 {
     doctormodel dm = new doctormodel();
     List<@case> allcases = dm.getallcases();
     if (allcases != null && allcases.Count > 0)
     {
         foreach (@case cs in allcases)
         {
             Response.Write(cs.id + "," + cs.name + "&");
         }
     }
 }