public ActionResult Create([Bind(Include = "ProcessingNumberId,FullName,DateOfBirth,Gender,Nationality,State,City,PermanantAddress,PinCode,PhoneNumber,Date,Email,AcademicQualification,Course,HealthStatus")] Yogacenter yogacenter)
        {
            if (ModelState.IsValid)
            {
                db.Yogacenters.Add(yogacenter);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(yogacenter));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "DoctorId,ClinicName,Address,City,State,PinCode,Latitude,Longitude,ReceptionistAvaliable,LoginNeededForReceptionist,ReceptionistLoginMobileNumber,LandlineNumberOrMobileNumber,EmailId,MorningStartTime,MorningEndTime,EveningStartTime,EveningEndTime,Holidays,ScheduleDeatils,AppointmentMode,AppointmentSlotTime,AdditionalServicesInClinic,Fees,FollowUp")] Clinic clinic)
        {
            if (ModelState.IsValid)
            {
                db.Clinics.Add(clinic);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DoctorId = new SelectList(db.Doctors, "DoctorId", "Title", clinic.DoctorId);
            return(View(clinic));
        }
Exemplo n.º 3
0
        public ActionResult UploadExcel(Doctor users, HttpPostedFileBase FileUpload)
        {
            List <string> data = new List <string>();

            if (FileUpload != null)
            {
                // tdata.ExecuteCommand("truncate table OtherCompanyAssets");
                if (FileUpload.ContentType == "application/vnd.ms-excel" || FileUpload.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                {
                    string filename   = FileUpload.FileName;
                    string targetpath = Server.MapPath("~/Doc/");
                    FileUpload.SaveAs(targetpath + filename);
                    string pathToExcelFile  = targetpath + filename;
                    var    connectionString = "";
                    if (filename.EndsWith(".xls"))
                    {
                        connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", pathToExcelFile);
                    }
                    else if (filename.EndsWith(".xlsx"))
                    {
                        connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", pathToExcelFile);
                    }

                    var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString);
                    var ds      = new DataSet();

                    adapter.Fill(ds, "ExcelTable");

                    DataTable dtable = ds.Tables["ExcelTable"];

                    string sheetName = "Sheet1";

                    var excelFile    = new ExcelQueryFactory(pathToExcelFile);
                    var artistAlbums = from a in excelFile.Worksheet <Doctor>(sheetName) select a;

                    foreach (var a in artistAlbums)
                    {
                        try
                        {
                            Doctor TU = new Doctor();
                            TU.DoctorId           = a.DoctorId;
                            TU.FormNumber         = a.FormNumber;
                            TU.Date               = a.Date;
                            TU.Title              = a.Title;
                            TU.FullName           = a.FullName;
                            TU.Gender             = a.Gender;
                            TU.DateOfBirth        = a.DateOfBirth;
                            TU.MobileNumber       = a.MobileNumber;
                            TU.LandLineNumber     = a.LandLineNumber;
                            TU.Qualifications     = TU.Qualifications;
                            TU.Speciality         = TU.Speciality;
                            TU.Expertise          = TU.Expertise;
                            TU.RegistrationNumber = TU.RegistrationNumber;
                            TU.YearsOfExperience  = TU.YearsOfExperience;
                            TU.ShortProfile       = TU.ShortProfile;
                            TU.Email              = TU.Email;
                            TU.Website            = TU.Website;
                            TU.Subscription       = TU.Subscription;
                            TU.SmartPhone         = TU.SmartPhone;
                            db.Doctors.Add(TU);
                            db.SaveChanges();
                        }

                        catch (DbEntityValidationException ex)
                        {
                            foreach (var entityValidationErrors in ex.EntityValidationErrors)
                            {
                                foreach (var validationError in entityValidationErrors.ValidationErrors)
                                {
                                    Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                                }
                            }
                        }
                    }
                    //deleting excel file from folder
                    if ((System.IO.File.Exists(pathToExcelFile)))
                    {
                        System.IO.File.Delete(pathToExcelFile);
                    }
                    return(Json("success", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    //alert message for invalid file format
                    data.Add("<ul>");
                    data.Add("<li>Only Excel file format is allowed</li>");
                    data.Add("</ul>");
                    data.ToArray();
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                data.Add("<ul>");
                if (FileUpload == null)
                {
                    data.Add("<li>Please choose Excel file</li>");
                }
                data.Add("</ul>");
                data.ToArray();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }

            return(View(db.Doctors.ToList()));
        }