Esempio n. 1
0
        public dynamic GetProblemsCountForAPeriod(string id, string selection)
        {
            dynamic MyLabels = GetLabels(selection);

            int.TryParse(id, out int hotelid);
            DataSet ds = Incedent.GetProblemsFromDateRange(hotelid, MyLabels.Start, MyLabels.End);
            Dictionary <string, int> dictMappedDateAndProblems = new Dictionary <string, int>();

            foreach (string label in MyLabels.Labels)
            {
                if (!String.IsNullOrEmpty(label))
                {
                    int count           = ds.Tables[0].AsEnumerable().Where(x => x.Field <DateTime>("date").ToString(MyLabels.LabelFormat) == label).Select(x => x.Field <int>("count")).Count();
                    int numberToBeAdded = count == 0 ? 0 : ds.Tables[0].AsEnumerable().Where(x => x.Field <DateTime>("date").ToString(MyLabels.LabelFormat) == label).Select(x => x.Field <int>("count")).First();
                    dictMappedDateAndProblems.Add(label, numberToBeAdded);

                    //int? count = ds.Tables[0].AsEnumerable().Where(x => DateTime.Parse(x["date"].ToString()).ToString(MyLabels.LabelFormat) == label).Select(x => x.Field<int>("count")).First();
                    //dictMappedDateAndProblems[label] = count!=null?int.Parse(count.ToString()):0;
                    //dicBad[label] = ds.Tables[0].AsEnumerable().Where(x => DateTime.Parse(x["ReviewTime"].ToString()).ToString(MyLabels.LabelFormat) == label && int.Parse(x["Rating"].ToString()) <= 3).Count();
                }

                //dicGood[label] = (from row in ds.Tables[0].AsEnumerable()
                //where DateTime.Parse(row["ReviewTime"].ToString()).ToString(LabelFormat) == label
                //select row).Count();
            }
            return(new ChartData()
            {
                Labels = dictMappedDateAndProblems.Keys.ToArray(),
                Data = dictMappedDateAndProblems.Values.ToArray()
            });
        }
        private void InsertIntoDatabase()
        {
            int           feedbackValue = 0;
            int           result        = 0;
            IncedentTypes incedent      = GetIncedentType();

            if (incedent != IncedentTypes.none)
            {
                feedbackValue = GetFeedbackValue(incedent);
                if (feedbackValue != 0)
                {
                    LoadIncedentFromHiddenFields(incedent, feedbackValue);
                    result = Incedent.ReportProblem(problem);
                    if (result > 0)
                    {
                        PnlSuccessFailure.Visible  = true;
                        PnlSuccessFailure.CssClass = "notification alert-success spacer-t10";
                        LblStatus.Text             = "Your Problem has been recorded!";
                    }
                    else
                    {
                        PnlSuccessFailure.Visible  = true;
                        PnlSuccessFailure.CssClass = "notification alert-error spacer-t10";
                        LblStatus.Text             = "Something went wrong. Please try again!";
                    }
                }
                else
                {
                    PnlSuccessFailure.Visible  = true;
                    PnlSuccessFailure.CssClass = "notification alert-warning spacer-t10";
                    LblStatus.Text             = "Please select an option!";
                }
            }
        }
 private void LoadIncedentFromHiddenFields(IncedentTypes incedent, int feedbackValue)
 {
     problem = new Incedent()
     {
         FeedbackValue = feedbackValue, IncedentType = Convert.ToInt32(incedent), HotelID = GetHotel(), UserID = GetUser(), IncedentDescription = additionalComments, IncedentTime = DateTime.Now, RoomNo = GetRoomNo()
     };
 }
Esempio n. 4
0
 private void LoadIncedents()
 {
     if (logininfo != null)
     {
         RptIncedents.DataSource = Incedent.FetchProblems(logininfo.HotelId, 1);
         RptIncedents.DataBind();
     }
 }
Esempio n. 5
0
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     if (Incedent.UpdateProblem(GetIncedentFromUpdatedValues()) > 0)
     {
         ShowLabel("The Problem has been successfully updated!", "success");
     }
     else
     {
         ShowLabel("Something went wrong!", "error");
     }
 }
Esempio n. 6
0
        private Incedent GetIncedentFromUpdatedValues()
        {
            Incedent incedent = new Incedent()
            {
                IncedentIDNum       = int.Parse(LblIncedentId.Text),
                IncedentDescription = TxtDesc.Text,
                IncedentType        = int.Parse(DdlIncedentType.SelectedValue),
                FeedbackValue       = int.Parse(DdlFeedbackValue.SelectedValue),
                IsSolved            = int.Parse(DdlIsResolved.SelectedValue) == 1?true:false
            };

            return(incedent);
        }
Esempio n. 7
0
 public dynamic GetProblemsStarCounts(string id, string selection)
 {
     int.TryParse(id, out int hotelid);
     if (dictDaeTimeMapping.Keys.Contains(selection))
     {
         DateTime end   = dictDaeTimeMapping[selection][1];
         DateTime start = dictDaeTimeMapping[selection][0];
         return(Incedent.FetchPRoblemForReport(hotelid, start, end));
     }
     else
     {
         return(null);
     }
 }
Esempio n. 8
0
        private ChartData donutHelper(string id, string selection, string storedProc)
        {
            DateTime startdate = DateTime.Now;

            if (selection == "month")
            {
                startdate = DateTime.Now.AddMonths(-1);
            }
            int.TryParse(id, out int res);
            DataTable dt   = Incedent.GetProblemsCount(res, startdate, storedProc).Tables[0];
            ChartData data = new ChartData()
            {
                Colors = dt.AsEnumerable().Select((x) => x["color"].ToString()).ToArray(),
                Labels = dt.AsEnumerable().Select((x) => x["type"].ToString()).ToArray(),
                Data   = dt.AsEnumerable().Select((x) => int.Parse(x["count"].ToString())).ToArray()
            };

            return(data);
        }
Esempio n. 9
0
        private void SetFormValues()
        {
            List <object> result = Incedent.FetchProblemByIncedentAndHotelId(logininfo.HotelId, GetProblemId());

            if (result != null)
            {
                User     user     = (User)result[0];
                Incedent incedent = (Incedent)result[1];
                LblIncedentId.Text             = incedent.IncedentID;
                TxtDesc.Text                   = incedent.IncedentDescription;
                LblRoomNo.Text                 = incedent.RoomNo;
                LblTime.Text                   = incedent.IncedentTime.ToShortDateString();
                DdlIsResolved.SelectedValue    = incedent.IsSolved ? "1" : "0";
                DdlIncedentType.SelectedValue  = incedent.IncedentType.ToString();
                DdlFeedbackValue.SelectedValue = incedent.FeedbackValue.ToString();
                TxtEmail.Text                  = user.Email;
                TxtUname.Text                  = user.LastName;
                TxtPhone.Text                  = user.Phone;
            }
        }
Esempio n. 10
0
        private void LoadRecentCommentsAtBottom()
        {
            if (logininfo != null)
            {
                DataSet MainDs             = Incedent.FetchProblems(logininfo.HotelId, 10);
                DataSet CompleedProblemsDs = Incedent.FetchProblems(logininfo.HotelId, 0, 1);

                /*DataRow[] FirstCommentDR = MainDs.Tables[0].AsEnumerable().Take(5).ToArray();
                 * DataRow[] SecondCommentDR = MainDs.Tables[0].AsEnumerable().Skip(5).ToArray();
                 * DataTable cloneTable = MainDs.Tables[0].Clone();
                 * DataTable FirstCommentdt = Utilities.AddRowsToTable(cloneTable,FirstCommentDR);
                 * DataTable SecondCommentdt = Utilities.AddRowsToTable(cloneTable,SecondCommentDR);*/
                RptRecentComments.DataSource = MainDs;
                RptRecentComments.DataBind();
                RptRecentComments2.DataSource = MainDs;
                RptRecentComments2.DataBind();
                RptCompleted.DataSource = CompleedProblemsDs;
                RptCompleted.DataBind();
            }
        }
Esempio n. 11
0
        public List <Incedent> GetProblems(string id)
        {
            DataSet ds = null;

            if (int.TryParse(id, out int convertedId))
            {
                ds = Incedent.FetchProblems(convertedId);
            }
            List <Incedent> incedents = ds.Tables[0].AsEnumerable()
                                        .Select(x =>
                                                new Incedent()
            {
                RoomNo              = x["RoomNo"].ToString(),
                IncedentTime        = DateTime.Parse(x["IncedentTime"].ToString()),
                IncedentTypeStr     = x["Type"].ToString(),
                FeedbackStr         = x["Problem"].ToString(),
                IncedentDescription = x["IncedentDescription"].ToString(),
                IsSolved            = bool.Parse(x["IsResolved"].ToString()),
                IncedentID          = x["IncedentID"].ToString()
            }).ToList <Incedent>();

            //string result = JsonConvert.SerializeObject(DatatableToDictionary(ds, "Title"), Newtonsoft.Json.Formatting.Indented);
            return(incedents);
        }