Beispiel #1
0
        /// <summary>
        ///  Search hospitals in database using Advanced option
        /// </summary>
        /// <param name="cityId">City ID</param>
        /// <param name="districtId">District ID</param>
        /// <param name="specialityId">Speciality ID</param>
        /// <param name="diseaseName">Disease name</param>
        /// <returns>List[HospitalEntity] that contains a list of Hospitals</returns>
        public async Task <List <HospitalEntity> > AdvancedSearchHospital(int cityId,
                                                                          int districtId, int specialityId, string diseaseName)
        {
            List <HospitalEntity> hospitalList = null;

            // Search for suitable hospitals in database
            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                hospitalList = await Task.Run(() =>
                                              (from h in data.SP_ADVANCED_SEARCH_HOSPITAL(cityId, districtId, specialityId, diseaseName)
                                               select new HospitalEntity()
                {
                    Hospital_ID = h.Hospital_ID,
                    Hospital_Name = h.Hospital_Name,
                    Address = h.Address,
                    Ward_ID = h.Ward_ID,
                    District_ID = h.District_ID,
                    City_ID = h.City_ID,
                    Phone_Number = h.Phone_Number,
                    Coordinate = h.Coordinate,
                    Is_Active = h.Is_Active,
                    Rating = h.Rating
                }).ToList());
            }

            // Return list of hospitals
            return(hospitalList);
        }
Beispiel #2
0
        /// <summary>
        /// Search hospitals in database using normal option
        /// </summary>
        /// <returns></returns>
        public async Task <List <HospitalEntity> > NormalSearchHospital()
        {
            List <HospitalEntity> hospitalList = null;

            // Take input values
            int    cityId     = this.CityID;
            int    districtId = this.DistrictID;
            string whatPhrase = this.WhatPhrase;

            // Search for suitable hospitals in database
            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                hospitalList = await Task.Run(() =>
                                              (from h in data.SP_NORMAL_SEARCH_HOSPITAL(whatPhrase.Trim().ToLower(),
                                                                                        cityId, districtId)
                                               select new HospitalEntity()
                {
                    Hospital_ID = h.Hospital_ID,
                    Hospital_Name = h.Hospital_Name,
                    Address = h.Address,
                    Ward_ID = h.Ward_ID,
                    District_ID = h.District_ID,
                    City_ID = h.City_ID,
                    Phone_Number = h.Phone_Number,
                    Coordinate = h.Coordinate,
                    Is_Active = h.Is_Active,
                    Rating = h.Rating
                }).ToList());
            }

            // Return list of hospitals
            return(hospitalList);
        }
Beispiel #3
0
        /// <summary>
        /// Search hospitals in database using Location option
        /// </summary>
        /// <param name="latitude">Latitide</param>
        /// <param name="longitude">Longitude</param>
        /// <param name="distance">Distance between 2 locations</param>
        /// <returns>List[HospitalEntity] that contains a list of Hospitals</returns>
        public static async Task <List <HospitalEntity> > LocationSearchHospital(double latitude, double longitude, double distance)
        {
            List <HospitalEntity> hospitalList = null;

            // Search for suitable hospitals in database
            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                hospitalList = await Task.Run(() =>
                                              (from h in data.SP_LOCATION_SEARCH_HOSPITAL(latitude, longitude, distance)
                                               select new HospitalEntity()
                {
                    Hospital_ID = h.Hospital_ID,
                    Hospital_Name = h.Hospital_Name,
                    Address = h.Address,
                    Ward_ID = h.Ward_ID,
                    District_ID = h.District_ID,
                    City_ID = h.City_ID,
                    Phone_Number = h.Phone_Number,
                    Coordinate = h.Coordinate,
                    Is_Active = h.Is_Active,
                    Rating = h.Rating
                }).ToList());
            }

            // Return list of hospitals
            return(hospitalList);
        }
Beispiel #4
0
        /// <summary>
        /// Load all speciality by hospital code
        /// </summary>
        /// <returns>List[SpecialityEntity] that contains a list of speciality</returns>
        public static async Task <List <Speciality> > LoadSpecialityByHospitalIDAsync(int HospitalID)
        {
            List <SP_LOAD_SPECIALITY_BY_HOSPITALIDResult> result = null;

            // Take specalities in a specific hospital in database
            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                result = await Task.Run(() =>
                                        data.SP_LOAD_SPECIALITY_BY_HOSPITALID(HospitalID).ToList());
            }

            List <Speciality> specialityList = new List <Speciality>();
            Speciality        speciality     = null;

            // Assign values for each speciality
            foreach (SP_LOAD_SPECIALITY_BY_HOSPITALIDResult re in result)
            {
                if (re.Speciality_ID != 1)
                {
                    speciality = new Speciality();
                    speciality.Speciality_ID   = re.Speciality_ID;
                    speciality.Speciality_Name = re.Speciality_Name;
                    specialityList.Add(speciality);
                }
            }

            // Return list of speciality
            return(specialityList);
        }
Beispiel #5
0
        public static List <FeedbackEntity> LoadHospitalUserFeedback(DateTime fromDate, DateTime toDate, int feedbackType, int responseType, int hospialId)
        {
            List <FeedbackEntity> feedbackList = null;

            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                feedbackList = (from f in data.Feedbacks
                                from ft in data.FeedbackTypes
                                where f.Feedback_Type == ft.Type_ID && ft.Is_Active == true &&
                                fromDate <= f.Created_Date && f.Created_Date <= toDate &&
                                (f.Feedback_Type == 4 || f.Feedback_Type == 5) &&       // Only Type_ID == 4 and Type_ID == 5
                                (feedbackType == 0 || f.Feedback_Type == feedbackType) &&
                                (responseType == 0 || f.Is_Response == (responseType == 1 ? true : false)) &&
                                f.Hospital_ID == hospialId
                                select new FeedbackEntity()
                {
                    Feedback_ID = f.Feedback_ID,
                    Header = f.Header,
                    Feedback_Content = f.Feedback_Content,
                    Email = f.Email,
                    Feedback_Type = ft.Type_Name,
                    Created_Date = f.Created_Date,
                    Is_Response = f.Is_Response
                }).ToList <FeedbackEntity>();
            }
            return(feedbackList);
        }
Beispiel #6
0
        /// <summary>
        /// Delete file from server
        /// </summary>
        /// <param name="id">File ID</param>
        /// <param name="fileName">File name</param>
        /// <param name="type">File type. 1: Photo, 2: Excel</param>
        /// <returns>1: Successful, 0: Failed</returns>
        public static async Task <int> DeleteFileFromServer(
            int id, string fileName, int type)
        {
            int result = 0;

            // Check file type
            if (type == 1)
            {
                using (LinqDBDataContext data = new LinqDBDataContext())
                {
                    Photo deleteFile = await Task.Run(() =>
                                                      (from p
                                                       in data.Photos
                                                       where p.Photo_ID == id
                                                       select p).SingleOrDefault());

                    data.Photos.DeleteOnSubmit(deleteFile);
                    result = data.GetChangeSet().Deletes.Count;
                    data.SubmitChanges();
                    if (result != 0)
                    {
                        string fileLocation = WebConfigurationManager.AppSettings[Constants.PhotoFolder];
                        string filePath     = Path.Combine(fileLocation, fileName);
                        File.Delete(filePath);
                    }
                }
            }

            // Return delete result
            return(result);
        }
        public async Task <ActionResult> UpdateDisease(DataModel model)
        {
            try
            {
                // Prepare data
                int result = 0;
                model.IsPostBack = false;
                model.IsActive   = true;

                // Return list of dictionary words
                using (LinqDBDataContext data = new LinqDBDataContext())
                {
                    result = await model.UpdateDiseaseAsync(model.DiseaseID,
                                                            model.DiseaseName, model.SelectedSpecialities);
                }

                // Return result
                TempData[Constants.ProcessUpdateData] = result;
                return(RedirectToAction(Constants.DisplayDiseaseAction, Constants.DataController, model));
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }
Beispiel #8
0
        /// <summary>
        /// Load all doctor in Doctor_Speciality
        /// </summary>
        /// <param name="SpecialityID"></param>
        /// <returns>List[DoctorEnity] that contains list of doctor with appropriate Speciality code</returns>
        public static async Task <List <Doctor> > LoadDoctorInDoctorSpecialityAsyn(int SpecialityID, int HospitalID)
        {
            List <Doctor> doctorList = new List <Doctor>();
            Doctor        doctor     = null;
            List <SP_LOAD_DOCTOR_BY_SPECIALITYIDResult> result = null;

            // Take doctor in specific speciality in database
            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                result = await Task.Run(() =>
                                        data.SP_LOAD_DOCTOR_BY_SPECIALITYID(SpecialityID, HospitalID).ToList());
            }
            // Assign value for each doctor
            foreach (SP_LOAD_DOCTOR_BY_SPECIALITYIDResult r in result)
            {
                doctor             = new Doctor();
                doctor.Doctor_ID   = r.Doctor_ID;
                doctor.First_Name  = r.First_Name;
                doctor.Last_Name   = r.Last_Name;
                doctor.Degree      = r.Degree;
                doctor.Experience  = r.Experience;
                doctor.Working_Day = r.Working_Day;
                doctor.Photo_ID    = r.Photo_ID;
                doctorList.Add(doctor);
            }
            Appointment app = new Appointment();

            return(doctorList);
        }
Beispiel #9
0
        public static async Task <List <Doctor> > LoadDoctorInDoctorHospitalAsync(int hospitalID)
        {
            List <SP_LOAD_DOCTOR_IN_DOCTOR_HOSPITALResult> result = null;
            List <Doctor> doctorList = new List <Doctor>();
            Doctor        doctor     = null;

            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                result = await Task.Run(() => data.SP_LOAD_DOCTOR_IN_DOCTOR_HOSPITAL(hospitalID).ToList());
            }

            foreach (SP_LOAD_DOCTOR_IN_DOCTOR_HOSPITALResult re in result)
            {
                doctor             = new Doctor();
                doctor.Doctor_ID   = re.Doctor_ID;
                doctor.First_Name  = re.First_Name;
                doctor.Last_Name   = re.Last_Name;
                doctor.Degree      = re.Degree;
                doctor.Experience  = re.Experience;
                doctor.Photo_ID    = re.Photo_ID;
                doctor.Working_Day = re.Working_Day;
                doctorList.Add(doctor);
            }
            return(doctorList);
        }
        public async Task <ActionResult> AddSpeciality(DataModel model)
        {
            try
            {
                // Prepare data
                int result = 0;
                model.IsPostBack = true;
                model.IsActive   = true;

                // Return list of dictionary words
                using (LinqDBDataContext data = new LinqDBDataContext())
                {
                    result = await model.AddSpeciality(model);
                }

                // Return result
                TempData[Constants.ProcessInsertData] = result;
                return(RedirectToAction(Constants.DisplaySpecialityAction, Constants.DataController, model));
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }
Beispiel #11
0
 public void GetReservas(String rut)
 {
     this.rut = rut;
     ListaReservas = new List<Reserva>();
     LinqDBDataContext db = new LinqDBDataContext();
     var reservas = from reserva in db.RESERVA
                     where
                         reserva.RUT_CLI == rut
                     select new
                     {
                         reserva.FECHA,
                         reserva.HORARIO,
                         reserva.NUMERO_COMENSALES,
                         reserva.OBSERVACIONES,
                         reserva.CODIGO_MESA
                     };
     foreach (var r in reservas)
     {
         Reserva rl = new Reserva();
         rl.fecha = r.FECHA;
         rl.horario = r.HORARIO;
         rl.comensales = r.NUMERO_COMENSALES;
         rl.observaciones = r.OBSERVACIONES;
         rl.mesa = Convert.ToInt32(r.CODIGO_MESA);
         ListaReservas.Add(rl);
     }
 }
Beispiel #12
0
        public async Task <ActionResult> FeedBack(FeedBackModels model)
        {
            try
            {
                string url    = Request.Url.AbsoluteUri;
                int    result = 0;

                // Return list of dictionary words
                using (LinqDBDataContext data = new LinqDBDataContext())
                {
                    result = await FeedBackModels.InsertFeedbackAsync(model);
                }

                // Check returned result
                if (result == 1)
                {
                    ViewBag.AddFeedbackStatus = 1;
                    return(RedirectToAction(Constants.HospitalAction, Constants.HomeController, new { hospitalId = model.HospitalID, redirect = "yes" }));
                }
                else
                {
                    ViewBag.AddFeedbackStatus = 0;
                    ModelState.Clear();
                    return(View());
                }
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }
Beispiel #13
0
        /// <summary>
        /// Add new disease
        /// </summary>
        /// <param name="diseaseName">Disease name</param>
        /// <param name="specialityList">List of speciality ID</param>
        /// <returns>1: Successful, 0: Failed</returns>
        public async Task <int> AddDiseaseAsync(string diseaseName, List <string> specialityList)
        {
            // Speciality list
            string speciality = string.Empty;

            if ((specialityList != null) && (specialityList.Count != 0))
            {
                for (int n = 0; n < specialityList.Count; n++)
                {
                    if (n == (specialityList.Count - 1))
                    {
                        speciality += specialityList[n];
                    }
                    else
                    {
                        speciality += specialityList[n] +
                                      Constants.VerticalBar.ToString();
                    }
                }
            }

            // Insert new service to database
            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                return(await Task.Run(() =>
                                      data.SP_INSERT_DISEASE(diseaseName, speciality)));
            }
        }
Beispiel #14
0
        /// <summary>
        /// Update disease
        /// </summary>
        /// <param name="diseaseId">Disease ID</param>
        /// <param name="diseaseName">Disease name</param>
        /// <param name="specialityList">List of speciality ID</param>
        /// <returns>1: Successful, 0: Failed</returns>
        public async Task <int> UpdateDiseaseAsync(int diseaseId,
                                                   string diseaseName, List <string> specialityList)
        {
            // Speciality list
            string speciality = string.Empty;

            if ((specialityList != null) && (specialityList.Count != 0))
            {
                for (int n = 0; n < specialityList.Count; n++)
                {
                    if (n == (specialityList.Count - 1))
                    {
                        speciality += specialityList[n];
                    }
                    else
                    {
                        speciality += specialityList[n] +
                                      Constants.VerticalBar.ToString();
                    }
                }
            }

            // Update service information
            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                return(await Task.Run(() =>
                                      data.SP_UPDATE_DISEASE(diseaseId, diseaseName, speciality)));
            }
        }
Beispiel #15
0
        public static async Task <List <Doctor> > SearchDoctor(string DoctorName, int SpecialityID, int HospitalID)
        {
            List <Doctor> doctorList             = new List <Doctor>();
            Doctor        doctor                 = null;
            List <SP_SEARCH_DOCTORResult> result = null;

            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                result = await Task.Run(() =>
                                        data.SP_SEARCH_DOCTOR(DoctorName, SpecialityID, HospitalID).ToList());
            }
            foreach (SP_SEARCH_DOCTORResult r in result)
            {
                doctor             = new Doctor();
                doctor.Doctor_ID   = r.Doctor_ID;
                doctor.First_Name  = r.First_Name;
                doctor.Last_Name   = r.Last_Name;
                doctor.Degree      = r.Degree;
                doctor.Experience  = r.Experience;
                doctor.Working_Day = r.Working_Day;
                doctor.Photo_ID    = r.Photo_ID;
                doctorList.Add(doctor);
            }
            return(doctorList);
        }
Beispiel #16
0
 public static bool RateHospital(int userId, int hospitalId, int score)
 {
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         int result = data.SP_RATE_HOSPITAL(userId, hospitalId, score);
         return(result > 0);
     }
 }
Beispiel #17
0
        public virtual void Delete(LinqDBDataContext dc)
        {
            Type t = this.GetType();

            object[] oo = t.GetCustomAttributes(typeof(TableAttribute), true);
            if (oo == null || oo.Length < 1)
            {
                return;
            }
            TableAttribute ta = (TableAttribute)oo[0];

            string        q;
            List <object> Params   = new List <object>();
            PropertyInfo  PiStatus = t.GetProperty("Status");

            if (PiStatus != null && PiStatus.PropertyType.FullName == typeof(bool?).FullName)
            {
                q = "UPDATE " + ta.Name + " SET Status=0, Updated={0} WHERE ";
                Params.Add(DateTime.Now);
            }
            else
            {
                q = "DELETE " + ta.Name + " WHERE ";
            }

            PropertyInfo[] pis        = t.GetProperties();
            bool           FirstWhere = true;

            foreach (PropertyInfo pi in pis)
            {
                oo = pi.GetCustomAttributes(typeof(ColumnAttribute), true);
                if (oo == null || oo.Length < 1)
                {
                    continue;
                }
                ColumnAttribute ca = (ColumnAttribute)oo[0];
                if (!ca.IsPrimaryKey)
                {
                    continue;
                }

                object v;
                if (pi.Name == "InstanceId")
                {
                    v = LinqMicajahDataContext.InstanceId;
                }
                else
                {
                    v = pi.GetValue(this, null);
                }
                Params.Add(v);
                q += (FirstWhere ? "" : " AND ") + ca.Name + "={" + (Params.Count - 1) + "} ";

                FirstWhere = false;
            }

            dc.ExecuteCommand(q, Params.ToArray());
        }
Beispiel #18
0
 /// <summary>
 /// Update service
 /// </summary>
 /// <param name="model">DataModel</param>
 /// <returns>1: Successful, 0: Failed</returns>
 public async Task <int> UpdateService(DataModel model)
 {
     // Update service information
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_UPDATE_SERVICE(model.ServiceID, model.ServiceName, model.TypeID)));
     }
 }
Beispiel #19
0
 /// <summary>
 /// Add new speciality
 /// </summary>
 /// <param name="model">DataModel</param>
 /// <returns>1: Successful, 0: Failed</returns>
 public async Task <int> AddSpeciality(DataModel model)
 {
     // Insert new service to database
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_INSERT_SPECIALITY(model.SpecialityName)));
     }
 }
Beispiel #20
0
 /// <summary>
 /// Update speciality
 /// </summary>
 /// <param name="model">DataModel</param>
 /// <returns>1: Successful, 0: Failed</returns>
 public async Task <int> UpdateSpeciality(DataModel model)
 {
     // Update service information
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_UPDATE_SPECIALITY(model.SpecialityID, model.SpecialityName)));
     }
 }
Beispiel #21
0
 /// <summary>
 /// Add new facility
 /// </summary>
 /// <param name="model">DataModel</param>
 /// <returns>1: Successful, 0: Failed</returns>
 public async Task <int> AddFacility(DataModel model)
 {
     // Insert new service to database
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_INSERT_FACILITY(model.FacilityName, model.TypeID)));
     }
 }
Beispiel #22
0
 /// <summary>
 /// Add new service
 /// </summary>
 /// <param name="model">DataModel</param>
 /// <returns>1: Successful, 0: Failed</returns>
 public async Task <int> AddService(DataModel model)
 {
     // Insert new service to database
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_INSERT_SERVICE(model.ServiceName, model.TypeID)));
     }
 }
Beispiel #23
0
 /// <summary>
 /// Update facility
 /// </summary>
 /// <param name="model">DataModel</param>
 /// <returns>1: Successful, 0: Failed</returns>
 public async Task <int> UpdateFacility(DataModel model)
 {
     // Update service information
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_UPDATE_FACILITY(model.FacilityID, model.FacilityName, model.TypeID)));
     }
 }
Beispiel #24
0
 /// <summary>
 /// Load list of speciality base on input conditions
 /// </summary>
 /// <param name="specialityName">Speciality name</param>
 /// <param name="isActive">Status</param>
 /// <returns></returns>
 public async Task <List <SP_TAKE_SPECIALITY_AND_TYPEResult> > LoadListOfSpeciality(
     string specialityName, bool isActive)
 {
     // Search for suitable hospitals in database
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_TAKE_SPECIALITY_AND_TYPE(specialityName, isActive).ToList()));
     }
 }
Beispiel #25
0
 public static Photo LoadPhotoByPhotoID(int photoID)
 {
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return((
                    from p in data.Photos
                    where p.Photo_ID == photoID
                    select p).FirstOrDefault());
     }
 }
 /// <summary>
 /// Load facility type in database
 /// </summary>
 /// <returns>List[FacilityType] that contains a list of services</returns>
 public static async Task <List <FacilityType> > LoadFacilityTypeAsync()
 {
     // Return list of dictionary words
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               (from f in data.FacilityTypes
                                select f).ToList()));
     }
 }
Beispiel #27
0
 /// <summary>
 /// Load list of disease base on input conditions
 /// </summary>
 /// <param name="diseaseName">Disease name</param>
 /// <param name="isActive">Status</param>
 /// <param name="mode">Mode</param>
 /// <param name="specialityID">Speciality ID</param>
 /// <returns></returns>
 public async Task <List <SP_TAKE_DISEASE_AND_TYPEResult> > LoadListOfDisease(
     string diseaseName, bool isActive, int mode, int specialityID)
 {
     // Search for suitable hospitals in database
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_TAKE_DISEASE_AND_TYPE(diseaseName, isActive, mode, specialityID).ToList()));
     }
 }
Beispiel #28
0
 /// <summary>
 /// Load list of service base on input conditions
 /// </summary>
 /// <param name="serviceName">Service name</param>
 /// <param name="serviceType">Service type</param>
 /// <param name="isActive">Status</param>
 /// <returns></returns>
 public async Task <List <SP_TAKE_SERVICE_AND_TYPEResult> > LoadListOfService(
     string serviceName, int serviceType, bool isActive)
 {
     // Search for suitable hospitals in database
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_TAKE_SERVICE_AND_TYPE(serviceName, serviceType, isActive).ToList()));
     }
 }
Beispiel #29
0
 /// <summary>
 /// Load list of facility base on input conditions
 /// </summary>
 /// <param name="facilityName">Facility name</param>
 /// <param name="facilityType">Facility type</param>
 /// <param name="isActive">Status</param>
 /// <returns></returns>
 public async Task <List <SP_TAKE_FACILITY_AND_TYPEResult> > LoadListOfFacility(
     string facilityName, int facilityType, bool isActive)
 {
     // Search for suitable hospitals in database
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               data.SP_TAKE_FACILITY_AND_TYPE(facilityName, facilityType, isActive).ToList()));
     }
 }
Beispiel #30
0
        public static bool StoreSearchQuery(string searchQuery, int resultCount)
        {
            int check = -1;

            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                check = data.SP_INSERT_SEARCH_QUERY(searchQuery, resultCount, DateTime.Now);
            }
            return(check >= 0);
        }
 /// <summary>
 /// Load service type in database
 /// </summary>
 /// <returns>List[ServiceType] that contains a list of services</returns>
 public static async Task <List <ServiceType> > LoadServiceTypeAsync()
 {
     // Return list of dictionary words
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         return(await Task.Run(() =>
                               (from s in data.ServiceTypes
                                select s).ToList()));
     }
 }
        public int SetInvitacion()
        {
            LinqDBDataContext db = new LinqDBDataContext();
            int resp;
            try
            {
                resp = db.SendInvitacion(rutContacto, rutCliente, cantidad);
            }
            catch
            {
                resp = -1;

            }

            return resp;
        }
Beispiel #33
0
        public void getMenu(DateTime fecha, bool horario)
        {
            this.fecha = fecha;
            this.horario = horario;
            ListaMenu = new List<SelectListItem>();

            LinqDBDataContext db = new LinqDBDataContext();

            var menu = (from item in db.ITEM
                        from menu_fecha in db.MENU_FECHA
                        from tipo_item in db.TIPO_ITEM
                        where
                            menu_fecha.FECHA == fecha &&
                            menu_fecha.HORARIO == horario &&
                            item.CODIGO_ITEM == menu_fecha.CODIGO_ITEM &&
                            tipo_item.CODIGO_TIPO_ITEM == item.CODIGO_TIPO_ITEM
                        select new
                        {
                            tipo_item.NOMBRE_TIPO_ITEM,
                            item.NOMBRE_ITEM,
                            item.CODIGO_ITEM,
                            menu_fecha.MENU_ITEM_CANTIDAD
                        }
                        );

            foreach (var item in menu)
            {
                SelectListItem sli = new SelectListItem();
                sli.Text = item.NOMBRE_ITEM;
                sli.Value = item.CODIGO_ITEM.ToString();
                ListaMenu.Add(sli);
                cantidades.Add(item.MENU_ITEM_CANTIDAD.Value);

            }
        }
Beispiel #34
0
 public int setMenu(Int32 item, Int16 cantidad, DateTime fecha, Boolean horario)
 {
     LinqDBDataContext db = new LinqDBDataContext();
     int resp;
     try
     {
         resp = (Int32)db.AddItemMenu(item, cantidad, fecha, horario);
     }
     catch
     {
         resp = -1;
     }
     return resp;
 }
Beispiel #35
0
        public void getPedido()
        {
            ListaPedido = new List<ItemPedido>();

            LinqDBDataContext db = new LinqDBDataContext();

            var det_pedido = (from item in db.ITEM
                        from pedido in db.DETALLE_PEDIDO
                        from tipo_item in db.TIPO_ITEM
                        where
                            pedido.CODIGO_PEDIDO == this.id_pedido &&
                            item.CODIGO_ITEM == pedido.CODIGO_ITEM &&
                            tipo_item.CODIGO_TIPO_ITEM == item.CODIGO_TIPO_ITEM
                        select new
                        {
                            tipo_item.NOMBRE_TIPO_ITEM,
                            item.NOMBRE_ITEM,
                            item.CODIGO_ITEM,
                            pedido.DETALLE_ITEM_CANTIDAD,
                            pedido.DETALLE_ITEM_OBSERVACION
                        }
                        );

            foreach (var item in det_pedido)
            {
                ItemPedido itp = new ItemPedido();
                itp.nom_item = item.NOMBRE_ITEM;
                itp.cod_item = (Int16)item.CODIGO_ITEM;
                itp.cantidad = (Int16)item.DETALLE_ITEM_CANTIDAD;
                itp.observacion = item.DETALLE_ITEM_OBSERVACION;
                ListaPedido.Add(itp);
            }
        }
Beispiel #36
0
 public void RegistrarMesa()
 {
     LinqDBDataContext db = new LinqDBDataContext();
     MESA m1 = new MESA { POS_X = pos_x, POS_Y = pos_y, CANT_MAXIMA = (short)cant_maxima};
     db.MESA.InsertOnSubmit(m1);
     db.SubmitChanges();
 }
Beispiel #37
0
        public void SetReserva(Int32 mesa, String rut, DateTime fecha, Boolean horario, Int16 comensales)
        {
            this.mesa = mesa;
            this.rut = rut;
            this.fecha = fecha;
            this.horario = horario;
            this.comensales = comensales;

            LinqDBDataContext db = new LinqDBDataContext();

            RESERVA iRESERVA = new RESERVA
            {
                CODIGO_MESA = mesa,
                RUT_CLI = rut,
                FECHA = fecha,
                HORARIO = horario,
                NUMERO_COMENSALES = comensales
            };
            db.RESERVA.InsertOnSubmit(iRESERVA);
            db.SubmitChanges();
        }
Beispiel #38
0
        public void getListas()
        {
            ListaEntrada = new List<SelectListItem>();
            ListaFondo = new List<SelectListItem>();
            ListaPostre = new List<SelectListItem>();

            LinqDBDataContext db = new LinqDBDataContext();

            var menu = (from item in db.ITEM
                        from tipo_item in db.TIPO_ITEM
                        where
                            tipo_item.CODIGO_TIPO_ITEM == item.CODIGO_TIPO_ITEM
                        select new
                        {
                            tipo_item.NOMBRE_TIPO_ITEM,
                            item.NOMBRE_ITEM,
                            item.CODIGO_ITEM
                        }
                        );

            foreach (var item in menu)
            {
                SelectListItem sli = new SelectListItem();
                sli.Text = item.NOMBRE_ITEM;
                sli.Value = item.CODIGO_ITEM.ToString();
                if (item.NOMBRE_TIPO_ITEM.Equals("Entrada"))
                {
                    ListaEntrada.Add(sli);
                }
                else if (item.NOMBRE_TIPO_ITEM.Equals("Plato de Fondo"))
                {
                    ListaFondo.Add(sli);
                }
                else if (item.NOMBRE_TIPO_ITEM.Equals("Postre"))
                {
                    ListaPostre.Add(sli);
                }
            }
        }
Beispiel #39
0
        public void setItem(Int32 tipo_item, String nombre_item, String descripcion)
        {
            LinqDBDataContext db = new LinqDBDataContext();
            ITEM iITEM = new ITEM
            {
                CODIGO_TIPO_ITEM = tipo_item,
                NOMBRE_ITEM = nombre_item,
                DESCRIPCION_ITEM = descripcion

            };
            db.ITEM.InsertOnSubmit(iITEM);
            db.SubmitChanges();
        }
        public ActionResult HacerReserva(MesasModel modelo)
        {
            string date = Request.Form["__DATE"];
            string operacion = Request.Form["op"];
            MesasModel _modelo = new MesasModel();

            DateTime fecha = DateTime.Now.Date;

            if (fecha.DayOfWeek == DayOfWeek.Saturday)
                fecha = DateTime.Now.AddDays(2).Date;
            else if (fecha.DayOfWeek == DayOfWeek.Sunday)
                fecha = DateTime.Now.AddDays(1).Date;

            if (date != null)
            {
                if (operacion == "mk")
                {
                    // IDENTIFICAR SI LA FECHA ACTUAL ES POR LO MENOS 2 DÍAS ANTES DE LA RESERVA
                    if (DateTime.Now.Date < DateTime.Parse(date).AddDays(-1).Date)
                    {
                        Int16 mesa_id = Int16.Parse(Request.Form["id_mesa"]);
                        short num_comen = Int16.Parse(Request.Form["num_comen"]);
                        string rut = User.Identity.Name;
                        bool horario = modelo.horario;
                        string obs = Request.Form["obs"];

                        // Intentando agregar a DB
                        LinqDBDataContext db = new LinqDBDataContext();

                        int respuesta = (Int32)db.MK_RESERVA(rut,
                                                            mesa_id,
                                                            DateTime.Parse(date),
                                                            horario,
                                                            num_comen,
                                                            obs).ReturnValue;
                        if (respuesta == 2)
                            ViewBag.RESP = "No puede reservar dos veces para el mismo momento";
                        else if (respuesta == 1)
                            ViewBag.RESP = "La reserva se ha realizado con éxito";
                        else if (respuesta == 0)
                            ViewBag.RESP = "Ya existe una reserva hecha en dicha mesa";
                        else if (respuesta == -1)
                        {
                            ViewBag.RESP = "No tienes invitaciones para realizar una reserva";
                        }
                        else
                        {
                            ViewBag.RESP = "Ha ocurrido un error desconocido :(";
                        }
                    }
                    else
                    {
                        ViewBag.RESP = "Debe reservar por lo menos dos días antes de la fecha que desea reservar";
                    }
                }

                _modelo.getMesasReserva(DateTime.Parse(date), modelo.horario);//DateTime.Parse(date)
                ViewBag.Fecha = _modelo.fecha.ToString("dd-MM-yyy");
            }

            return View(_modelo);
        }
        public ActionResult TomarPedido(PedidoModel modelo, string id_reserva, string rut_garzon, string btn_submit)
        {
            DateTime fecha = DateTime.Parse(Request.Form["__DATE"]);
            bool horario = Boolean.Parse(Request.Form["__HORARIO"]);

            PedidoModel _modelo = new PedidoModel();
            if (btn_submit == null)
            {
                string user_rut = User.Identity.Name.ToString();
                if (!String.IsNullOrEmpty(rut_garzon) && !rut_garzon.Equals(user_rut))
                {
                    TempData.Add("Error", "_"+user_rut+"_"+rut_garzon+"_");
                    return RedirectToAction("ConsultarReserva", "Garzon");
                }
                else
                {
                    LinqDBDataContext db = new LinqDBDataContext();
                    int respuesta = (Int32)db.CrearPedido(Int16.Parse(id_reserva), user_rut);

                    if (respuesta <= 0)
                    {
                        TempData.Add("Error", "Ha habido un error inesperado");
                        return RedirectToAction("ConsultarReserva", "Garzon");
                    }
                    else if (respuesta > 0)
                    {
                        _modelo = new PedidoModel();
                        _modelo.id_pedido = (Int16)respuesta;
                    }
                }
                ModelState.Clear();
            }
            else
            {
                _modelo.id_pedido = Int16.Parse(Request.Form["id_pedido"]);
                if (ModelState.IsValid)
                {
                    int resp = _modelo.setPedido(Int16.Parse(modelo.selected_item), Int16.Parse(modelo.selected_cant), modelo.observacion);

                    if (resp == 2)
                    {
                        TempData.Add("Resp", "El Pedido se ha actualizado");
                    }
                    else if (resp == 1)
                    {
                        TempData.Add("Resp", "Se ha agregado el ítem");
                    }
                    else if (resp == -1)
                    {
                        TempData.Add("Resp", "Ha ocurrido un error inesperado");
                    }

                    ModelState.Clear();
                }

            }

            ViewBag.Fecha = fecha.ToString("dd-MM-yyy");
            _modelo.getListas(fecha,horario);
            _modelo.getPedido();

            return View(_modelo);
        }
Beispiel #42
0
        public void DeleteReserva(Int32 codigo_reserva)
        {
            LinqDBDataContext db = new LinqDBDataContext();

            var eliminaRESERVA = (
                                from reserva in db.RESERVA
                                where
                                    reserva.CODIGO_RESERVA == codigo_reserva
                                select reserva);
            foreach (var del in eliminaRESERVA)
            {
                db.RESERVA.DeleteOnSubmit(del);
            }
            db.SubmitChanges();
        }
Beispiel #43
0
        public void getMesas()
        {
            lista_mesas = new List<Mesa>();
            LinqDBDataContext db = new LinqDBDataContext();
            var mesas = (from mesa in db.MESA
                        select new
                        {
                            mesa.CODIGO_MESA,
                            mesa.POS_X,
                            mesa.POS_Y,
                            mesa.CANT_MAXIMA
                        }
                        );

            foreach (var una_mesa in mesas)
            {
                Mesa _mesa = new Mesa();
                _mesa.id_mesa = una_mesa.CODIGO_MESA;
                _mesa.pos_x = una_mesa.POS_X.Value;
                _mesa.pos_y = una_mesa.POS_Y.Value;
                _mesa.cant_maxima = una_mesa.CANT_MAXIMA.Value;
                lista_mesas.Add(_mesa);
            }
        }
Beispiel #44
0
        public void getMesasGarzon(DateTime fecha, bool horario)
        {
            this.fecha = fecha;
            lista_mesas = new List<Mesa>();
            LinqDBDataContext db = new LinqDBDataContext();
            var lines = db.MesasPedidoInfo(fecha,horario);

            foreach (var una_mesa in lines)
            {
                Mesa _mesa = new Mesa();
                _mesa.id_reserva = una_mesa.CODIGO_RESERVA.HasValue ? una_mesa.CODIGO_RESERVA.Value : 0;
                _mesa.id_mesa = una_mesa.CODIGO_MESA;
                _mesa.pos_x = una_mesa.POS_X.Value;
                _mesa.pos_y = una_mesa.POS_Y.Value;
                _mesa.cant_maxima = una_mesa.CANT_MAXIMA.Value;
                _mesa.observacion = una_mesa.OBSERVACIONES;
                _mesa.num_comensales = una_mesa.NUMERO_COMENSALES.HasValue ? una_mesa.NUMERO_COMENSALES.Value : 0;
                _mesa.estado = una_mesa.ESTADO_PEDIDO.HasValue ? una_mesa.ESTADO_PEDIDO.Value : -1;
                _mesa.nombre_cliente = String.IsNullOrEmpty(una_mesa.CLIENTE) ? "" : una_mesa.CLIENTE;
                _mesa.nombre_garzon = String.IsNullOrEmpty(una_mesa.GARZON) ? "" : una_mesa.GARZON;
                _mesa.rut_garzon = String.IsNullOrEmpty(una_mesa.RUT_GARZON) ? "" : una_mesa.RUT_GARZON;
                lista_mesas.Add(_mesa);
            }
        }
Beispiel #45
0
 /* 0 = Hoteleria;
  * 1 = Gastronomía;
  * 2 = Funcionario;
  * 3 = Administrador;
  */
 public void Registro(int tipo)
 {
     string nombre = this.Nombre + " " + this.ApellidoPaterno + " " + this.ApellidoMaterno;
     LinqDBDataContext db = new LinqDBDataContext();
     if (tipo == 0)
     {
         CONTACTO C = new CONTACTO { RUT_CONTACTO = this.UserName, NOMBRE_CONTACTO = nombre, SEXO_CONTACTO = this.Sexo, CODIGO_CARRERA = 1, CORREO_CONTACTO = this.Email, FONO_CONTACTO = Convert.ToInt32(this.Telefono), CANT_TICKETS = 30};
         db.CONTACTO.InsertOnSubmit(C);
         db.SubmitChanges();
     }
     else if (tipo == 1)
     {
         CONTACTO C = new CONTACTO { RUT_CONTACTO = this.UserName, NOMBRE_CONTACTO = nombre, SEXO_CONTACTO = this.Sexo, CODIGO_CARRERA = 2, CORREO_CONTACTO = this.Email, FONO_CONTACTO = Convert.ToInt32(this.Telefono), CANT_TICKETS = 30 };
         db.CONTACTO.InsertOnSubmit(C);
         db.SubmitChanges();
     }
     else if (tipo == 2)
     {
         CONTACTO C = new CONTACTO { RUT_CONTACTO = this.UserName, NOMBRE_CONTACTO = nombre, SEXO_CONTACTO = this.Sexo, CORREO_CONTACTO = this.Email, FONO_CONTACTO = Convert.ToInt32(this.Telefono), CANT_TICKETS = 30 };
         db.CONTACTO.InsertOnSubmit(C);
         db.SubmitChanges();
     }
     else if (tipo == 3)
     {
         // Debería ingresar un administrador al sistema, pero esto solamente serviría para almacenar información de contacto
     }
     else
     {
         // Si no es ni 0, 1, 2, 3 Fail!
     }
 }
Beispiel #46
0
        public void GetItems(DateTime fecha, bool horario)
        {
            this.fecha = fecha;
            ListaEntrada = new List<string>();
            ListaFondo = new List<string>();
            ListaPostre = new List<string>();
            ListaBebestible = new List<string>();

            LinqDBDataContext db = new LinqDBDataContext();

            var menu = (from item in db.ITEM
                        from menu_fecha in db.MENU_FECHA
                        from tipo_item in db.TIPO_ITEM
                        where
                            menu_fecha.FECHA == fecha &&
                            menu_fecha.HORARIO == horario &&
                            item.CODIGO_ITEM == menu_fecha.CODIGO_ITEM &&
                            tipo_item.CODIGO_TIPO_ITEM == item.CODIGO_TIPO_ITEM
                        select new
                        {
                            tipo_item.NOMBRE_TIPO_ITEM,
                            item.NOMBRE_ITEM
                        }
                        ).Union((
                        from item in db.ITEM
                        from tipo_item in db.TIPO_ITEM
                        where
                            tipo_item.CODIGO_TIPO_ITEM == 4 &&
                            item.CODIGO_TIPO_ITEM == 4

                        select new
                        {
                            tipo_item.NOMBRE_TIPO_ITEM,
                            item.NOMBRE_ITEM
                        }
                        )
                        );

            foreach (var item in menu)
            {
                if (item.NOMBRE_TIPO_ITEM.Equals("Entrada"))
                {
                    ListaEntrada.Add(item.NOMBRE_ITEM);
                }
                else if (item.NOMBRE_TIPO_ITEM.Equals("Plato de Fondo"))
                {
                    ListaFondo.Add(item.NOMBRE_ITEM);
                }
                else if (item.NOMBRE_TIPO_ITEM.Equals("Postre"))
                {
                    ListaPostre.Add(item.NOMBRE_ITEM);
                }
                else if (item.NOMBRE_TIPO_ITEM.Equals("Bebestible"))
                {
                    ListaBebestible.Add(item.NOMBRE_ITEM);
                }
            }
        }
Beispiel #47
0
        public void UpdateMesa(int pos_x, int pos_y)
        {
            this.pos_x = pos_x;
            this.pos_y = pos_y;

            LinqDBDataContext db = new LinqDBDataContext();
            var mesa = (from m in db.MESA
                        where m.CODIGO_MESA == this.id_mesa
                        select m).Single();
            mesa.POS_X = pos_x;
            mesa.POS_Y = pos_y;
            db.SubmitChanges();
        }
Beispiel #48
0
        public void getListas(DateTime fecha, bool horario)
        {
            this.fecha = fecha;
            this.horario = horario;
            ListaEntrada = new List<SelectListItem>();
            ListaFondo = new List<SelectListItem>();
            ListaPostre = new List<SelectListItem>();
            ListaBebestible = new List<SelectListItem>();

            LinqDBDataContext db = new LinqDBDataContext();

            var menu = (from menu_ in db.MENU_FECHA
                        from tipo_item in db.TIPO_ITEM
                        from item in db.ITEM
                        where
                            tipo_item.CODIGO_TIPO_ITEM == item.CODIGO_TIPO_ITEM &&
                            item.CODIGO_ITEM == menu_.CODIGO_ITEM &&
                            menu_.FECHA == fecha &&
                            menu_.HORARIO == horario
                        select new
                        {
                            tipo_item.NOMBRE_TIPO_ITEM,
                            item.NOMBRE_ITEM,
                            item.CODIGO_ITEM
                        }).Union((
                        from item in db.ITEM
                        from tipo_item in db.TIPO_ITEM
                        where
                            tipo_item.CODIGO_TIPO_ITEM == 4 &&
                            item.CODIGO_TIPO_ITEM == 4

                        select new
                        {
                            tipo_item.NOMBRE_TIPO_ITEM,
                            item.NOMBRE_ITEM,
                            item.CODIGO_ITEM
                        }
                        )
                        );

            foreach (var item in menu)
            {
                SelectListItem sli = new SelectListItem();
                sli.Text = item.NOMBRE_ITEM;
                sli.Value = item.CODIGO_ITEM.ToString();
                if (item.NOMBRE_TIPO_ITEM.Equals("Entrada"))
                {
                    ListaEntrada.Add(sli);
                }
                else if (item.NOMBRE_TIPO_ITEM.Equals("Plato de Fondo"))
                {
                    ListaFondo.Add(sli);
                }
                else if (item.NOMBRE_TIPO_ITEM.Equals("Postre"))
                {
                    ListaPostre.Add(sli);
                }
                else if (item.NOMBRE_TIPO_ITEM.Equals("Bebestible"))
                {
                    ListaBebestible.Add(sli);
                }
            }
        }
Beispiel #49
0
        public void getMesasCocinero(DateTime fecha, bool horario)
        {
            this.fecha = fecha;
            lista_mesas = new List<Mesa>();

            LinqDBDataContext db = new LinqDBDataContext();
            var lines = (
                        from vista in db.VW_PEDIDOS
                        select new
                        {
                            id_reserva = vista.CODIGO_RESERVA == null ? 0 : vista.CODIGO_RESERVA,
                            vista.CODIGO_MESA,
                            id_pedido = vista.CODIGO_PEDIDO == null ? 0 : vista.CODIGO_PEDIDO,
                            estado = vista.ESTADO_PEDIDO == null ? -1 : vista.ESTADO_PEDIDO,
                            garzon = vista.GARZON == null ? "" : vista.GARZON,
                            num_com = vista.NUMERO_COMENSALES == null ? 0 : vista.NUMERO_COMENSALES,
                            nom_item = vista.NOMBRE_ITEM == null ? "" : vista.NOMBRE_ITEM,
                            obs = vista.DETALLE_ITEM_OBSERVACION == null ? "" : vista.DETALLE_ITEM_OBSERVACION,
                            cant = vista.DETALLE_ITEM_CANTIDAD == null ? 0 : vista.DETALLE_ITEM_CANTIDAD
                        });
            foreach (var row in lines)
            {
                Int16 id_mesa = (short) row.CODIGO_MESA;
                Mesa mesa_ = null;
                int j = -1;
                for (int i = 0; i < lista_mesas.Count; i++)
                {
                    if (lista_mesas[i].id_mesa == id_mesa)
                    {
                        j = i;
                        break;
                    }
                }

                ItemPedido item_ = new ItemPedido();
                item_.nom_item = row.nom_item;
                item_.observacion = row.obs;
                item_.cantidad = (short)row.cant;

                if (j == -1)
                {
                    mesa_ = new Mesa();
                    mesa_.id_mesa = id_mesa;
                    mesa_.id_reserva = (short)row.id_reserva;
                    mesa_.estado = (short)row.estado;
                    mesa_.nombre_garzon = row.garzon;
                    mesa_.num_comensales = (short)row.num_com;
                    mesa_.lista_pedido.Add(item_);

                    lista_mesas.Add(mesa_);
                }
                else
                {
                    lista_mesas[j].lista_pedido.Add(item_);
                }
            }
        }
Beispiel #50
0
        // Actualiza el estado del pedido a 1 -> "Preparado"
        public int PrepararPedido(short id_reserva)
        {
            LinqDBDataContext db = new LinqDBDataContext();

            // Query the database for the row to be updated.
            var query = (
                from p in db.PEDIDO
                where p.CODIGO_RESERVA == id_reserva
                select p);

            // Execute the query, and change the column values
            // you want to change.
            foreach (PEDIDO ped in query)
            {
                ped.ESTADO_PEDIDO = 1;
                // Insert any additional changes to column values.
            }

            // Submit the changes to the database.
            try
            {
                db.SubmitChanges();
                return 1;
            }
            catch (Exception e)
            {
                return -1;
                // Provide for exceptions.
            }
        }
Beispiel #51
0
        public void getMesasReserva(DateTime fecha, bool horario)
        {
            this.fecha = fecha;
            lista_mesas = new List<Mesa>();
            LinqDBDataContext db = new LinqDBDataContext();
            var lines = (
                        from m in db.MESA
                        from r in db.RESERVA.Where(r=>r.CODIGO_MESA == m.CODIGO_MESA &&
                            r.FECHA == fecha &&
                            r.HORARIO == horario)
                            .DefaultIfEmpty()
                        select new
                        {
                            id_reserva = r.CODIGO_RESERVA == null ? 0 : r.CODIGO_RESERVA,
                            m.CODIGO_MESA,
                            m.POS_X,
                            m.POS_Y,
                            m.CANT_MAXIMA
                        });

            foreach (var una_mesa in lines)
            {
                Mesa _mesa = new Mesa();
                _mesa.id_reserva = una_mesa.id_reserva;
                _mesa.id_mesa = una_mesa.CODIGO_MESA;
                _mesa.pos_x = una_mesa.POS_X.Value;
                _mesa.pos_y = una_mesa.POS_Y.Value;
                _mesa.cant_maxima = una_mesa.CANT_MAXIMA.Value;
                lista_mesas.Add(_mesa);
            }
        }
Beispiel #52
0
        public void RegistroCliente()
        {
            string nombre = this.Nombre + " " + this.ApellidoPaterno + " " + this.ApellidoMaterno;
            LinqDBDataContext db = new LinqDBDataContext();
            CLIENTE c1 = new CLIENTE { RUT_CLI = this.UserName, NOMBRE_CLI = nombre, SEXO_CLIENTE = this.Sexo, CORREO_CLI = this.Email, TELEFONO_CLI = Convert.ToInt32(this.Telefono), TICKETS_RECIBIDOS = 0 };

            db.CLIENTE.InsertOnSubmit(c1);
            db.SubmitChanges();
        }
Beispiel #53
0
 public int setPedido(Int32 item, Int16 cantidad, string observacion)
 {
     LinqDBDataContext db = new LinqDBDataContext();
     int resp;
     try
     {
         resp = (Int32)db.AddItemPedido(item, cantidad, this.id_pedido, observacion);
     }
     catch
     {
         resp = -1;
     }
     return resp;
 }
Beispiel #54
0
        public ActionResult AgregarMenu(AgregarMenuModel modelo, string btn_submit)
        {
            string date = Request.Form["__DATE"];
            bool _horario = false;
            if (modelo != null)
            {
                if (Request.Form["__HORARIO"] != null)
                {
                    if (Request.Form["__HORARIO"] == "True")
                        _horario = true;
                    else if (Request.Form["__HORARIO"] == "False")
                        _horario = false;
                }
                else
                {
                    _horario = modelo.horario;
                }
            }

            AgregarMenuModel new_model = new AgregarMenuModel();

            DateTime fecha = DateTime.Now.Date;

            if (fecha.DayOfWeek == DayOfWeek.Saturday)
                fecha = DateTime.Now.AddDays(2).Date;
            else if (fecha.DayOfWeek == DayOfWeek.Sunday)
                fecha = DateTime.Now.AddDays(1).Date;

            ViewBag.Fecha = fecha.ToString("dd-MM-yy");

            ViewBag.Horario = false.ToString();

            if (date != null)
            {
                ViewBag.Fecha = DateTime.Parse(date).ToString("dd-MM-yy");
                ViewBag.Horario = _horario;

                if (btn_submit != null)
                {
                    if (ModelState.IsValid)
                    {
                        LinqDBDataContext db = new LinqDBDataContext();
                        db.CrearFecha(DateTime.Parse(date), _horario);
                        int resp = new_model.setMenu(Int16.Parse(modelo.selected_item), short.Parse(modelo.selected_cant), DateTime.Parse(date), _horario);

                        if (resp == 2)
                        {
                            TempData.Add("Resp", "El Menu se ha actualizado");
                        }
                        else if (resp == 1)
                        {
                            TempData.Add("Resp", "Se ha agregado el ítem");
                        }
                        else if (resp == -1)
                        {
                            TempData.Add("Resp", "Ha ocurrido un error inesperado");
                        }

                        ModelState.Clear();
                    }
                }
                else
                {
                    ModelState.Clear();

                }
            }
            new_model.getListas();//DateTime.Parse(date)
            new_model.getMenu(DateTime.Parse(date), _horario);

            return View(new_model);
        }