/// <summary> /// Muestra el formulario para realizar responder la pregunta. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void PerformGenericAction(object sender, UbiquicityEventArg e) { int id = Convert.ToInt32(e.TheObject.ToString()); ItemCommentManager itemCommentManager = new ItemCommentManager(); ItemComment itemComment = itemCommentManager.Get(id); if (itemComment == null && itemCommentManager.HasErrors) { Alert.ShowUP("Error", itemCommentManager.ErrorDescription); } else { //Si existe la referencia, entonces a sido respondida if (itemComment.SentenceReference == null) { UCFormInquiry.CleanForm(); UCFormInquiry.FillForm(itemComment); SessionUtilHelper.KeepInSession(id.ToString(), Session); ScriptManager.RegisterStartupScript(upUCModalForm, upUCModalForm.GetType(), "openModalCreate", "$('#modalInquiry').modal('show');", true); upUCModalForm.Update(); } else { Alert.ShowUP("Respuesta", "Esta pregunta ya ha sido respondida; no hay acciones disponibles."); } } }
/// <summary> /// Ejecuta la valración /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void PerformRanking(object sender, EventArgs e) { try { int invoiceItemId = Convert.ToInt32(SessionUtilHelper.GetIdFromSession(Session)); TrackingManager trackingManager = new TrackingManager(); //TODO - AGREGAR CONTROL DE ERROR Tracking tracking = trackingManager.Get(invoiceItemId); tracking.Ranking = UCFormRanking.Ranking; tracking.Status = Tracking.StatusType.Valorado; bool success = trackingManager.Edit(tracking); if (!success && trackingManager.HasErrors) { ((front)Master).Alert.Show("Error", trackingManager.ErrorDescription); } else { LoadProductTracking(); } //} } catch (Exception exception) { ((front)Master).Alert.Show("Exception", exception.Message); } }
/// <summary> /// Se encarga de persistir los datos. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void PerformAnswer(object sender, EventArgs e) { try { //Una implementación no muy buena int id = Convert.ToInt32(SessionUtilHelper.GetIdFromSession(Session)); ItemCommentManager itemCommentManager = new ItemCommentManager(); ItemComment itemommentRef = itemCommentManager.Get(id); ItemComment itemComment = new ItemComment(); itemComment.Resource = itemommentRef.Resource; itemComment.SentenceReference = itemommentRef; UCFormInquiry.PopulateModel(itemComment); bool success = itemCommentManager.Save(itemComment); if (!success && itemCommentManager.HasErrors) { Alert.Show("Error", itemCommentManager.ErrorDescription); } else { LoadGridView(); } } catch (Exception exception) { Alert.Show("Excepción", exception.Message); } SessionUtilHelper.FlushId(Session); }
/// <summary> /// Ejecuta el pago contemplando los distintos métodos de pago. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void PerformCheckout(object sender, EventArgs e) { try { InvoiceManager invoiceManager = new InvoiceManager(); List <PaymentMethod> paymenMethods = new List <PaymentMethod>(); //Modelo la factura Invoice invoice = new Invoice(); invoice.User = SessionHelper.GetUser(); invoice.BillingAddress = GetBillingAddress(); invoice.CreditCard = GetCreditCard(); invoice.CreditNotes = GetCreditNotes(); invoice.InvoiceItems = GetInvoiceItems(); // Procesamiento del pago y creación de la facturación bool success = invoiceManager.ProcessPayment(invoice); if (!success && invoiceManager.HasErrors) { ((front)Master).Alert.Show("Error", invoiceManager.ErrorDescription); } else { SessionUtilHelper.KeepInSession(invoice.Id.ToString(), Session); Response.Redirect("/invoice_finish.aspx"); } } catch (Exception exception) { ((front)Master).Alert.Show("Exception", exception.Message); } }
protected void PerformDownload(object sender, EventArgs e) { try { int id = Convert.ToInt32(SessionUtilHelper.GetIdFromSession(Session)); InvoiceManager invoiceManager = new InvoiceManager(); string url = invoiceManager.DownloadInvoice(id); if (invoiceManager.HasErrors) { ((front)Master).Alert.Show("Error", invoiceManager.ErrorDescription); } else { HttpResponse res = HttpContext.Current.Response; res.Clear(); res.AppendHeader("content-disposition", "attachment; filename=PaymentReceipt.pdf"); res.ContentType = "application/octet-stream"; res.WriteFile(url); res.Flush(); res.End(); } } catch (Exception exception) { ((front)Master).Alert.Show("Exception", exception.Message); } }
/// <summary> /// Carga la encuesta de satisfacción. /// </summary> public void LoadPoll() { try { PollManager pollManager = new PollManager(); Poll poll = pollManager.GetInstantPoll(); SessionUtilHelper.KeepInSession(poll.Id.ToString(), Session); if (poll != null && poll.Questions.Count > 0) { txtPollTitle.InnerText = poll.Name; pollRepeater.DataSource = poll.Questions; pollRepeater.DataBind(); divPoll.Visible = true; } else { // No es prolijo porque se mezcla la parte visual con los datos, pero sirve divPoll.Visible = false; } } catch (Exception exception) { //TODO - aplicar contorl e errores //((front)Master).Alert.Show("Excepción", exception.Message); } }
public void PopulateModel(Poll poll) { poll.Name = nameInput.Value; poll.Description = descriptionInput.Value; poll.DueDate = String.IsNullOrEmpty(dueDateInput.Date)? DateTime.Now : Convert.ToDateTime(dueDateInput.Date); poll.Active = activeCheck.Checked; Poll.PollType type; Enum.TryParse <Poll.PollType>(pollRadioList.SelectedItem.Value, true, out type); poll.Type = type; //Es un manejo malo... pero se eliminan todas las preguntas de la lista porque //se recibe el listado actualizado de la sesión poll.Questions = new List <PollQuestion>(); //Es un chinito: si no se editaron, no se debe llenar la lista if (SessionUtilHelper.PollQuestionEdited()) { poll.Questions.AddRange(SessionUtilHelper.GetPollQuestions(Session)); } else { poll.Questions = null; } SessionUtilHelper.FlushPollQuestion(Session); }
/// <summary> /// Crea un comentario. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void PerformComment(object sender, EventArgs e) { try { int invoiceItemId = Convert.ToInt32(SessionUtilHelper.GetIdFromSession(Session)); ItemCommentSupportManager commentManager = new ItemCommentSupportManager(); InvoiceItemSupport invoiceItemSupport = new InvoiceItemSupport(); invoiceItemSupport.InvoiceItem.Id = invoiceItemId; ItemCommentSupport itemCommentSupport = new ItemCommentSupport(); itemCommentSupport.Sentence = commentInput.InnerText; itemCommentSupport.User = SessionHelper.GetUser(); itemCommentSupport.IsOperator = false; itemCommentSupport.Date = DateTime.Now; invoiceItemSupport.Comments.Add(itemCommentSupport); commentManager.Save(invoiceItemSupport); LoadCommentsSupport(invoiceItemId); } catch (Exception exception) { //TODO - agregar control de error //((front)Master).Alert.Show("Exception", exception.Message); } }
public void FillForm(Poll poll) { nameInput.Value = poll.Name; descriptionInput.Value = poll.Description; dueDateInput.Date = poll.DueDate.ToShortDateString(); dueDateInput.DefaultView = AjaxControlToolkit.CalendarDefaultView.Days; pollRadioList.SelectedIndex = (int)poll.Type; SessionUtilHelper.KeepPollQuestion(poll.Questions, Session); RefreshQuestionList(poll.Questions); activeCheck.Checked = poll.Active; }
/// <summary> /// Muestra en pantalla el mensaje; si los labels fueron asignados, se muestran los botones. /// </summary> /// <param name="title"></param> /// <param name="message"></param> /// <param name="button1Label"></param> /// <param name="button2Label"></param> public void Show(Map map) { SessionUtilHelper.KeepInSession(map.Id.ToString(), Session); LoadComments(map.Id); //super turbio: almaceno el id para saber, al momento de comentar, a qué producto le pertenece. btnComentar.CommandArgument = map.Id.ToString(); //this.message = map.Description; PopulateItemDetail(map); //Page.ClientScript.RegisterStartupScript(this.GetType(), "openModalItemShop", "window.onload = function() { $('#ucModalItemShop').modal('show'); }", true); ScriptManager.RegisterStartupScript(upItemShop, upItemShop.GetType(), "openModalItemShop", "$('#ucModalItemShop').modal('show');", true); upItemShop.Update(); }
/// <summary> /// Se encarga de guardar las respuestas en el sistema. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SubmitAnswer(object sender, EventArgs e) { try { PollAnswerManager pollAnswerManager = new PollAnswerManager(); List <PollAnswer> pollAnswers = new List <PollAnswer>(); foreach (RepeaterItem item in pollRepeater.Items) { PollAnswer pollAnswer = new PollAnswer(); pollAnswer.User = SessionHelper.GetUser(); pollAnswer.PollOption.Id = Convert.ToInt32(((RadioButtonList)item.FindControl("radioOptionList")).SelectedValue); pollAnswer.PollQuestion.Id = Convert.ToInt32(((HiddenField)item.FindControl("lblQuestion")).Value); //if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) pollAnswers.Add(pollAnswer); } bool success = pollAnswerManager.Save(pollAnswers); if (!success && pollAnswerManager.HasErrors) { //TODO - Aplicar control de errores //((front)Master).Alert.Show("Error", pollAnswerManager.ErrorDescription); } else { //Esconde el panel de las preguntas y muestra el resultado en el chart divPoll.Visible = false; divPollStatistics.Visible = true; int pollId = Convert.ToInt32(SessionUtilHelper.GetIdFromSession(Session)); Dictionary <string, ArrayList[]> statistics = pollAnswerManager.GetReportForPollAnswers(pollId); int i = 0; foreach (KeyValuePair <string, ArrayList[]> serie in statistics) { Chart1.Series.Add(new Series(serie.Key)); Chart1.Legends.Add(serie.Key); Array yValues = serie.Value[1].ToArray(typeof(int)); Array xLabels = (string[])serie.Value[0].ToArray(typeof(string)); Chart1.Series[i].Points.DataBindXY(xLabels, yValues); Chart1.Series[i].ChartType = SeriesChartType.Column; ++i; } } } catch (Exception exception) { //Aplicar control de errores // ((front)Master).Alert.Show("Excepción", exception.Message); } }
/// <summary> /// Elimina de la lista de las preguntas, aquella que se encuentra seleccionada. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteQuestion(object sender, EventArgs e) { if (pollQuestionList.SelectedItem == null) { return; } ListItem selectedQuestion = pollQuestionList.SelectedItem; PollQuestion pollQuestion = new PollQuestion(); pollQuestion.Question = selectedQuestion.Text; SessionUtilHelper.RemovePollQuestion(pollQuestion, Session); RefreshQuestionList(SessionUtilHelper.GetPollQuestions(Session)); }
protected void PerformClose(object sender, EventArgs e) { try { int invoiceItemId = Convert.ToInt32(SessionUtilHelper.GetIdFromSession(Session)); ItemCommentSupportManager commentManager = new ItemCommentSupportManager(); commentManager.CloseTopic(invoiceItemId); LoadCommentsSupport(invoiceItemId); } catch (Exception exception) { //TODO - agregar control de error //((front)Master).Alert.Show("Exception", exception.Message); } }
public void CleanForm(List <PollOption> pollOptions) { optionListInput.DataSource = pollOptions; optionListInput.DataTextField = "Option"; optionListInput.DataValueField = "Id"; optionListInput.DataBind(); SessionUtilHelper.FlushPollQuestion(Session); pollQuestionList.Items.Clear(); pollQuestionList.DataSource = null; pollQuestionList.DataBind(); nameInput.Value = ""; descriptionInput.Value = ""; dueDateInput.Date = ""; dueDateInput.DefaultView = AjaxControlToolkit.CalendarDefaultView.Days; pollRadioList.SelectedIndex = 1; activeCheck.Checked = false; }
/// <summary> /// Crea un comentario. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnComentar_Click(object sender, EventArgs e) { try { ItemCommentManager commentManager = new ItemCommentManager(); ItemComment itemComment = new ItemComment(); itemComment.Sentence = commentInput.InnerText; itemComment.User = (User)Session["SessionCreated"]; itemComment.Resource.Id = Convert.ToInt32(((Button)sender).CommandArgument); commentManager.Save(itemComment); LoadComments(Convert.ToInt32(SessionUtilHelper.GetIdFromSession(Session))); //upItemShop.Update(); } catch (Exception exception) { //TODO - agregar control de error //((front)Master).Alert.Show("Exception", exception.Message); } }
protected void AddQuestion(object sender, EventArgs e) { //Prgeunta vacía... if (String.IsNullOrEmpty(questionInput.Value)) { return; } List <PollOption> pollOptions = new List <PollOption>(); List <ListItem> selectedOptions = optionListInput.Items.Cast <ListItem>().Where(li => li.Selected).ToList(); //No se eligieron opciones if (selectedOptions.Count == 0) { return; } //Como es un elemento simple, no tiene sentido buscar el elemento en la base //puesto que todos los datos ya están disponibles. foreach (ListItem listItem in selectedOptions) { PollOption pollOption = new PollOption(); pollOption.Id = Convert.ToInt32(listItem.Value); pollOption.Option = listItem.Text; pollOptions.Add(pollOption); } PollQuestion pollQuestion = new PollQuestion(); pollQuestion.Question = questionInput.Value; pollQuestion.Options = pollOptions; SessionUtilHelper.KeepPollQuestion(pollQuestion, Session); RefreshQuestionList(SessionUtilHelper.GetPollQuestions(Session)); questionInput.Value = ""; optionListInput.ClearSelection(); }
/// <summary> /// Muestra el formulario para realizar responder la pregunta. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void PerformGenericAction(object sender, UbiquicityEventArg e) { try { int id = Convert.ToInt32(e.TheObject.ToString()); //UCFormInquiry.CleanForm(); //UCFormInquiry.FillForm(itemComment); SessionUtilHelper.KeepInSession(id.ToString(), Session); //ScriptManager.RegisterStartupScript(upUCModalForm, upUCModalForm.GetType(), "openModalCreate", "$('#modalInquiry').modal('show');", true); //upUCModalForm.Update(); //SessionUtilHelper.KeepInSession(e.CommandArgument.ToString(), Session); //Page.ClientScript.RegisterStartupScript(this.GetType(), "openModal", "window.onload = function() { $('#modalInvoiceItemSupport').modal('show'); }", true); UCModalInvoiceItemSupport.LoadCommentsSupport(id); ScriptManager.RegisterStartupScript(upUCModalInvoiceItemSupport, upUCModalInvoiceItemSupport.GetType(), "openModalCreate", "$('#modalInvoiceItemSupport').modal('show');", true); upUCModalInvoiceItemSupport.Update(); } catch (Exception exception) { Alert.Show("Excepción", exception.Message); } }
/// <summary> /// Atiende la ejecución de las acciones generadas según el estado del tracking. /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void PerformTrackingAction(object source, RepeaterCommandEventArgs e) { try { if (e.CommandName == PERFORM_CLAIM) { int invoiceItemId = Convert.ToInt32(e.CommandArgument); CreditNoteManager creditNoteManager = new CreditNoteManager(); bool success = creditNoteManager.ClaimCreditNote(invoiceItemId); if (!success && creditNoteManager.HasErrors) { ((front)Master).Alert.Show("Error", creditNoteManager.ErrorDescription); } else { LoadProductTracking(); ((front)Master).Alert.Show("Nota de crédito", "Se ha generado una nota de crédito, pendiente de aprobación"); } } else if (e.CommandName == PERFORM_RANKING) { SessionUtilHelper.KeepInSession(e.CommandArgument.ToString(), Session); Page.ClientScript.RegisterStartupScript(this.GetType(), "openModal", "window.onload = function() { $('#modalRanking').modal('show'); }", true); } else if (e.CommandName == PERFORM_SUPPORT) { SessionUtilHelper.KeepInSession(e.CommandArgument.ToString(), Session); Page.ClientScript.RegisterStartupScript(this.GetType(), "openModal", "window.onload = function() { $('#modalInvoiceItemSupport').modal('show'); }", true); UCModalInvoiceItemSupport.LoadCommentsSupport(Convert.ToInt32(e.CommandArgument.ToString())); } } catch (Exception exception) { ((front)Master).Alert.Show("Exception", exception.Message); } }