/// <summary> /// Get all items for the current type /// </summary> /// <returns>A list of Lookup objects</returns> public IList <Lookup> List(LookupType type) { //Cache Section string cacheKey = null; MembershipHelperUser mhu = MembershipHelper.GetUser(); if (mhu != null) { cacheKey = string.Format("LOOKUPS_{0}_{1}_{2}", mhu.UserId, typeof(Lookup).ToString(), type.ToString()); } object result = CacheManager.GetCached(typeof(Lookup), cacheKey); ICriteria crit = GetCriteria(); if (result == null) { string query = "SELECT L FROM Lookup L WHERE"; query += " LookupType = :Type"; query += " ORDER BY UPPER(Description)"; IQuery q = NHibernateSession.CreateQuery(query); q.SetEnum("Type", type); result = q.List <Lookup>(); //crit.Add(Expression.Eq("LookupType", type)); //crit.AddOrder(new Order("Description", true)); //result = crit.List<Lookup>(); CacheManager.AddItem(typeof(Lookup), cacheKey, result); } return(result as IList <Lookup>); }
protected void btnImport_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } try { #if DEBUG ControllerManager.PriceImport.Import(Id, MembershipHelper.GetUser().UserId); #else ControllerManager.PriceImport.ImportOffLine(Id); #endif } catch (Exception ex) { Utils.ShowMessage(Page, "Ocurrío un error al importar el archivo. Comuniquese con el administrador.", Utils.MessageType.Error); Utils.GetLogger().Error(ex); return; } LoadInfo(); Utils.ShowMessage(Page, "La importación se ha enviado a procesar...", Utils.MessageType.Info); }
public IList <Distributor> GetActivesByPriceGroup(PriceGroup pG, int?maxResults) { //Cache Section string cacheKey = null; MembershipHelperUser mhu = MembershipHelper.GetUser(); if (mhu != null) { cacheKey = string.Format("DISTRIBUTORS_{0}_{1}_{2}_{3}", mhu.UserId, typeof(Distributor).ToString(), pG.ID, maxResults); } object result = CacheManager.GetCached(typeof(Distributor), cacheKey); if (result == null) { ExecutePermissionValidator epv = new ExecutePermissionValidator(); epv.ClassType = typeof(PriceList); epv.KeyIdentifier = Config.SeePriceLists; bool CanSeeAll = PermissionManager.Check(epv); IList priceListIds = null; if (!CanSeeAll) { priceListIds = PermissionManager.GetPermissionIdentifiers(typeof(PriceList), PermissionAction.Create); } IList <Distributor> d = repository.GetActivesByPriceGroup(pG, maxResults, priceListIds); CacheManager.AddItem(typeof(Distributor), cacheKey, d); result = d; } return(result as IList <Distributor>); }
public void GetAssistence(Quote q, string path) { q = GetById(q.ID); q.Status = QuoteStatus.AssistenceRequired; IList <UserMember> umlst = MembershipManager.GetAdministrators(); MembershipHelperUser user = MembershipHelper.GetUser(); IList <Note> lst = ControllerManager.Note.ListByType(q.GetType(), q.ID, 1); foreach (UserMember userMember in umlst) { //PermissionManager.AddEntityPermision(q.GetType(), q.ID.ToString(), userMember.UserName); WebMailing w = new WebMailing(); string body = File.ReadAllText(Path.Combine(HttpContext.Current.Server.MapPath(Config.MailTemplatePath), "quote.htm")); body = body.Replace("[QUOTE_CONTACT]", MembershipHelper.GetUser(userMember.ID).FullName); body = body.Replace("[QUOTE_BODY]", path); body = body.Replace("[QUOTE_OBSERVATION]", lst[0].Description); body = body.Replace("[USUARIO]", user.FullName); body = body.Replace("[EMAIL]", user.Email); w.SendMail(userMember.Email, "", "Se ha solicitado asistencia en la cotización " + q.Number, body, false); } Save(q); }
public void Run(Provider provider, CategoryBase category) { int?providerId = null; int?categoryId = null; if (provider != null) { providerId = provider.ID; } if (category != null) { categoryId = category.ID; } #if !DEBUG // Indicates which method to execute ProcessItem processItem = new ProcessItem(Guid.NewGuid().ToString()); processItem.AssemblyName = typeof(PriceCalculator).Assembly.FullName; processItem.ClassName = typeof(PriceCalculator).FullName; processItem.ConstructorParameters = new object[] { true, MembershipHelper.GetUser().UserId }; processItem.MethodName = "Run"; processItem.MethodParameters = new object[] { providerId, categoryId }; // Add the task for processing whenever possible DynamicProcessorRemoting processor = (DynamicProcessorRemoting)Activator.GetObject(typeof(DynamicProcessorRemoting), Config.RemotingProcessor); processor.AddTask(processItem); #else new PriceCalculator(true, MembershipHelper.GetUser().UserId).Run(providerId, categoryId); #endif }
public void Send(Quote q, byte[] filecontent) { string body = File.ReadAllText( Path.Combine(HttpContext.Current.Server.MapPath(Config.MailTemplatePath), "quote.htm")); string email = q.Email; if (string.IsNullOrEmpty(email)) { email = q.Distributor.Email; } if (string.IsNullOrEmpty(email)) { email = q.Distributor.AlternativeEmail; } q.Status = QuoteStatus.Sent; Save(q); this.CommitChanges(); MembershipHelperUser mhu = MembershipHelper.GetUser(q.TimeStamp.CreatedBy); body = body.Replace("[QUOTE_BODY]", Resource.Business.GetString("QuoteBody")); body = body.Replace("[QUOTE_OBSERVATION]", q.Observations); body = body.Replace("[USUARIO]", mhu.FullName); body = body.Replace("[EMAIL]", mhu.Email); string title = "Cotizaciones"; string subject = "Cotización para " + q.Distributor.Name; string fileName = "Cotizacion" + q.Number + ".pdf"; IList <string> lstMails = new List <string>(); lstMails.Add(email); if (mhu != null) { lstMails.Add(mhu.Email); } if (ControllerManager.Lookup.List(LookupType.AdministratorReceiveMail)[0].Description == "True") { IList <UserMember> umlst = MembershipManager.GetAdministrators(); foreach (UserMember um in umlst) { lstMails.Add(um.Email); } } WebMailing w = new WebMailing(); foreach (string currentEmail in lstMails) { w.SendMail(currentEmail, title, subject, body, false, false, mhu.Email, mhu.FullName, fileName, filecontent); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Assembly a = Assembly.GetExecutingAssembly(); AssemblyName name = a.GetName(); lblVersion.Text = "v" + name.Version.Major + "." + name.Version.Minor + "." + name.Version.Build; lnkClearCache.Visible = MembershipHelper.GetUser().IsAdministrator; lnkGoToMembership.Visible = MembershipHelper.GetUser().IsAdministrator; } }
public void Reject(Quote q) { q = GetById(q.ID); if (q.TimeStamp.CreatedBy == null) { return; } MembershipHelperUser mu = MembershipHelper.GetUser((Guid)q.TimeStamp.CreatedBy); Reject(q, mu.Email); }
public IList <Distributor> GetActivesByPriceGroup(PriceGroup pG, int?maxResults) { //Cache Section string cacheKey = null; MembershipHelperUser mhu = MembershipHelper.GetUser(); if (mhu != null) { cacheKey = string.Format("DISTRIBUTORS_{0}_{1}_{2}_{3}", mhu.UserId, typeof(Distributor).ToString(), pG.ID, maxResults); } object result = CacheManager.GetCached(typeof(Distributor), cacheKey); ICriteria crit = GetCriteria(); if (result == null) { crit.Add(Expression.Not(Expression.Eq("DistributorStatus", DistributorStatus.Disable))); ICriteria critPriceList = crit.CreateCriteria("PriceList"); ExecutePermissionValidator epv = new ExecutePermissionValidator(); epv.ClassType = typeof(PriceList); epv.KeyIdentifier = Config.SeePriceLists; if (PermissionManager.Check(epv) == false) { IList priceListIds = PermissionManager.GetPermissionIdentifiers(typeof(PriceList), PermissionAction.Create); int[] intPriceListIds = new int[priceListIds.Count]; for (int i = 0; i < priceListIds.Count; i++) { intPriceListIds[i] = Convert.ToInt32(priceListIds[i]); } critPriceList.Add(Expression.In("ID", intPriceListIds)); } critPriceList.Add(Expression.Or(Expression.Eq("PriceListStatus", PriceListStatus.Active), Expression.Eq("PriceListStatus", PriceListStatus.New))); critPriceList.Add(Expression.Eq("PriceGroup", pG)); crit.AddOrder(new Order("TimeStamp.CreatedOn", false)); if (maxResults.HasValue) { crit.SetMaxResults(maxResults.Value); } result = crit.List <Distributor>(); CacheManager.AddItem(typeof(Distributor), cacheKey, result); } return(result as IList <Distributor>); }
public new IList <Selection> GetAll() { MembershipHelperUser u = MembershipHelper.GetUser(); ICriteria crit = GetCriteria(); crit.AddOrder(new Order("Description", true)); if (u != null) { crit.Add(Expression.Eq("User", u.UserId)); } return(crit.List <Selection>()); }
public override void Refresh() { IList <UserMember> lst = MembershipManager.ListBySite(); IList <MembershipHelperUser> lstfinal = new List <MembershipHelperUser>(); foreach (UserMember member in lst) { lstfinal.Add(MembershipHelper.GetUser(member.ID)); } DataSource = lstfinal; DataTextField = "FullName"; DataValueField = "UserId"; DataBind(); Items.Insert(0, new ListItem("--Usuario--", "0")); }
private void RunOffline(bool trackChanges, object[] parameters) { // Indicates which method to execute string id = Guid.NewGuid().ToString(); ProcessItem processItem = new ProcessItem(id); processItem.AssemblyName = typeof(PriceCalculator).Assembly.FullName; processItem.ClassName = typeof(PriceCalculator).FullName; processItem.ConstructorParameters = new object[] { trackChanges, MembershipHelper.GetUser().UserId }; processItem.MethodName = "Run"; processItem.MethodParameters = parameters; // Add the task for processing whenever possible DynamicProcessorRemoting processor = (DynamicProcessorRemoting)Activator.GetObject(typeof(DynamicProcessorRemoting), Config.RemotingProcessor); processor.AddTask(processItem); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Distributor d = ControllerManager.Distributor.GetById(DistributorId); IList <Quo> quotesLst = ControllerManager.Quote.GetQuotesByUser(d, MembershipHelper.GetUser()); if (quotesLst != null && quotesLst.Count > 0) { rpterQuotes.DataSource = quotesLst; rpterQuotes.DataBind(); } else { litNoItems.Visible = true; } } }
public Quote AddItems(GridState gridState, IList <Filters.IFilter> filters, int quoteId, string distributorName, string description, string observations, int vigency, int quoteCondition, int quoteIntroText, string email, string contact, out bool canfinal) { canfinal = true; Quote q = new Quote(); if (quoteId > 0) { q = GetById(quoteId); } q.Distributor = ControllerManager.Distributor.GetByName(distributorName); q.Condition = ControllerManager.Lookup.GetById(quoteCondition); q.Description = description; q.IntroText = ControllerManager.Lookup.GetById(quoteIntroText); q.Observations = observations; q.Status = QuoteStatus.Draft; q.Vigency = ControllerManager.Lookup.GetById(vigency); q.Email = email; q.Contact = contact; MasterPriceSearchParameters mpsp = FilterHelper.GetSearchFilters(filters); //Si no limpiamos los items antes de agregarlos, se ahorraria tiempo y se podria acomodar por fecha de creación. //¿Porque se sacan todos? q.QuoteItems.Clear(); List <PriceBase> temppblist = ControllerManager.PriceBase.GetPriceBases(string.Empty, null, null, null, null, null, null, false, gridState.Items, false, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); foreach (PriceBase priceBase in temppblist) { canfinal = canfinal && AddItem(q, priceBase, string.Empty); } Save(q); CommitChanges(); q.Number = q.ID.ToString("000000"); if (quoteId == 0) { PermissionManager.AddEntityPermision(q.GetType(), q.ID.ToString(), MembershipHelper.GetUser().UserName); } return(q); }
private void Reject(Quote q, string creatoremail) { if (string.IsNullOrEmpty(creatoremail) || q.Status == QuoteStatus.Sent) { return; } q.Status = QuoteStatus.Rejected; string body = File.ReadAllText( Path.Combine(HttpContext.Current.Server.MapPath(Config.MailTemplatePath), "rejectquote.htm")); body = body.Replace("[QUOTE_BODY]", string.Format(Resource.Business.GetString("QuoteReject"), q.Number, q.Description)); body = body.Replace("[USUARIO]", MembershipHelper.GetUser().UserName); WebMailing wm = new WebMailing(); wm.SendMail(creatoremail, "Cotización Rechazada", "Cotización rechazada", body, false); }
public void Run(MasterPriceSearchParameters mpsp, GridState gs, Currency currency, PriceBaseStatus status) { #if !DEBUG // Indicates which method to execute string id = Guid.NewGuid().ToString(); ProcessItem processItem = new ProcessItem(id); processItem.AssemblyName = typeof(PriceCalculator).Assembly.FullName; processItem.ClassName = typeof(PriceCalculator).FullName; processItem.ConstructorParameters = new object[] { true, MembershipHelper.GetUser().UserId }; processItem.MethodName = "Run"; processItem.MethodParameters = new object[] { mpsp, gs, currency, status }; // Add the task for processing whenever possible DynamicProcessorRemoting processor = (DynamicProcessorRemoting)Activator.GetObject(typeof(DynamicProcessorRemoting), Config.RemotingProcessor); processor.AddTask(processItem); #else new PriceCalculator(true, MembershipHelper.GetUser().UserId).Run(mpsp, gs, currency, status); #endif }
protected void rpterNotes_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } Note nTemp = (Note)e.Item.DataItem; //Checkeo de permisos para borrar nota. e.Item.FindControl("lnkErase").Visible = PermissionManager.Check(e.Item.FindControl("lnkErase")); (e.Item.FindControl("litDate") as Literal).Text = string.Format("El {0} a las {1}", nTemp.TimeStamp.CreatedOn.ToShortDateString(), nTemp.TimeStamp.CreatedOn.ToLongTimeString()); MembershipHelperUser mhu = MembershipHelper.GetUser(nTemp.TimeStamp.CreatedBy); if (mhu != null) { (e.Item.FindControl("litUser") as Literal).Text = string.Format("{0} ({1}) escribió:", mhu.FullName, mhu.UserName); } }
/// <summary> /// /// </summary> /// <param name="gridState"></param> /// <param name="filters"></param> /// <param name="newselection"></param> /// <param name="selectionid"></param> /// <returns></returns> /// <exception cref="SelectionAlreadyExistException">Throws this exception when a selection already exist.</exception> public Selection Add(GridState gridState, IList <Filters.IFilter> filters, string newselection, int selectionid) { if (!gridState.IsAnyItemMarked) { throw new NoItemMarkedException("No items has been marked"); } Selection nuevaseleccion; if (!string.IsNullOrEmpty(newselection)) { if (!CanCreate(newselection)) { throw new SelectionAlreadyExistException("Ya existe una selección con ese nombre"); } MembershipHelperUser usuario = MembershipHelper.GetUser(); nuevaseleccion = ControllerManager.Selection.CreateSelection(newselection, usuario.UserId); } else { nuevaseleccion = ControllerManager.Selection.GetWithProducts(selectionid); } if (nuevaseleccion == null) { return(null); } string order = "DESC"; if (gridState.SortAscending) { order = "ASC"; } MasterPriceSearchParameters mpsp = FilterHelper.GetSearchFilters(filters); ControllerManager.PriceBase.AddToSelection(mpsp.Description, mpsp.Categories, mpsp.CtrRange, mpsp.Selection, mpsp.Frequency, gridState.SortField, order, gridState.MarkedAll, gridState.Items, mpsp.Currency, nuevaseleccion, mpsp.PriceGroup, mpsp.Provider, mpsp.SearchDate, mpsp.PriceBaseStatus, mpsp.ProductStatus, mpsp.IndexPrice, mpsp.SearchDateTo, mpsp.PriceImport, mpsp.PriceList, mpsp.WorkListItemStatus, mpsp.PublishList, mpsp.Distributor); return(nuevaseleccion); }
public void LoadInfo() { PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); PageNumber = 1; priceImportLogStatus = PriceImportLogStatus.Error; liError.Attributes["class"] = "pressed"; FillRepeater(); PriceImport priceImport = ControllerManager.PriceImport.GetById(Id); lblPriceImport.Text = priceImport.Description; lblCod.Text = priceImport.Number.ToString(); lblFile.Text = priceImport.File; lblNew.Text = priceImport.ImportView.AmountNew.ToString(); lblModified.Text = priceImport.ImportView.AmountChange.ToString(); lblErrors.Text = priceImport.ImportView.AmountError.ToString(); MembershipHelperUser mhu = MembershipHelper.GetUser(priceImport.TimeStamp.ModifiedBy); if (mhu != null) { lblUser.Text = mhu.UserName; } if (priceImport.TimeStamp.ModifiedOn.HasValue) { lblDate.Text = priceImport.TimeStamp.ModifiedOn.Value.ToShortDateString(); } lblStatus.Text = EnumHelper.GetDescription(priceImport.ImportStatus); if (priceImport.ImportStatus != ImportStatus.Verified && priceImport.ImportStatus != ImportStatus.VerifiedSomeInvalid) { btnImport.Visible = false; } if (priceImport.ImportView.AmountError == 0) { btnErrorExport.Visible = false; } }
protected void btnSend_Click(object sender, EventArgs e) { MembershipUser mu = Membership.GetUser(txtUser.Text); if (mu != null) { string newPassword = mu.ResetPassword(); WebMailing w = new WebMailing(); string body = File.ReadAllText(Path.Combine(HttpContext.Current.Server.MapPath(Config.MailTemplatePath), "newpassword.htm")); body = body.Replace("[NEW_PASSWORD]", newPassword); body = body.Replace("[USUARIO]", MembershipHelper.GetUser(mu.UserName).FullName); w.SendMail(mu.Email, "Cambio de Contraseña", "Cambio de Contraseña", body, false); Flash.Attributes["class"] = "flash_notice"; lblInfo.Text = "Su contraseña fue enviada con éxito."; } else { Flash.Attributes["class"] = "flash_alert"; lblInfo.Text = "El usuario ingresado es incorrecto"; } }
public new IList <Selection> GetAll() { MembershipHelperUser u = MembershipHelper.GetUser(); string query = "SELECT S FROM Selection S WHERE"; query += " User = :User"; query += " ORDER BY UPPER(Description)"; IQuery q = NHibernateSession.CreateQuery(query); q.SetGuid("User", u.UserId); return(q.List <Selection>()); //ICriteria crit = GetCriteria(); //crit.AddOrder(new Order("Description", true)); //if (u != null) // crit.Add(Expression.Eq("User", u.UserId)); //return crit.List<Selection>(); }
protected override void OnInit(EventArgs e) { if (!Page.User.Identity.IsAuthenticated) { return; } if (!Page.IsPostBack) { MembershipHelperUser mhs = MembershipHelper.GetUser(); if (mhs == null) { return; } Trace.Write("Begin Validate"); PermissionManager.Validate(this.Page); Trace.Write("Finish Validate"); lblUser.Text = mhs.FullName; } LoadMenu(); }
public void ImportOffLine(Guid id) { // Change the status to indicate we are processing this import file PriceImport pi = GetById(id); // Indicates which method to execute ProcessItem processItem = new ProcessItem(id.ToString()); processItem.AssemblyName = typeof(PriceImportController).Assembly.FullName; processItem.ClassName = typeof(PriceImportController).FullName; processItem.ConstructorParameters = new object[] { this.SessionFactoryConfigPath.Replace("~/", "") }; processItem.MethodName = "Import"; processItem.MethodParameters = new object[] { id, MembershipHelper.GetUser().UserId }; // Add the task for processing whenever possible DynamicProcessorRemoting processor = (DynamicProcessorRemoting)Activator.GetObject(typeof(DynamicProcessorRemoting), Config.RemotingProcessor); if (processor.AddTask(processItem)) { pi.ImportStatus = ImportStatus.SendToExecute; Save(pi); } }
/// <summary> /// Get all the notes for the current type, ordered by creation date. /// </summary> /// <param name="currentUser">If true only returns notes of the current user.</param> /// <param name="type">Tipo de objeto a la cual se agrega la nota</param> /// <returns>List of notes</returns> private IList <Note> ListByType(Type type, int?typeIdentifier, bool currentUser, int?maxResults) { ICriteria crit = GetCriteria(); crit.AddOrder(new Order("TimeStamp.CreatedOn", false)); crit.Add(Expression.Eq("TypeName", type.FullName)); if (typeIdentifier.HasValue) { crit.Add(Expression.Eq("TypeIdentifier", typeIdentifier)); } if (currentUser) { crit.Add(Expression.Eq("TimeStamp.CreatedBy", MembershipHelper.GetUser().UserId)); } if (maxResults.HasValue) { crit.SetMaxResults(Convert.ToInt32(maxResults)); } return(crit.List <Note>()); }
private void LoadFields() { Quote q = null; if (QuoteId > 0) { q = ControllerManager.Quote.GetById(QuoteId); } if (q == null) { Response.Redirect("/accessdenied.aspx"); } if (q.Status == QuoteStatus.Sent) { lnkEdit.Visible = false; } ExecutePermissionValidator epv = new ExecutePermissionValidator(); epv.ClassType = typeof(Quote); epv.KeyIdentifier = Config.SeeQuotes; if (PermissionManager.Check(epv) == false) { PermissionManager.Validate(q); } lblDistributor.Text = q.Distributor.Name; if (!string.IsNullOrEmpty(q.Contact)) { lblContact.Text = q.Contact; } else { lblContact.Text = q.Distributor.Contact; } if (!string.IsNullOrEmpty(q.Email)) { lblMail.Text = q.Email; } else if (!string.IsNullOrEmpty(q.Distributor.Email)) { lblMail.Text = q.Distributor.Email; } else if (!string.IsNullOrEmpty(q.Distributor.AlternativeEmail)) { lblMail.Text = q.Distributor.AlternativeEmail; } else { lblMail.Text = "N/D"; } lblDate.Text = q.TimeStamp.CreatedOn.ToShortDateString(); lblDiscount.Text = q.Distributor.Discount.ToString("#0.00") + "%"; lblVigency.Text = q.Vigency.Description + " dias"; lblQuoteNumber.Text = q.Number; if (q.Distributor.PaymentTerm != null) { lblPaymentCondition.Text = q.Distributor.PaymentTerm.Title; } lblIntroText.Text = q.IntroText.Description; lblCondition.Text = q.Condition.Description; lblStatus.Text = EnumHelper.GetDescription(q.Status); if (q.TimeStamp != null && MembershipHelper.GetUser(q.TimeStamp.CreatedBy) != null) { lblAutor.Text = MembershipHelper.GetUser(q.TimeStamp.CreatedBy).UserName; } //lblObservation.Text = q.Observations; lblObservation.Text = StringFormat.Cut(q.Observations, 100); lblObservation.Attributes["title"] = q.Observations; if (!Page.IsPostBack) { BoundField bf = new BoundField(); bf.DataField = "Code"; bf.HeaderText = Resource.Business.GetString("GridViewColumnCode"); bf.SortExpression = "Code"; GridView1.Columns.Add(bf); bf = new BoundField(); bf.DataField = "Description"; bf.HeaderText = Resource.Business.GetString("GridViewColumnDescription"); bf.SortExpression = "Description"; GridView1.Columns.Add(bf); bf = new BoundField(); bf.DataField = "PriceSell"; bf.HeaderText = Resource.Business.GetString("GridViewColumnPriceSell"); bf.SortExpression = "PriceSell"; GridView1.Columns.Add(bf); bf = new BoundField(); bf.DataField = "PriceList"; bf.HeaderText = Resource.Business.GetString("GridViewColumnPrice"); bf.SortExpression = "PriceList"; GridView1.Columns.Add(bf); bf = new BoundField(); bf.DataField = "LeadTime"; bf.HeaderText = Resource.Business.GetString("GridViewColumnLeadTime"); bf.SortExpression = "LeadTime"; GridView1.Columns.Add(bf); epv = new ExecutePermissionValidator(); epv.ClassType = typeof(QuoteItem); epv.KeyIdentifier = Config.QuoteItemSourceColumn; bf = new BoundField(); bf.DataField = "Source"; bf.HeaderText = Resource.Business.GetString("GridViewColumnSource"); bf.SortExpression = "Source"; bf.Visible = PermissionManager.Check(epv); GridView1.Columns.Add(bf); } GridView1.DataSource = q.QuoteItems; GridView1.DataBind(); if ((string.IsNullOrEmpty(q.Distributor.Email) && string.IsNullOrEmpty(q.Distributor.AlternativeEmail) && string.IsNullOrEmpty(q.Email)) || q.Status == QuoteStatus.Rejected) { btnSendPDF.Visible = false; Utils.ShowMessage(this.Page, "No se podra enviar la cotización por correo ya que el Canal de Ventas no tiene correo electronico asignado.", Utils.MessageType.Warning); } }
public Quote AddItems(GridState gridState, int quoteId, string distributorName, string description, string observations, int vigency, int quoteCondition, int quoteIntroText, string email, string contact, out bool canfinal, List <int> contactids, int currencyId) { lstRates = ControllerManager.CurrencyRate.GetArray(); canfinal = true; Currency c = ControllerManager.Currency.GetById(currencyId); Quote q = new Quote(); if (quoteId > 0) { q = repository.GetById(quoteId); } Distributor d = ControllerManager.Distributor.GetByName(distributorName); q.Distributor = d; q.Condition = ControllerManager.Lookup.GetById(quoteCondition); q.Description = description; q.IntroText = ControllerManager.Lookup.GetById(quoteIntroText); q.Observations = observations; q.Status = QuoteStatus.Draft; q.Vigency = ControllerManager.Lookup.GetById(vigency); q.Currency = c; q.CurrencyRate = ControllerManager.CurrencyRate.GetLast(q.Currency); List <Contact> temp = new List <Contact>(d.Contacts); AddContactNotifications(q, temp, contactids); if (!string.IsNullOrEmpty(email.Trim())) { AddNotifications(q, contact.Trim(), email.Trim()); } if (q.QuoteNotifications.Count == 0 && !string.IsNullOrEmpty(q.Distributor.Email)) { AddNotifications(q, q.Distributor.Contact, q.Distributor.Email); } else if (q.QuoteNotifications.Count == 0 && !string.IsNullOrEmpty(q.Distributor.AlternativeEmail)) { AddNotifications(q, q.Distributor.Contact, q.Distributor.AlternativeEmail); } //Si no limpiamos los items antes de agregarlos, se ahorraria tiempo y se podria acomodar por fecha de creación. //¿Porque se sacan todos? //q.QuoteItems.Clear(); List <PriceBase> temppblist = ControllerManager.PriceBase.GetPriceBases(string.Empty, null, null, null, null, null, null, false, gridState.Items, false, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); int i = 1; foreach (int item in gridState.Items) { PriceBase pb = temppblist.Find(delegate(PriceBase record) { if (record.ID == item) { return(true); } return(false); }); canfinal = canfinal && AddItem(q, pb, string.Empty, i); i++; } //foreach (PriceBase priceBase in temppblist) // canfinal = canfinal && AddItem(q, priceBase, string.Empty); repository.Save(q); repository.CommitChange(); q.Number = q.ID.ToString("000000"); if (quoteId == 0) { PermissionManager.AddEntityPermision(q.GetType(), q.ID.ToString(), MembershipHelper.GetUser().UserName); } return(q); }
public MemoryStream ExportToPDF(Quote q, string imagepath, bool includePriceSell) { MemoryStream ms = new MemoryStream(); System.Drawing.Image.FromFile(imagepath).Save(ms, System.Drawing.Imaging.ImageFormat.Gif); Font myfont = new Font(FontFactory.GetFont(FontFactory.HELVETICA, 8, iTextSharp.text.Font.NORMAL)); Document document = new Document(PageSize.LETTER); document.AddHeader("Expires", "0"); MemoryStream stream = new MemoryStream(); PdfWriter.GetInstance(document, stream).CloseStream = false; GeneratePDFHeaderFooter(document); document.Open(); document.NewPage(); GeneratePDFHeaderFooter(document); Image im = Image.GetInstance(ms.ToArray()); im.Alignment = Image.MIDDLE_ALIGN; im.ScalePercent(73); document.Add(im); document.Add(new Paragraph("Señores de:")); document.Add(new Paragraph(q.Distributor.Name)); document.Add(new Paragraph("Att:")); if (!string.IsNullOrEmpty(q.Contact)) { document.Add(new Paragraph(q.Contact)); } else { document.Add(new Paragraph(q.Distributor.Contact)); } document.Add(new Paragraph("Buenos Aires, " + q.TimeStamp.CreatedOn.ToLongDateString())); document.Add(new Paragraph("Cotización Nro: " + q.ID)); if (includePriceSell) { document.Add(new Paragraph("Descuento: " + q.Distributor.Discount.ToString("##0.00") + "%")); } document.Add(new Paragraph(q.IntroText.Description)); IList <QuoteItemView> lst = new List <QuoteItemView>(); foreach (QuoteItem item in q.QuoteItems) { lst.Add(new QuoteItemView(item)); } string[] titles; string[] columns; SetTitlesAndColumns(out titles, out columns, includePriceSell); document.Add(GeneratePDFTable(lst, titles, columns, includePriceSell)); Paragraph p = new Paragraph(); p.SpacingBefore = 10; p.Add("Forma de Pago: " + ((q.Distributor.PaymentTerm != null) ? q.Distributor.PaymentTerm.Title : "N/D")); document.Add(p); document.Add(new Paragraph("Validez de la Oferta: " + q.Vigency.Description + " días.")); document.Add(new Paragraph("Los precios son: " + ((q.Distributor.SaleConditions.HasValue) ? EnumHelper.GetDescription(q.Distributor.SaleConditions.Value) : "N/D"))); document.Add(new Paragraph(q.Condition.Description)); p = new Paragraph(); p.SpacingBefore = 10; p.Add("Sin más, saludo a Uds atte."); document.Add(p); p = new Paragraph(); p.SpacingBefore = 10; p.Add(q.CreatedByName); document.Add(p); document.Add(new Paragraph(MembershipHelper.GetUser(q.TimeStamp.CreatedBy).Email)); document.Close(); return(stream); }
public void Send(Quote q, byte[] filecontent) { MembershipHelperUser mhu = MembershipHelper.GetUser(q.TimeStamp.CreatedBy); IList <string[]> lstMails = new List <string[]>(); if (q.QuoteNotifications.Count > 0) { foreach (IQuoteNotification quoteNotification in q.QuoteNotifications) { string[] _contact = new string[2]; _contact[0] = quoteNotification.Name; _contact[1] = quoteNotification.Email; lstMails.Add(_contact); } } else { string name = q.Distributor.Contact; string email = q.Distributor.Email; if (string.IsNullOrEmpty(email)) { email = q.Distributor.AlternativeEmail; } string[] _contact = new string[2]; _contact[0] = name; _contact[1] = email; lstMails.Add(_contact); } if (mhu != null) { string[] _contact = new string[2]; _contact[0] = mhu.FullName; _contact[1] = mhu.Email; lstMails.Add(_contact); } if (ControllerManager.Lookup.List(LookupType.AdministratorReceiveMail)[0].Description == "True") { IList <UserMember> umlst = MembershipManager.GetAdministrators(); foreach (UserMember um in umlst) { string[] _contact = new string[2]; _contact[0] = um.UserName; _contact[1] = um.Email; lstMails.Add(_contact); } } string title = "Cotizaciones"; string subject = "Cotización para " + q.Distributor.Name; string fileName = "Cotizacion" + q.Number + ".pdf"; WebMailing w = new WebMailing(); foreach (string[] currentEmail in lstMails) { string body = File.ReadAllText(Path.Combine(HttpContext.Current.Server.MapPath(Config.MailTemplatePath), "quote.htm")); body = body.Replace("[QUOTE_CONTACT]", currentEmail[0]); body = body.Replace("[QUOTE_BODY]", Resource.Business.GetString("QuoteBody")); body = body.Replace("[QUOTE_OBSERVATION]", q.Observations); body = body.Replace("[USUARIO]", mhu.FullName); body = body.Replace("[EMAIL]", mhu.Email); w.SendMail(currentEmail[1], title, subject, body, false, false, mhu.Email, mhu.FullName, fileName, filecontent); } q.Status = QuoteStatus.Sent; if (q.SentDate == null) { q.SentDate = DateTime.Now; } repository.Save(q); repository.CommitChange(); }
private void LoadFields() { Quote q = null; if (QuoteId > 0) { q = ControllerManager.Quote.GetById(QuoteId); } if (q == null || ((q.Status == QuoteStatus.InAssistence || q.Status == QuoteStatus.AssistenceRequired) && "Chequear si no sos administrador" == "Chequear si no sos administrador")) { Response.Redirect("/accessdenied.aspx"); } if (q.Status == QuoteStatus.Sent) { lnkEdit.Visible = false; } else if (!ControllerManager.Quote.ValidateQuote(q)) { Utils.ShowMessage(this.Page, "Se modifico la información de la cotización.", Utils.MessageType.Warning); } ExecutePermissionValidator epv = new ExecutePermissionValidator(); epv.ClassType = typeof(Quote); epv.KeyIdentifier = Config.SeeQuotes; if (PermissionManager.Check(epv) == false) { PermissionManager.Validate(q); } lblDistributor.Text = q.Distributor.Name; if (!string.IsNullOrEmpty(q.Contacts)) { lblContact.Text = q.Contacts; } else { lblContact.Text = "N/D"; } lblDate.Text = q.TimeStamp.CreatedOn.ToShortDateString(); lblDiscount.Text = q.Distributor.Discount.ToString("#0.00") + "%"; lblVigency.Text = q.Vigency.Description + " dias"; lblQuoteNumber.Text = q.Number; if (q.Distributor.PaymentTerm != null) { lblPaymentCondition.Text = q.Distributor.PaymentTerm.Description; } lblIntroText.Text = q.IntroText.Description; lblCondition.Text = q.Condition.Description; lblStatus.Text = EnumHelper.GetDescription(q.Status); MembershipHelperUser mhu = MembershipHelper.GetUser(q.TimeStamp.CreatedBy); if (q.TimeStamp != null && mhu != null) { lblAutor.Text = mhu.FullName; } //lblObservation.Text = q.Observations; lblObservation.Text = StringFormat.Cut(q.Observations, 100); lblObservation.Attributes["title"] = q.Observations; if (q.Currency != null && q.CurrencyRate != null) { lblCurrency.Text = q.Currency.Description + " (" + q.CurrencyRate.Rate + ")"; } btnGetAssistence.Visible = q.Status == QuoteStatus.Draft; rptQuoteLine.DataSource = q.QuoteItems; rptQuoteLine.DataBind(); lblTotalCount.Text = q.Currency.Description + " " + TotalCount.ToString("0.##"); if (q.QuoteNotifications.Count == 0 || q.Status == QuoteStatus.Rejected) { btnSendPDF.Visible = false; if (q.QuoteNotifications.Count == 0) { Utils.ShowMessage(this.Page, "La cotización no podrá ser enviada por email ya que no tiene contactos asignados.", Utils.MessageType.Warning); } } }
public ProductView ChangePrice(string id, string value, string type, string masterListType, string globalToCurrency) { return(ControllerManager.PriceBase.ChangePrice(id, value, type, MembershipHelper.GetUser().UserId, masterListType, globalToCurrency)); }