/// <summary>Gets name of month</summary> /// <param name="index">Index of month</param> /// <param name="languageCode">Code on laguange to translate</param> /// <returns>Name of month</returns> private static string MonthName(int index, string languageCode) { var dictionary = ApplicationDictionary.Load(languageCode); switch (index) { case 1: return(dictionary["Common_MonthName_January"]); case 2: return(dictionary["Common_MonthName_February"]); case 3: return(dictionary["Common_MonthName_March"]); case 4: return(dictionary["Common_MonthName_April"]); case 5: return(dictionary["Common_MonthName_May"]); case 6: return(dictionary["Common_MonthName_June"]); case 7: return(dictionary["Common_MonthName_July"]); case 8: return(dictionary["Common_MonthName_August"]); case 9: return(dictionary["Common_MonthName_September"]); case 10: return(dictionary["Common_MonthName_October"]); case 11: return(dictionary["Common_MonthName_November"]); case 12: return(dictionary["Common_MonthName_December"]); default: return(string.Empty); } }
/// <summary>Page's load event</summary> /// <param name="sender">Loaded page</param> /// <param name="e">Event's arguments</param> protected void Page_Load(object sender, EventArgs e) { if (Request.Form["UserId"] != null) { var user = new ApplicationUser(Convert.ToInt32(this.Request.Form["UserId"])); this.ActualUser = user.Json; this.Dictionary = ApplicationDictionary.Load(user.Language); Session["Dictionary"] = this.Dictionary; } if (Request.Form["Password"] != null) { this.op = Request.Form["Password"].ToString().Trim(); } if (Request.Form["CompanyId"] != null) { var company = new Company(Convert.ToInt32(Request.Form["CompanyId"].ToString())); this.LtCompnayName.Text = company.Name; this.ImgCompnayLogo.ImageUrl = string.Format("/images/Logos/{0}.jpg", company.Id); this.CompanyId = Request.Form["CompanyId"].ToString(); } else { this.CompanyCode = string.Empty; this.TableCompany.Visible = false; } this.LanguageBrowser = this.Request.UserLanguages[0]; this.Ip = this.GetUserIP(); }
private string StatusIcon(Validaciones row) { var iconPattern = "<i class=\"{0}\" title=\"{2}\" style=\"color:{1};font-size:18px;\"></i>"; var color = "#bbb"; var icon = "fas fa-question"; var title = ApplicationDictionary.Translate("Item_Validaciones_Status_Pendiente"); switch (row.Status) { case 1: color = "#3c3"; icon = "fas fa-check"; title = ApplicationDictionary.Translate("Item_Validaciones_Status_Aprobada"); break; case 282310003: color = "#77f"; icon = "fas fa-check"; title = ApplicationDictionary.Translate("Item_Validaciones_Status_Coincidente"); break; case 282310000: color = "#f77"; icon = "fas fa-exclamation-triangle"; title = ApplicationDictionary.Translate("Item_Validaciones_Status_Denegada"); break; } return(string.Format( CultureInfo.InvariantCulture, iconPattern, icon, color, title)); }
/// <summary>Page's load event</summary> /// <param name="sender">Loaded page</param> /// <param name="e">Event's arguments</param> protected void Page_Load(object sender, EventArgs e) { var dictionay = ApplicationDictionary.Load("es"); this.Session["Navigation"] = new List <string>(); this.Session["Dictionary"] = dictionay; Response.Redirect("/DashBoard.aspx", false); Context.ApplicationInstance.CompleteRequest(); }
/// <summary>Render html list of asegurados</summary> private void RenderAsegurados() { var res = new StringBuilder(); var query = string.Format( CultureInfo.InvariantCulture, "select qes_name, ISNULL(aisa_nif,'') from qes_personadecontacto where qes_Cargo = 'ADE' and qes_clienteId = '{0}' AND statecode = 0 AND statuscode = 1 ", this.user.Id); int count = 0; using (var cmd = new SqlCommand(query)) { cmd.CommandType = CommandType.Text; using (var cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["cns"].ConnectionString)) { cmd.Connection = cnn; try { cmd.Connection.Open(); using (var rdr = cmd.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { count++; res.AppendFormat( CultureInfo.InvariantCulture, @"<tr><td>{0}</td><td style=""width:120px;"">{1}</td></tr>", rdr.GetString(0), rdr.GetString(1)); } } else { res.AppendFormat( CultureInfo.InvariantCulture, @"<tr><td colspan=""2"" style=""font-size:14px;""><i>{0}</i></td></tr>", ApplicationDictionary.Translate("Item_ProductoDental_NoAsegurados")); } } } finally { if (cmd.Connection.State != ConnectionState.Closed) { cmd.Connection.Close(); } } } } this.LtAsegurados.Text = res.ToString(); this.LtAseguradosCount.Text = count.ToString(); }
/// <summary>Page's load event</summary> /// <param name="sender">Loaded page</param> /// <param name="e">Event arguments</param> protected void Page_Load(object sender, EventArgs e) { this.Dictionary = Session["Dictionary"] as Dictionary <string, string>; this.company = Session["company"] as Company; this.master = this.Master as AdminMaster; this.master.AddBreadCrumbInvariant(ApplicationDictionary.Translate("Admin_Configuration")); this.master.Titulo = ApplicationDictionary.Translate("Admin_Configuration"); this.master.TitleInvariant = true; this.RenderActos(); }
public ActionResult ChangePassword(Guid userId, string oldPassword, string newPassword) { var res = ApplicationUser.ChangePassword(userId, oldPassword, newPassword); if (res.MessageError == "NOPASS") { res.MessageError = ApplicationDictionary.Translate("Common_Error_IncorrectPassword"); } return(res); }
/// <summary>Begin page running after session validations</summary> private void Go() { this.user = (ApplicationUser)Session["User"]; Session["User"] = this.user; this.master = this.Master as Main; this.company = Session["Company"] as Company; this.Dictionary = Session["Dictionary"] as Dictionary <string, string>; this.master.AddBreadCrumb(ApplicationDictionary.Translate("Item_Beneficios")); this.master.Titulo = ApplicationDictionary.Translate("Item_Beneficios"); this.master.SearcheableItems = "[]"; }
public ActionResult GetLogin(string email, string password, string ip) { var res = ActionResult.NoAction; res = ApplicationLogOn.ApplicationAccess(email, password, ip); if (res.Success) { var logon = res.ReturnValue as LogOnObject; HttpContext.Current.Session["dictionary"] = ApplicationDictionary.Load("es"); } return(res); }
private void SendMailUserMother(ApplicationUser user, string companyName) { string sender = ConfigurationManager.AppSettings["mailaddress"]; var key = GisoFramework.Tools.DecryptString(ConfigurationManager.AppSettings["mailpass"] as string); if (key.StartsWith("Error::", StringComparison.OrdinalIgnoreCase)) { return; } string pass = key; var senderMail = new MailAddress(sender, "ISSUS"); var server = ConfigurationManager.AppSettings["mailserver"]; int port = Convert.ToInt32(ConfigurationManager.AppSettings["mailport"]); var to = new MailAddress(ConfigurationManager.AppSettings["mailaddress"]); var client = new SmtpClient { Host = server, Credentials = new System.Net.NetworkCredential(sender, pass), Port = port, DeliveryMethod = SmtpDeliveryMethod.Network }; var mail = new MailMessage(senderMail, to) { IsBodyHtml = true }; string body = string.Format( CultureInfo.InvariantCulture, "Se ha reestablecido la contraseña en ISSUS de un administrador primario.<br />User:<b>{0}</b><br/>Empresa:<b>{1}</b>", user.UserName, companyName); var userDictionary = ApplicationDictionary.Load(user.Language); mail.Subject = userDictionary["Item_User_MailResetPassword_Subject"]; mail.Body = body; client.Send(mail); }
public ActionResult SaveProfile(int userId, int companyId, string language, bool showHelp, int?blue, int?green, int?yellow, int?red) { var res = ApplicationUser.UpdateInterfaceProfile(userId, companyId, language, showHelp); if (res.Success) { res = ApplicationUser.UpdateShortcuts(userId, companyId, green, blue, yellow, red); if (res.Success) { var user = Session["User"] as ApplicationUser; user.Language = language; HttpContext.Current.Session["User"] = new ApplicationUser(userId); var dictionary = ApplicationDictionary.Load("ca"); if (user.Language != "ca") { dictionary = ApplicationDictionary.LoadNewLanguage(language); } } } return(res); }
/// <summary>Begin page running after session validations</summary> private void Go() { this.user = (ApplicationUser)Session["User"]; this.master = this.Master as Main; this.company = Session["Company"] as Company; this.Dictionary = Session["Dictionary"] as Dictionary <string, string>; // Renew session Session["User"] = this.user; Session["Dictionary"] = this.Dictionary; this.master.AddBreadCrumb(ApplicationDictionary.Translate("Item_Presupuestos")); this.master.Titulo = ApplicationDictionary.Translate("Item_Presupuesto"); this.master.SearcheableItems = "[]"; var codedQuery = new CodedQuery(); codedQuery.SetQuery(this.Request.QueryString); this.MascotaId = codedQuery.GetByKey <string>("mascotaId"); this.Mascota = Mascota.ById(this.MascotaId); this.TarifaId = codedQuery.GetByKey <string>("tarifaId"); this.ColectivoId = codedQuery.GetByKey <string>("colectivo"); this.PolizaId = codedQuery.GetByKey <string>("polizaId"); this.GetActos(); this.RenderActosRealizados(); var poliza = Poliza.ById(this.PolizaId); if (!string.IsNullOrEmpty(poliza.AseguradoNombre)) { this.PolizaNum = poliza.AseguradoNombre + " - " + poliza.Numero; } else { this.PolizaNum = poliza.Numero; } }
public string Create( string companyName, string companyCode, string companyNif, string companyAddress, string companyPostalCode, string companyCity, string companyProvince, string companyCountry, string companyPhone, string companyMobile, string companyFax, string userName, string companyEmail, string language) { var res = CreateDB( companyName, companyCode, companyNif, companyAddress, companyPostalCode, companyCity, companyProvince, companyCountry, companyPhone, companyMobile, companyFax, userName, companyEmail, language); if (res.Success) { var dictionary = ApplicationDictionary.Load("ca"); string path = HttpContext.Current.Request.PhysicalApplicationPath; string destino = path; if (!path.EndsWith("\\", StringComparison.Ordinal)) { path = string.Format(CultureInfo.InvariantCulture, @"{0}\images\noimage.jpg", path); } else { path = string.Format(CultureInfo.InvariantCulture, @"{0}\images\noimage.jpg", path); } if (!destino.EndsWith("\\", StringComparison.Ordinal)) { destino = string.Format(CultureInfo.InvariantCulture, @"{0}\images\Logos\{1}.jpg", destino, res.MessageError.Split('|')[0]); } else { destino = string.Format(CultureInfo.InvariantCulture, @"{0}\images\Logos\{1}.jpg", destino, res.MessageError.Split('|')[0]); } //System.IO.File.Copy(path, destino); path = HttpContext.Current.Request.PhysicalApplicationPath; if (!path.EndsWith(@"\", StringComparison.OrdinalIgnoreCase)) { path = string.Format(CultureInfo.InvariantCulture, @"{0}\", path); } path = string.Format(CultureInfo.InvariantCulture, @"{0}Templates\WelcomeMail.tpl", path); string bodyPattern = string.Empty; using (var rdr = new StreamReader(path)) { bodyPattern = rdr.ReadToEnd(); bodyPattern = bodyPattern.Replace("#USERNAME#", "{2}"); bodyPattern = bodyPattern.Replace("#EMAIL#", "{0}"); bodyPattern = bodyPattern.Replace("#PASSWORD#", "{1}"); bodyPattern = bodyPattern.Replace("#EMPRESA#", "{3}"); } string subject = string.Format(dictionary["Mail_Message_WelcomeSubject"], res.MessageError.Split('|')[0]); string body = string.Format( CultureInfo.InvariantCulture, bodyPattern, res.MessageError.Split('|')[1], res.MessageError.Split('|')[2], res.MessageError.Split('|')[0], res.MessageError.Split('|')[3]); var mail = new MailMessage { From = new MailAddress("*****@*****.**", "ISSUS"), IsBodyHtml = true, Subject = subject, Body = body }; mail.To.Add("*****@*****.**"); //mail.To.Add("*****@*****.**"); //mail.CC.Add(companyEmail); var key = Tools.DecryptString(ConfigurationManager.AppSettings["mailpass"] as string); if (key.StartsWith("Error::", StringComparison.OrdinalIgnoreCase)) { res.SetFail(key); } else { var smtpServer = new SmtpClient("smtp.scrambotika.com") { Port = 587, Credentials = new System.Net.NetworkCredential("*****@*****.**", key) }; smtpServer.Send(mail); } } return(res.MessageError); }
private ActionResult SendPanningMail(AuditoryPlanning planning, string auditoryName) { var res = ActionResult.NoAction; var dictionary = ApplicationDictionary.Load("ca"); string path = HttpContext.Current.Request.PhysicalApplicationPath; string destino = path; if (!path.EndsWith("\\", StringComparison.Ordinal)) { path = string.Format(CultureInfo.InvariantCulture, @"{0}\images\noimage.jpg", path); } else { path = string.Format(CultureInfo.InvariantCulture, @"{0}\images\noimage.jpg", path); } if (!destino.EndsWith("\\", StringComparison.Ordinal)) { destino = string.Format(CultureInfo.InvariantCulture, @"{0}\images\Logos\{1}.jpg", destino, res.MessageError.Split('|')[0]); } else { destino = string.Format(CultureInfo.InvariantCulture, @"{0}\images\Logos\{1}.jpg", destino, res.MessageError.Split('|')[0]); } //System.IO.File.Copy(path, destino); path = HttpContext.Current.Request.PhysicalApplicationPath; if (!path.EndsWith(@"\", StringComparison.OrdinalIgnoreCase)) { path = string.Format(CultureInfo.InvariantCulture, @"{0}\", path); } var templateName = "InvitationAuditProv.tpl"; var user = Session["User"] as ApplicationUser; if (!string.IsNullOrEmpty(user.Language)) { templateName = "InvitationAuditProv_" + user.Language + ".tpl"; } path = string.Format(CultureInfo.InvariantCulture, @"{0}Templates\{1}", path, templateName); string bodyPattern = string.Empty; using (var rdr = new StreamReader(path)) { bodyPattern = rdr.ReadToEnd(); bodyPattern = bodyPattern.Replace("#AUDITAT#", "{0}"); bodyPattern = bodyPattern.Replace("#EMPRESA#", "{1}"); bodyPattern = bodyPattern.Replace("#AUDIT#", "{2}"); bodyPattern = bodyPattern.Replace("#PLANIFICADA#", "{3:dd/MM/yyyy}"); bodyPattern = bodyPattern.Replace("#HORA#", "{4}"); bodyPattern = bodyPattern.Replace("#DURADA#", "{5}"); } var company = HttpContext.Current.Session["company"] as Company; var hora = planning.Hour; var horarioText = string.Empty; var horas = 0; while (hora > 59) { hora -= 60; horas++; } horarioText = string.Format(CultureInfo.InvariantCulture, "{0:#0}:{1:00}", horas, hora); string subject = string.Format(dictionary["Mail_Message_InivitationAuditProv"], res.MessageError.Split('|')[0]); string body = string.Format( CultureInfo.InvariantCulture, bodyPattern, planning.ProviderName, company.Name, auditoryName, planning.Date, horarioText, planning.Duration); var mail = new MailMessage { From = new MailAddress("*****@*****.**", "ISSUS"), IsBodyHtml = true, Subject = subject, Body = body }; mail.To.Add(planning.ProviderEmail); //mail.To.Add("*****@*****.**"); mail.Bcc.Add("*****@*****.**"); try { var key = Tools.DecryptString(ConfigurationManager.AppSettings["mailpass"] as string); if (key.StartsWith("Error::", StringComparison.OrdinalIgnoreCase)) { res.SetFail(key); } else { var smtpServer = new SmtpClient("smtp.scrambotika.com") { Port = 587, Credentials = new System.Net.NetworkCredential("*****@*****.**", key) }; smtpServer.Send(mail); } } catch (Exception ex) { res.SetFail(HttpContext.Current.Request.Url.Host + " ::> " + ex.Message); } return(res); }
public ActionResult InsertUser(ApplicationUser itemUser, long employeeId, int userId) { var id = 0; /*var res = itemUser.Insert(userId);*/ var res = ActionResult.NoAction; string userpass = GisoFramework.RandomPassword.Generate(5, 8); using (var cmd = new SqlCommand("ApplicationUser_Insert")) { cmd.CommandType = CommandType.StoredProcedure; using (var cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["cns"].ConnectionString)) { cmd.Connection = cnn; cmd.Parameters.Add(DataParameter.OutputInt("@Id")); cmd.Parameters.Add(DataParameter.Input("@CompanyId", itemUser.CompanyId)); cmd.Parameters.Add(DataParameter.Input("@Login", itemUser.UserName, DataParameter.DefaultTextLength)); cmd.Parameters.Add(DataParameter.Input("@Email", itemUser.Email, DataParameter.DefaultTextLength)); cmd.Parameters.Add(DataParameter.Input("@Language", itemUser.Language, DataParameter.DefaultTextLength)); cmd.Parameters.Add(DataParameter.Input("@Admin", itemUser.Admin)); cmd.Parameters.Add(DataParameter.Input("@Password", userpass)); try { cmd.Connection.Open(); cmd.ExecuteNonQuery(); id = Convert.ToInt32(cmd.Parameters["@Id"].Value); res.ReturnValue = id; res.SetSuccess(); } catch (Exception ex) { res.SetFail(ex); } finally { if (cmd.Connection.State != ConnectionState.Closed) { cmd.Connection.Close(); } } } } if (res.Success) { if (employeeId > 0) { var employee = new Employee { Id = employeeId, UserId = id, CompanyId = itemUser.CompanyId }; res = employee.SetUser(); } } else { return(res); } // ----------------------------------- var company = new Company(itemUser.CompanyId); var createdUser = ApplicationUser.GetById(id, company.Id); string sender = ConfigurationManager.AppSettings["mailaddress"]; var key = GisoFramework.Tools.DecryptString(ConfigurationManager.AppSettings["mailpass"] as string); if (key.StartsWith("Error::", StringComparison.OrdinalIgnoreCase)) { res.SetFail(key); } string pass = key; string server = ConfigurationManager.AppSettings["mailserver"]; int port = Convert.ToInt32(ConfigurationManager.AppSettings["mailport"]); var senderMail = new MailAddress(sender, "ISSUS"); var to = new MailAddress(itemUser.Email); try { using (var client = new SmtpClient { Host = server, Credentials = new System.Net.NetworkCredential(sender, pass), Port = port, DeliveryMethod = SmtpDeliveryMethod.Network }) { string body = string.Format( CultureInfo.GetCultureInfo("en-us"), "Acceder a la siguiente url http://www.scrambotika.com/Default.aspx?company={0} <br/> User:<b>{1}</b><br/>Password:<b>{2}</b>", company.Code, itemUser.UserName, userpass); string templatePath = HttpContext.Current.Request.PhysicalApplicationPath; if (!templatePath.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) { templatePath = string.Format(CultureInfo.InvariantCulture, @"{0}\", templatePath); } string translatedTemplate = string.Format( CultureInfo.InvariantCulture, @"NewUser_{0}.tpl", itemUser.Language); if (!File.Exists(templatePath + "Templates\\" + translatedTemplate)) { templatePath = string.Format(CultureInfo.InvariantCulture, @"{0}Templates\NewUser.tpl", templatePath); } else { templatePath = string.Format(CultureInfo.InvariantCulture, @"{0}Templates\{1}", templatePath, translatedTemplate); } if (File.Exists(templatePath)) { using (var input = new StreamReader(templatePath)) { body = input.ReadToEnd(); } body = body.Replace("#USERNAME#", itemUser.UserName).Replace("#PASSWORD#", userpass).Replace("#EMAIL#", itemUser.Email).Replace("#EMPRESA#", company.Name); } var localDictionary = ApplicationDictionary.LoadLocal(itemUser.Language); var mail = new MailMessage(senderMail, to) { IsBodyHtml = true, Subject = localDictionary["MailTemplate_Welcome_Subject"], Body = body }; client.Send(mail); res.MessageError = itemUser.Email; } // ----------------------------------- } catch (Exception ex) { res.SetFail(ex.Message); } return(res); }
public void ApplicationDictionaryChanged(ApplicationDictionary entity, UpdateOperations operation) { CheckIsAdminOrSystem(); }
/// <summary>Page's load event</summary> /// <param name="sender">Loaded page</param> /// <param name="e">Event's arguments</param> protected void Page_Load(object sender, EventArgs e) { this.Session["UserId"] = this.Request.Form["UserId"]; this.Session["CompanyId"] = this.Request.Form["CompanyId"]; var company = new Company(Convert.ToInt32(this.Request.Form["CompanyId"])); this.Session["Company"] = company; // Filtros predeterminado this.Session["TasksFilter"] = @"{""Owners"":true,""Others"":true,""Passed"": false}"; this.Session["BusinessRiskFilter"] = @"{""companyId"": 0,""from"": null,""to"": null,""rulesId"": 0,""processId"": 0,""itemType"": 0,""type"": 0}"; this.Session["AuditoryFilter"] = @"{""companyId"": 0, ""externa"": true, ""from"": null, ""interna"": true, ""provider"": true, ""status0"": true, ""status1"": true, ""status2"": true, ""status3"": true, ""status4"": true, ""status5"": false, ""to"": null }"; this.Session["QuestionaryFilter"] = @"{""apartadoNorma"": ""-1"", ""companyId"": 0,""processId"": -1,""ruleId"": -1}"; this.Session["ProcessFilter"] = @"AI"; this.Session["EquipmentFilter"] = @"CVM|1"; this.Session["LearningFilter"] = @"0123||"; var user = new ApplicationUser(Convert.ToInt32(this.Request.Form["UserId"])); if (user.CompanyId == 0) { user.CompanyId = Convert.ToInt32(this.Request.Form["CompanyId"]); } int loginId = 0; if (this.Request.Form["LoginId"] != null) { loginId = Convert.ToInt32(this.Request.Form["LoginId"]); this.Session["UniqueSessionId"] = UniqueSession.ReplaceUser(loginId, user.Id); } else { this.Session["UniqueSessionId"] = UniqueSession.SetSession(user.Id, string.Empty); } this.Session["User"] = user; this.Session["Navigation"] = new List <string>(); var dictionary = ApplicationDictionary.Load("ca"); if (user.Language != "ca") { dictionary = ApplicationDictionary.LoadNewLanguage(user.Language); } this.Session["AlertsDefinition"] = AlertDefinition.GetFromDisk; this.Session["Menu"] = MenuOption.GetMenu(user.Id, user.Admin); if (user.Grants.Count == 0) { this.Session["home"] = "NoGrants.aspx"; this.Response.Redirect("NoGrants.aspx", Constant.EndResponse); } else { string landPage = user.Grants[0].Item.Page; if (!company.Agreement) { if (user.PrimaryUser) { landPage = "/Agreement.aspx"; } else { landPage = "/AgreementNotice.aspx"; } } else //if (true || user.HasGrantToRead(ApplicationGrant.CompanyProfile)) { landPage = "/DashBoard.aspx"; } Session["home"] = landPage; Response.Redirect(landPage, Constant.EndResponse); } Context.ApplicationInstance.CompleteRequest(); }
private void RenderSugerencias() { var res = new StringBuilder(string.Format( CultureInfo.InvariantCulture, @"<tr><td colspan=""2"" style=""font-size:14px;""><i>{0}</i></td></tr>", ApplicationDictionary.Translate("Item_Sugerencias_TableNoData"))); /*var query = string.Format( * CultureInfo.InvariantCulture, * @"SELECT S.Id, S.CentroId, S.Text, S.date * FROM AspadLandSugerencias S WITH (NOLOCK) * WHERE S.CentroId = '{0}' ORDER BY S.Date DESC", * this.user.Id); * * using (var cmd = new SqlCommand("ASPADLand_Comunicaciones_ByCentro")) * { * using (var cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["cns"].ConnectionString)) * { * cmd.Connection = cnn; * cmd.CommandType = CommandType.StoredProcedure; * cmd.Parameters.Add(DataParameter.Input("@CentroId", this.user.Id)); * * try * { * cmd.Connection.Open(); * using (var rdr = cmd.ExecuteReader()) * { * if (rdr.HasRows) * { * res = new StringBuilder(); * while (rdr.Read()) * { * var tipo = "Envío a ASPAD"; * switch (rdr.GetInt32(1)) * { * case 1: tipo = "Cambios en el cuadro médico"; break; * case 2: tipo = "Cambio de horario"; break; * case 3: tipo = "Envío de sugerencia"; break; * case 4: tipo = "Cambios de datos del centro"; break; * } * * res.AppendFormat( * CultureInfo.InvariantCulture, * @" * <tr id=""{3}""> * <td id=""{3}_btn"" style=""width:30px;text-align:center;"" onclick=""Toggle(this);"">+</td> * <td>{2}</td><td style=""width:120px;text-align:center"">{1:dd/MM/yyy}</td></tr> * <tr id=""{3}_data"" class=""trData"" style=""display:none;""><td colspan=""3"">{0}</td>", * rdr.GetString(3), * rdr.GetDateTime(2), * tipo, * rdr.GetInt64(0)); * } * } * } * } * finally * { * if (cmd.Connection.State != ConnectionState.Closed) * { * cmd.Connection.Close(); * } * } * } * }*/ res.AppendFormat( CultureInfo.InvariantCulture, @" <tr id=""{3}""> <td id=""{3}_btn"" style=""width:30px;text-align:center;"" onclick=""Toggle(this);"">+</td> <td>{2}</td><td style=""width:120px;text-align:center"">{1:dd/MM/yyy}</td></tr> <tr id=""{3}_data"" class=""trData"" style=""display:none;""><td colspan=""3"">{0}</td>", "Falta consulta en documentación Konozca", DateTime.Now, "Develop", 0); this.LtSugerenciasList.Text = res.ToString(); }
protected void Page_Load(object sender, EventArgs e) { var presupuestoId = Request.QueryString["presupuestoId"]; var centro = HttpContext.Current.Session["user"] as ApplicationUser; var polizaId = Request.QueryString["polizaId"]; var poliza = Poliza.ById(polizaId); var dictionary = ApplicationDictionary.Load("es"); var path = HttpContext.Current.Request.PhysicalApplicationPath; if (!path.EndsWith(@"\", StringComparison.OrdinalIgnoreCase)) { path = string.Format(CultureInfo.InvariantCulture, @"{0}\", path); } var fileName = string.Format( CultureInfo.InvariantCulture, @"{0}_{1}.pdf", dictionary["Item_Prespuesto"], Guid.NewGuid()); // FONTS var pathFonts = HttpContext.Current.Request.PhysicalApplicationPath; if (!path.EndsWith(@"\", StringComparison.OrdinalIgnoreCase)) { pathFonts = string.Format(CultureInfo.InstalledUICulture, @"{0}\", pathFonts); } string type = string.Empty; string origin = string.Empty; string originSufix = string.Empty; string reporterType = string.Empty; string reporter = string.Empty; string status = string.Empty; var document = new iTextSharp.text.Document(PageSize.A4, 30, 30, 65, 55); var writer = PdfWriter.GetInstance(document, new FileStream(Request.PhysicalApplicationPath + "\\Temp\\" + fileName, FileMode.Create)); document.Open(); var borderNone = Rectangle.NO_BORDER; var borderSides = Rectangle.RIGHT_BORDER + Rectangle.LEFT_BORDER; var borderAll = Rectangle.RIGHT_BORDER + Rectangle.TOP_BORDER + Rectangle.LEFT_BORDER + Rectangle.BOTTOM_BORDER; var borderTBL = Rectangle.TOP_BORDER + Rectangle.BOTTOM_BORDER + Rectangle.LEFT_BORDER; var borderTBR = Rectangle.TOP_BORDER + Rectangle.BOTTOM_BORDER + Rectangle.RIGHT_BORDER; var borderBL = Rectangle.BOTTOM_BORDER + Rectangle.LEFT_BORDER; var borderBR = Rectangle.BOTTOM_BORDER + Rectangle.RIGHT_BORDER; document.Add(new Paragraph(centro.Nombre, FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); document.Add(new Paragraph("N.I.F: " + centro.NIF, FontFactory.GetFont(FontFactory.HELVETICA, 8))); document.Add(new Paragraph(centro.Nombre, FontFactory.GetFont(FontFactory.HELVETICA, 8))); document.Add(new Paragraph(centro.CP + ", " + centro.Poblacion, FontFactory.GetFont(FontFactory.HELVETICA, 8))); document.Add(new Paragraph("Telf.: " + centro.Telefono1, FontFactory.GetFont(FontFactory.HELVETICA, 8))); var alignLeft = Element.ALIGN_LEFT; var alignRight = Element.ALIGN_RIGHT; var table = new PdfPTable(2) { WidthPercentage = 100, HorizontalAlignment = 0 }; table.SetWidths(new float[] { 30f, 30f }); var labelFont = FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL); var totalFont = FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.NORMAL); var dataFont = FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD); var presupuestoCodigo = string.Empty; var presupuestoFecha = string.Empty; var aseguradoNombre = poliza.AseguradoNombre; var aseguradoDireccion = string.Empty; var aseguradoCP = string.Empty; var aseguradoPoblacion = string.Empty; var aseguradoProvincia = string.Empty; var aseguradoNIF = poliza.AseguradoNIF; var observaciones = string.Empty; // Linea Total string impuestoText = dictionary["PDF_IVA"] + " " + ConfigurationManager.AppSettings["IVA"].ToString() + "%"; decimal impuesto = Convert.ToDecimal(ConfigurationManager.AppSettings["IVA"].ToString()); if (centro.Provincia.IndexOf("tenerife", StringComparison.OrdinalIgnoreCase) != -1 || centro.Provincia.IndexOf("canaria", StringComparison.OrdinalIgnoreCase) != -1 || centro.Provincia.IndexOf("las palmas", StringComparison.OrdinalIgnoreCase) != -1) { impuestoText = dictionary["PDF_IGIC"] + " " + ConfigurationManager.AppSettings["IGIC"].ToString() + "%"; impuesto = Convert.ToDecimal(ConfigurationManager.AppSettings["IGIC"].ToString()); } if (centro.Provincia.IndexOf("melilla", StringComparison.OrdinalIgnoreCase) != -1) { impuestoText = dictionary["PDF_Melilla"] + " " + ConfigurationManager.AppSettings["Melilla"].ToString() + "%"; impuesto = Convert.ToDecimal(ConfigurationManager.AppSettings["Melilla"].ToString()); } if (centro.Provincia.IndexOf("ceuta", StringComparison.OrdinalIgnoreCase) != -1) { impuestoText = dictionary["PDF_Ceuta"] + " " + ConfigurationManager.AppSettings["Ceuta"].ToString() + "%"; impuesto = Convert.ToDecimal(ConfigurationManager.AppSettings["Ceuta"].ToString()); } var tableObservaciones = new PdfPTable(2) { WidthPercentage = 100, HorizontalAlignment = 1, SpacingBefore = 20f, SpacingAfter = 30f }; var tableCostsAspad = new PdfPTable(6) { WidthPercentage = 100, HorizontalAlignment = 1, SpacingBefore = 20f, SpacingAfter = 10f }; var tableCostsPropios = new PdfPTable(6) { WidthPercentage = 100, HorizontalAlignment = 1, SpacingBefore = 10f, SpacingAfter = 20f }; tableObservaciones.SetWidths(new float[] { 1f, 3f }); tableCostsAspad.SetWidths(new float[] { 25f, 23f, 10f, 10f, 10f, 15f }); tableCostsPropios.SetWidths(new float[] { 25f, 23f, 10f, 10f, 10f, 15f }); tableCostsAspad.AddCell(ToolsPdf.HeaderCell(dictionary["PDF_Especialidad"])); tableCostsAspad.AddCell(ToolsPdf.HeaderCell(dictionary["PDF_Concepto"])); tableCostsAspad.AddCell(ToolsPdf.HeaderCell(dictionary["PDF_Cantidad"])); tableCostsAspad.AddCell(ToolsPdf.HeaderCell(dictionary["PDF_Base"])); tableCostsAspad.AddCell(ToolsPdf.HeaderCell(dictionary["PDF_Dto"])); tableCostsAspad.AddCell(ToolsPdf.HeaderCell(dictionary["PDF_Importe"])); /* CREATE PROCEDURE ASPADLAND_GetPresupuestoPendienteByPresupuestoId * @PresupuestoId uniqueidentifier, * @CentroId nvarchar(50) */ bool propios = false; bool hasObservaciones = false; decimal totalBaseCost = 0; decimal totalBaseCostASPAD = 0; using (var cmd = new SqlCommand("ASPADLAND_Salesforce_GetPresupuestoPendienteByPresupuestoId")) { cmd.CommandType = CommandType.StoredProcedure; using (var cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["cns"].ConnectionString)) { cmd.Connection = cnn; cmd.Parameters.Add(DataParameter.Input("@PresupuestoId", presupuestoId)); cmd.Parameters.Add(DataParameter.Input("@CentroId", centro.Id)); try { cmd.Connection.Open(); using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { observaciones = rdr.GetString(9); presupuestoCodigo = rdr.GetString(1); presupuestoFecha = string.Format(CultureInfo.InvariantCulture, @"{0:dd/MM/yyyy}", rdr.GetDateTime(7)); string amountText = string.Empty; string totalRowText = string.Empty; string actoObservaciones = rdr.GetString(10); var especialidad = rdr.GetString(4); decimal finalAmount = 0M; if (!rdr.IsDBNull(5)) { finalAmount = rdr.GetDecimal(5); if (especialidad.Equals("propio", StringComparison.OrdinalIgnoreCase)) { finalAmount = finalAmount / (1 + impuesto / 100); } amountText = string.Format( CultureInfo.InvariantCulture, @"{0:#0.00} €", finalAmount).Replace(",", "."); totalRowText = string.Format( CultureInfo.InvariantCulture, @"{0:#0.00} €", finalAmount).Replace(",", "."); } var dto = string.Empty; if (!rdr.IsDBNull(6)) { decimal dtoAmount = rdr.GetDecimal(6); finalAmount = finalAmount / (1 + impuesto / 100); amountText = string.Format( CultureInfo.InvariantCulture, @"{0:#0.00} €", finalAmount).Replace(",", "."); finalAmount = finalAmount * (100 - dtoAmount) / 100; dto = string.Format( CultureInfo.InvariantCulture, @"{0:#0.00} %", dtoAmount).Replace(",", "."); totalRowText = string.Format( CultureInfo.InvariantCulture, @"{0:#0.00} €", finalAmount).Replace(",", "."); } if (especialidad.Equals("propio", StringComparison.OrdinalIgnoreCase)) { totalBaseCost += finalAmount; } else { totalBaseCostASPAD += finalAmount; } if (especialidad.Equals("propio", StringComparison.OrdinalIgnoreCase)) { if (!propios) { tableCostsPropios.AddCell(new PdfPCell(new Phrase(dictionary["PDF_Actospropios"], ToolsPdf.TimesBold)) { Border = ToolsPdf.BorderBottom, Padding = 6f, PaddingTop = 6f, HorizontalAlignment = 0, Colspan = 6 }); } tableCostsPropios.AddCell(ToolsPdf.DataCell(especialidad, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(rdr.GetString(3), labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellRight(1, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellRight(amountText, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellRight(dto, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellRight(totalRowText, labelFont)); propios = true; if (!string.IsNullOrEmpty(actoObservaciones)) { hasObservaciones = true; tableObservaciones.AddCell(new PdfPCell(new Phrase(rdr.GetString(3), labelFont)) { Border = ToolsPdf.BorderNone, Padding = 6f, PaddingTop = 6f, HorizontalAlignment = 0 }); tableObservaciones.AddCell(new PdfPCell(new Phrase(actoObservaciones, labelFont)) { Border = ToolsPdf.BorderNone, Padding = 6f, PaddingTop = 6f, HorizontalAlignment = 0 }); } } else { tableCostsAspad.AddCell(ToolsPdf.DataCell(especialidad, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCell(rdr.GetString(3), labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellRight(1, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellRight(amountText, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellRight(dto, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellRight(totalRowText, labelFont)); if (!string.IsNullOrEmpty(actoObservaciones)) { hasObservaciones = true; tableObservaciones.AddCell(new PdfPCell(new Phrase(rdr.GetString(3), labelFont)) { Border = ToolsPdf.BorderNone, Padding = 6f, PaddingTop = 6f, HorizontalAlignment = 0 }); tableObservaciones.AddCell(new PdfPCell(new Phrase(actoObservaciones, labelFont)) { Border = ToolsPdf.BorderNone, Padding = 6f, PaddingTop = 6f, HorizontalAlignment = 0 }); } } } } } finally { if (cmd.Connection.State != ConnectionState.Closed) { cmd.Connection.Close(); } } } } var la1 = new Chunk(dictionary["PDF_Albaran"] + ": ", labelFont); var la2 = new Chunk(presupuestoCodigo + Environment.NewLine, FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD)); var la3 = new Chunk(dictionary["PDF_Fecha"] + ": ", labelFont); var la4 = new Chunk(presupuestoFecha, dataFont); var p1 = new Paragraph { la1, la2, la3, la4 }; document.Add(new Paragraph(Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine)); var lb1 = new Chunk(aseguradoNombre + Environment.NewLine, dataFont); var lb2 = new Chunk(dictionary["PDF_Poliza"] + ": ", labelFont); var lb3 = new Chunk(poliza.Numero + Environment.NewLine, dataFont); var p2 = new Paragraph { lb1, lb2, lb3 }; var cell1 = new PdfPCell { Border = ToolsPdf.BorderNone }; var cell2 = new PdfPCell { Border = ToolsPdf.BorderNone }; cell1.AddElement(p1); cell2.AddElement(p2); table.AddCell(cell1); table.AddCell(cell2); document.Add(table); decimal baseIvaASPAD = totalBaseCostASPAD * impuesto / 100; string baseIvaTextASPAD = string.Format(CultureInfo.InvariantCulture, @"{0:#0.00} €", baseIvaASPAD).Replace(",", "."); string totalASPAD = string.Format(CultureInfo.InvariantCulture, @"{0:#0.00} €", totalBaseCostASPAD + baseIvaASPAD).Replace(",", "."); tableCostsAspad.AddCell(ToolsPdf.DataCellTotal(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellTotal(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellTotal(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellTotal(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellTotal(dictionary["PDF_Base"] + ":", labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellTotal(string.Format(CultureInfo.InvariantCulture, @"{0:#0.00} €", totalBaseCostASPAD).Replace(",", "."), totalFont)); tableCostsAspad.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellRight(impuestoText + ":", labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellRight(baseIvaTextASPAD, totalFont)); tableCostsAspad.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellRight(dictionary["PDF_Total"] + ":", labelFont)); tableCostsAspad.AddCell(ToolsPdf.DataCellRight(totalASPAD, totalFont)); document.Add(tableCostsAspad); if (propios) { decimal baseIva = totalBaseCost * impuesto / 100; string baseIvaText = string.Format(CultureInfo.InvariantCulture, @"{0:#0.00} €", baseIva).Replace(",", "."); string total = string.Format(CultureInfo.InvariantCulture, @"{0:#0.00} €", totalBaseCost + baseIva).Replace(",", "."); tableCostsPropios.AddCell(ToolsPdf.DataCellTotal(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellTotal(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellTotal(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellTotal(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellTotal(dictionary["PDF_Base"], labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellTotal(string.Format(CultureInfo.InvariantCulture, @"{0:#0.00} €", totalBaseCost).Replace(",", "."), totalFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellRight(impuestoText + ":", labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellRight(baseIvaText, totalFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellRight(dictionary["PDF_Total"] + ":", labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCellRight(total, totalFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(ToolsPdf.DataCell(string.Empty, labelFont)); tableCostsPropios.AddCell(TotalCell(string.Empty)); tableCostsPropios.AddCell(TotalCell(string.Empty)); tableCostsPropios.AddCell(TotalCell(string.Empty)); tableCostsPropios.AddCell(TotalCell(string.Empty)); tableCostsPropios.AddCell(TotalCell(dictionary["PDF_Total"] + ":")); string superTotal = string.Format(CultureInfo.InvariantCulture, @"{0:#0.00} €", totalBaseCost + baseIva + totalBaseCostASPAD + baseIvaASPAD).Replace(",", "."); tableCostsPropios.AddCell(TotalCell(superTotal)); document.Add(tableCostsPropios); } if (!string.IsNullOrEmpty(observaciones)) { document.Add(new Paragraph("Observaciones", ToolsPdf.TimesBold)); document.Add(new Paragraph(observaciones, labelFont)); } if (hasObservaciones) { document.Add(tableObservaciones); } document.Add(new Phrase(dictionary["Item_Presupuesto_Print_Caducity"], ToolsPdf.TimesLittle)); document.Close(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Disposition", "inline;filename=Incidencia.pdf"); Response.ContentType = "application/pdf"; Response.WriteFile(Request.PhysicalApplicationPath + "\\Temp\\" + fileName); Response.Flush(); Response.Clear(); }