Пример #1
0
        public ActionResult Create([Bind(Include = "Id,Name")] tbl_MajorArea tbl_MajorArea)
        {
            if (ModelState.IsValid)
            {
                db.tbl_MajorArea.Add(tbl_MajorArea);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_MajorArea));
        }
        public ActionResult Create([Bind(Include = "Id,Name")] tbl_VisualAcuityType tbl_VisualAcuityType)
        {
            if (ModelState.IsValid)
            {
                db.tbl_VisualAcuityType.Add(tbl_VisualAcuityType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_VisualAcuityType));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Address,ChiefComplains,Age,Sex,Mrno")] tbl_Patient tbl_Patient)
        {
            if (ModelState.IsValid)
            {
                db.tbl_Patient.Add(tbl_Patient);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_Patient));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "Id,MajorAreaId,Rx,PatientId,NextVisit,EntryDate")] tbl_Rx tbl_Rx)
        {
            if (ModelState.IsValid)
            {
                db.tbl_Rx.Add(tbl_Rx);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MajorAreaId = new SelectList(db.tbl_MajorArea, "Id", "Name", tbl_Rx.MajorAreaId);
            ViewBag.PatientId   = new SelectList(db.tbl_Patient, "Id", "Name", tbl_Rx.PatientId);
            return(View(tbl_Rx));
        }
Пример #5
0
 public ActionResult Edit(Usergroup model, Guid?[] formlist, Guid?[] DelList)
 {
     if (GlobalClass.SystemSession)
     {
         Usergroup abm = db.Usergroup.Find(model.UserGroupKey);
         abm.GroupName = model.GroupName;
         abm.GroupID   = model.GroupID;
         db.SaveChanges();
         if (formlist == null)
         {
         }
         else
         {
             if (formlist.Count() > 0)
             {
                 foreach (var item in formlist)
                 {
                     db = new HasanHoutoneEntities();
                     Forms f = db.Forms.Find(item);
                     CheckForModule(f.ModuleID, model.UserGroupKey);
                     UserGroupForm obj = new UserGroupForm();
                     obj.CompanyKey       = GlobalClass.Company.CompanyKey;
                     obj.ModuleKey        = f.ModuleID;
                     obj.UserGroupKey     = abm.UserGroupKey;
                     obj.UserGroupFormKey = Guid.NewGuid();
                     obj.FormKey          = item;
                     db.UserGroupForm.Add(obj);
                     db.SaveChanges();
                 }
             }
         }
         if (DelList == null)
         {
         }
         else
         {
             if (DelList.Count() > 0)
             {
                 foreach (var item in DelList)
                 {
                     db = new HasanHoutoneEntities();
                     UserGroupForm f = db.UserGroupForm.Find(item);
                     CheckForModuleBeforDelete(f);
                     db.UserGroupForm.Remove(f);
                     db.SaveChanges();
                 }
             }
         }
         return(RedirectToAction("Index"));
     }
     else
     {
         Exception e = new Exception("Sorry, your Session has Expired");
         return(View("Error", new HandleErrorInfo(e, "UserHome", "Logout")));
     }
 }
        public ActionResult Access(StaffClass model, string Save)
        {
            if (GlobalClass.SystemSession)
            {
                if (!string.IsNullOrEmpty(Save))
                {
                    StaffList staffList = db.StaffList.Find(model.PersonnelKey);
                    staffList.IsUser = true;

                    staffList.Password = model.Password;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View(model));
            }
            else
            {
                Exception e = new Exception("Sorry, your Session has Expired");
                return(View("Error", new HandleErrorInfo(e, "UserHome", "Logout")));
            }
        }
Пример #7
0
        private void AddModulesToCompany(Forms obj, Guid id)
        {
            var t = from x in db.CompanyModule where x.ModuleKey == obj.ModuleID && x.CompanyKey == id select x;

            if (!(t.Count() > 0))
            {
                db = new HasanHoutoneEntities();
                CompanyModule a = new CompanyModule();
                a.CompanyModuleID = Guid.NewGuid();
                a.CompanyKey      = id;
                a.ModuleKey       = obj.ModuleID;
                db.CompanyModule.Add(a);
                db.SaveChanges();
            }
        }
Пример #8
0
        private void CheckForModuleBeforDelete(UserGroupForm f)
        {
            HasanHoutoneEntities ac = new HasanHoutoneEntities();
            var temp = from x in ac.UserGroupForm where x.UserGroupKey == f.UserGroupKey && x.ModuleKey == f.ModuleKey && x.CompanyKey == GlobalClass.Company.CompanyKey select x;

            if (temp.Count() > 0)
            {
            }
            else
            {
                UserGroupModule obj = db.UserGroupModule.FirstOrDefault(x => x.UserGroupKey == f.UserGroupKey && x.ModuleKey == f.ModuleKey && x.CompanyKey == GlobalClass.Company.CompanyKey);
                ac.UserGroupModule.Remove(obj);
                ac.SaveChanges();
            }
        }
Пример #9
0
 public ActionResult Delete(Guid?id)
 {
     if (GlobalClass.SystemSession)
     {
         Usergroup company = db.Usergroup.Find(id);
         var       temp    = from x in db.UserGroupForm where x.UserGroupKey == id select x;
         var       temp2   = from x in db.UserGroupModule where x.UserGroupKey == id select x;
         var       temp3   = from x in db.StaffList where x.Usergr == id select x;
         if (temp.Count() > 0)
         {
             foreach (var a in temp)
             {
                 HasanHoutoneEntities ac   = new HasanHoutoneEntities();
                 UserGroupForm        form = db.UserGroupForm.Find(a.UserGroupFormKey);
                 ac.UserGroupForm.Remove(form);
                 ac.SaveChanges();
             }
         }
         if (temp3.Count() > 0)
         {
             foreach (var a in temp3)
             {
                 HasanHoutoneEntities ac   = new HasanHoutoneEntities();
                 StaffList            form = db.StaffList.Find(a.PersonnelKey);
                 form.Usergr = null;
                 ac.SaveChanges();
             }
         }
         if (temp2.Count() > 0)
         {
             foreach (var a in temp2)
             {
                 HasanHoutoneEntities ac   = new HasanHoutoneEntities();
                 UserGroupModule      form = db.UserGroupModule.Find(a.UserGroupModuleKey);
                 ac.UserGroupModule.Remove(form);
                 ac.SaveChanges();
             }
         }
         db.Usergroup.Remove(company);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         Exception e = new Exception("Sorry, your Session has Expired");
         return(View("Error", new HandleErrorInfo(e, "UserHome", "Logout")));
     }
 }
Пример #10
0
        private void CheckForModule(Guid moduleID, Guid UserGroupKey)
        {
            HasanHoutoneEntities ac = new HasanHoutoneEntities();
            var temp = from x in ac.UserGroupModule where x.UserGroupKey == UserGroupKey && x.ModuleKey == moduleID && x.CompanyKey == GlobalClass.Company.CompanyKey select x;

            if (temp.Count() > 0)
            {
            }
            else
            {
                UserGroupModule obj = new UserGroupModule();
                obj.CompanyKey         = GlobalClass.Company.CompanyKey;
                obj.ModuleKey          = moduleID;
                obj.UserGroupKey       = UserGroupKey;
                obj.UserGroupModuleKey = Guid.NewGuid();
                ac.UserGroupModule.Add(obj);
                ac.SaveChanges();
            }
        }
Пример #11
0
        public ActionResult Create(Company company, HttpPostedFileBase file)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (file != null)
                    {
                        byte[] data = null;
                        using (Stream inputStream = file.InputStream)
                        {
                            MemoryStream memoryStream = inputStream as MemoryStream;
                            if (memoryStream == null)
                            {
                                memoryStream = new MemoryStream();
                                inputStream.CopyTo(memoryStream);
                            }
                            data = memoryStream.ToArray();
                        }
                        company.Logo     = data;
                        company.LogoType = file.ContentType;
                    }
                    company            = val.ValidateCompany(company);
                    company.IsDelete   = false;
                    company.CompanyKey = Guid.NewGuid();
                    db.Company.Add(company);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(company));
            }
            catch (Exception e)
            {
                return(View("Error", new HandleErrorInfo(e, "AdminLogin", "UserHome")));
            }
        }
Пример #12
0
        public ActionResult Create(StaffClass staffList, HttpPostedFileBase file)
        {
            if (GlobalClass.SystemSession)
            {
                ViewBag.mess = "";
                bool flag = true;
                if (string.IsNullOrEmpty(staffList.PID))
                {
                }
                else
                {
                    var uid = from x in db.StaffList where x.PID == staffList.PID && x.CompanyKey == GlobalClass.Company.CompanyKey select x;
                    if (uid.Count() > 0)
                    {
                        ViewBag.mess = "Duplicate ID";
                        flag         = false;
                    }
                    else
                    {
                    }
                }
                if (flag == true)
                {
                    if (file != null)
                    {
                        byte[] data = null;

                        data              = BufferFromImage(file, 50, 80);
                        staffList.Pic     = data;
                        staffList.PicType = file.ContentType;
                    }
                    staffList = Val.ValidateStaff(staffList, true);
                    StaffList model = new StaffList();
                    model.PersonnelKey = Guid.NewGuid();
                    model.IsUser       = true;
                    model.IsDelete     = false;
                    model.Pic          = staffList.Pic; model.PicType = staffList.PicType;
                    model.PID          = staffList.PID;
                    model.PName        = staffList.PName;
                    model.Mobile       = staffList.Mobile;
                    model.Mail         = staffList.Mail;
                    model.Designation  = staffList.Designation;
                    model.Department   = staffList.Department;
                    model.Username     = staffList.Username;
                    model.Password     = staffList.Password;
                    model.Usergr       = staffList.Usergr;
                    model.CompanyKey   = GlobalClass.Company.CompanyKey;
                    db.StaffList.Add(model);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.Usergr = new SelectList(db.Usergroup.Where(m => m.CompanyKey == GlobalClass.Company.CompanyKey).OrderBy(m => m.GroupName), "UserGroupKey", "GroupName", staffList.Usergr);

                return(View(staffList));
            }
            else
            {
                Exception e = new Exception("Sorry, your Session has Expired");
                return(View("Error", new HandleErrorInfo(e, "UserHome", "Logout")));
            }
        }
Пример #13
0
        public ActionResult ConpanyUserAcess(Company model, Guid?[] unformlist, Guid?[] formlist)
        {
            if (GlobalClass.MasterSession)
            {
                if (unformlist == null)
                {
                }
                else
                {
                    if (unformlist.Count() > 0)
                    {
                        foreach (var temp in unformlist)
                        {
                            db = new HasanHoutoneEntities();
                            CompanyForm a         = db.CompanyForm.Find(temp);
                            Guid?       comkey    = a.CompanyKey;
                            Guid?       moduleKey = a.ModuleKey;
                            Guid?       formKey   = a.FormKey;
                            db.CompanyForm.Remove(a);
                            db.SaveChanges();
                            CheckCompanyForModule(comkey, moduleKey);

                            db = new HasanHoutoneEntities();
                            var fg = from m in db.UserGroupForm where m.FormKey == formKey && m.CompanyKey == comkey select m;
                            if (fg.Count() > 0)
                            {
                                foreach (var item in fg)
                                {
                                    HasanHoutoneEntities nr = new HasanHoutoneEntities();
                                    UserGroupForm        b  = nr.UserGroupForm.SingleOrDefault(m => m.UserGroupFormKey == item.UserGroupFormKey);
                                    Guid k  = (Guid)b.ModuleKey;
                                    Guid uk = (Guid)b.UserGroupKey;
                                    nr.UserGroupForm.Remove(b);
                                    nr.SaveChanges();
                                    CheckUserGroupForModule(k, uk);
                                }
                            }
                        }
                    }
                }
                if (formlist == null)
                {
                }
                else
                {
                    if (formlist.Count() > 0)
                    {
                        foreach (var temp in formlist)
                        {
                            db = new HasanHoutoneEntities();
                            Forms o = db.Forms.Find(temp);
                            AddModulesToCompany(o, model.CompanyKey);
                            CompanyForm a = new CompanyForm();
                            a.CompanyFormKey = Guid.NewGuid();
                            a.FormKey        = temp;
                            a.CompanyKey     = model.CompanyKey;
                            a.ModuleKey      = o.ModuleID;
                            db.CompanyForm.Add(a);
                            db.SaveChanges();
                        }
                    }
                }
                model = db.Company.Find(model.CompanyKey);
                ViewBag.CompanyKey = new SelectList(db.Company, "CompanyKey", "CompanyName", model.CompanyKey);
                return(View(model));
            }
            else
            {
                Exception e = new Exception("Session Expired");
                return(View("Error", new HandleErrorInfo(e, "AdminLogin", "UserHome")));
            }
        }
Пример #14
0
        internal DataReturn SaveMainData(Prescription prescriptionObj)
        {
            DataReturn model = new DataReturn();

            try
            {
                tbl_Rx ent = new tbl_Rx();
                // ent.Id = prescriptionObj.Id;
                ent.MajorAreaId = prescriptionObj.MajorAreaId;
                ent.Rx          = prescriptionObj.Rx;
                ent.PatientId   = prescriptionObj.PatientId;
                ent.NextVisit   = prescriptionObj.NextVisit;
                ent.EntryDate   = DateTime.Now;

                ent.VisualAcuityLeftEye      = prescriptionObj.VisualAcuityLeftEye;
                ent.VisualAcuityLeftEyeType  = prescriptionObj.VisualAcuityLeftEyeType;
                ent.VisualAcuityRightEye     = prescriptionObj.VisualAcuityRightEye;
                ent.VisualAcuityRightEyeType = prescriptionObj.VisualAcuityRightEyeType;


                db.tbl_Rx.Add(ent);
                db.SaveChanges();

                model.Pkey = ent.Id;

                foreach (var drug in GlobalClass.DragList)
                {
                    tbl_RxDrug drugEnt = new tbl_RxDrug();
                    drugEnt.DrugId      = drug.DrugId;
                    drugEnt.RxId        = model.Pkey;
                    drugEnt.Instruction = drug.Instruction;

                    db.tbl_RxDrug.Add(drugEnt);
                    db.SaveChanges();
                }

                foreach (var drop in GlobalClass.DropList)
                {
                    tbl_RxDrop dropEnt = new tbl_RxDrop();
                    dropEnt.DropId      = drop.DropId;
                    dropEnt.RxId        = model.Pkey;
                    dropEnt.Instruction = drop.Instruction;

                    db.tbl_RxDrop.Add(dropEnt);
                    db.SaveChanges();
                }

                foreach (var invest in GlobalClass.InvestigationList)
                {
                    tbl_RxInvestigation investEnt = new tbl_RxInvestigation();
                    investEnt.InvestigationId = invest.InvestigationId;
                    investEnt.RxId            = model.Pkey;
                    investEnt.Instruction     = invest.Instruction;

                    db.tbl_RxInvestigation.Add(investEnt);
                    db.SaveChanges();
                }



                model.flag = 1;
                model.mess = "Data has been saved successfully.";
            }
            catch (Exception ex)
            {
                model.flag = 0;
                model.mess = ex.Message.ToString();
            }


            return(model);
        }