Example #1
0
		void Paint(Element parent)
		{	
			new Div(parent, div=>{
				div.ClassName="span6 offset3 well";
				div.Hide();
			}) ;
			
			SearchDiv= new Div(default(Element), searchdiv=>{
				searchdiv.ClassName= "span6 offset3 nav";

				var inputFecha=new InputText(searchdiv, ip=>{
					ip.ClassName="input-medium search-query";
					ip.SetAttribute("data-mask","99.99.9999");
					ip.SetPlaceHolder("dd.mm.aaaa");
				}).Element(); 
				
				new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-search icon-large";
					abn.JSelect().Click(evt=>{
						if( ! inputFecha.Value.IsDateFormatted()){
							Div.CreateAlertErrorAfter(SearchDiv.Element(),"Digite una fecha valida");
							return;
						}
						LoadGastos( inputFecha.Value.ToServerDate() );

					});
				});

				BNew= new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-plus-sign icon-large";
					abn.JSelect().Click(evt=>{
						FormDiv.FadeIn();
						GridDiv.FadeOut();
						Form.Element().Reset();
						BDelete.Element().Disabled=true;
					});
				});

				BDelete=new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-remove-sign icon-large";
					abn.Disabled=true;
					abn.JSelect().Click(evt=>{
						RemoveRow();
					});
				});

				BList= new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-reorder icon-large";
					abn.Disabled=true;
					abn.JSelect().Click(evt=>{
						FormDiv.FadeOut();
						GridDiv.FadeIn();
						abn.Disabled=true;
					});
				});
				
			});
			SearchDiv.AppendTo(parent);
			
			
			FormDiv= new Div(default(Element), formdiv=>{
				formdiv.ClassName="span6 offset3 well";
				Form = new Form(formdiv, f=>{
					f.ClassName="form-horizontal";
					f.Action="api/Gasto/";
					f.Method="post";

					var inputId= new InputText(f, e=>{
						e.Name="Id";
						e.Hide();
					}); 

					var cbConcepto=new SelectField(f, (e)=>{
						e.Name="IdConcepto";
						e.ClassName="span12";
						new HtmlOption(e, o=>{
							o.Value="";
							o.Selected=true;
							o.Text="Seleccione el concepto ...";
						});											
						LoadConceptos(e);
					});
					
					var cbFuente= new SelectField(f, (e)=>{
						e.Name="IdFuente";
						e.ClassName="span12";
						new HtmlOption(e, o=>{
							o.Value="";
							o.Selected=true;
							o.Text="Seleccione la fuente de pago ...";
						});											
						LoadFuentes(e);
					});
					
					var fieldValor= new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Valor";
						field.SetPlaceHolder("$$$$$$$$$$");
						field.AutoNumericInit();
						field.Style.TextAlign="right";
					});
					
					new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Beneficiario";
						field.SetPlaceHolder("Pagado a ....");
					});
					
					new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Descripcion";
						field.SetPlaceHolder("Descripcion");
					});
										
					var bt = new SubmitButton(f, b=>{
						b.JSelect().Text("Guardar");
						b.LoadingText(" Guardando ...");
						b.ClassName="btn btn-info btn-block" ;
					});
					
					var vo = new ValidateOptions()
						.SetSubmitHandler( form=>{
							
							bt.ShowLoadingText();

							var action= form.Action+(string.IsNullOrEmpty(inputId.Value())?"create":"update");
							jQuery.PostRequest<BLResponse<Gasto>>(action, form.AutoNumericGetString(), cb=>{},"json")
								.Success(d=>{
									Cayita.Javascript.Firebug.Console.Log("Success guardar gasto",d);
									if(string.IsNullOrEmpty(inputId.Value()) )
										AppendRow(d.Result[0]);
									else
										UpdateRow(d.Result[0]);

									form.Reset();
								})
									.Error((request,  textStatus,  error)=>{
										Cayita.Javascript.Firebug.Console.Log("request", request );
										Cayita.Javascript.Firebug.Console.Log("error", error );
										Div.CreateAlertErrorBefore(form.Elements[0],
										                           textStatus+": "+ request.StatusText);
									})
									.Always(a=>{
										bt.ResetLoadingText();
									});
							
						})
							.AddRule((rule, msg)=>{
								rule.Element=fieldValor.Element();
								rule.Rule.Required();
								msg.Required("Digite el valor del gasto");
							})

							.AddRule((rule, msg)=>{
								rule.Element=cbConcepto.Element();
								rule.Rule.Required();
								msg.Required("Seleccione el concepto");
							})
							
							.AddRule((rule, msg)=>{
								rule.Element=cbFuente.Element();
								rule.Rule.Required();
								msg.Required("Seleccione al fuente del pago");
							});
					
					f.Validate(vo);				
				});
			});

			FormDiv.AppendTo(parent);
						
			GridDiv= new  Div(default(Element), gdiv=>{
				gdiv.ClassName="span10 offset1";

				TableGastos= new HtmlTable(gdiv, table=>{
					InitTable (table);
				});	
				gdiv.Hide();
			});

			GridDiv.AppendTo(parent);	
		}
		public void Show()
		{
			Container = Div.CreateContainer(default(Element), container=>{
				Div.CreateRow(container, row=>{
					//
					new Div(row,element=>{
						
						element.ClassName="span4 offset4 well";
						new Legend(element, l=>l.Text("Por favor inicie session"));
						
						new Form(element, fe=>{
							fe.Action= "/api/User/login";

							new TextField(fe, i=>{
								i.SetPlaceHolder("NIT");i.Name="Nit";i.ClassName="span4";
								i.SetRequired();i.SetMinLength(8);
							});

							new TextField(fe, i=>{
								i.SetPlaceHolder("nombre usuario");	i.Name="Nombre";i.ClassName="span4";
								i.SetRequired();i.SetMinLength(4);
							});

							new TextField(fe, i=>{
								i.SetPlaceHolder("clave");	i.Name="Clave";i.ClassName="span4";
								i.SetRequired();i.SetMinLength(4);
								i.Type="password";
							});

							var bt = new SubmitButton(fe, b=>{
								b.JQuery().Text("Iniciar Session");
								b.ClassName="btn btn-info btn-block";
								b.LoadingText("  autenticando....");
							});
							
							var vo = new ValidateOptions()
								.SetSubmitHandler( f=>{
									
									bt.ShowLoadingText();
									
									var req=jQuery.PostRequest<UserLoginResponse>(f.Action, f.Serialize(), cb=>{},"json");
									req.Done(d=>{
										Cayita.Javascript.Firebug.Console.Log(d);
										f.Clear();
										if(OnLogin!=null) OnLogin(d,this);
											
									});
									req.Fail(e=> {
										Cayita.Javascript.Firebug.Console.Log("fail :",req); 
										Div.CreateAlertErrorBefore(fe.Elements[0], req.Status.ToString()+":"+
										                           (req.StatusText.StartsWith("ValidationException")?
										                           "Usario/clave no validos":
										                           req.StatusText)); 
									});
									req.Always(a=>{
												bt.ResetLoadingText();
									})	;
										
								});
							
							fe.Validate(vo);			
							
						});
						
					});
					
				});
			});
			
			Parent.AppendChild(Container.Element());
		}
Example #3
0
		void Paint(Element parent)
		{	
			new Div(parent, div=>{
				div.ClassName="span6 offset3 well";
				div.Hide();
			}) ;
			
			SearchDiv= new Div(default(Element), searchdiv=>{
				searchdiv.ClassName= "span6 offset3 nav";
				
				BNew = new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-plus-sign icon-large";
					abn.JSelect().Click(evt=>{
						GridDiv.Hide();
						FormDiv.FadeIn();
						Form.Element().Reset();
						BDelete.Element().Disabled=true;
						BList.Element().Disabled=false;
					});
				});
				
				BDelete= new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-remove-sign icon-large";
					abn.Disabled=true;
					abn.JSelect().Click(evt=>{
						RemoveRow();
					});
				});
				
				BList= new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-reorder icon-large";
					abn.JSelect().Click(evt=>{
						FormDiv.Hide();
						GridDiv.FadeIn();
						BList.Element().Disabled=true;
					});
				});
				
			});
			SearchDiv.AppendTo(parent);
			
			GridDiv= new  Div(default(Element), gdiv=>{
				gdiv.ClassName="span6 offset3";
				TableFuentes= new HtmlTable(gdiv, table=>{
					InitTable(table);
					LoadFuentes(table);
				});
			});
			
			GridDiv.AppendTo(parent);
			
			
			FormDiv= new Div(default(Element), formdiv=>{
				formdiv.ClassName="span6 offset3 well";
				formdiv.Hide();
				Form = new Form(formdiv, f=>{
					f.ClassName="form-horizontal";
					f.Action="api/Fuente/";
					
					var inputId= new InputText(f, e=>{
						e.Name="Id";
						e.Hide();
					}); 
					
					var cbTipo= new SelectField(f, (e)=>{
						e.Name="Tipo";
						e.ClassName="span12";

						new HtmlOption(e, o=>{
							o.Value="";
							o.Selected=true;
							o.Text="Seleccione el tipo ";
						});

						new HtmlOption(e, o=>{
							o.Value="Credito";
							o.Text="Credito";
						});											
						new HtmlOption(e, o=>{
							o.Value="Debito";
							o.Text="Debito";
						});											
												
					});
					
					var fieldCodigo=new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Codigo";
						field.SetPlaceHolder("Codigo del Recurso ## Grupo ##.## Item");
					});
					
					var fieldNombre=new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Nombre";
						field.SetPlaceHolder("Nombre del Recurso");
					});
					
					
					var bt = new SubmitButton(f, b=>{
						b.JSelect().Text("Guardar");
						b.LoadingText(" Guardando ...");
						b.ClassName="btn btn-info btn-block" ;
					});
					
					var vo = new ValidateOptions()
						.SetSubmitHandler( form=>{
							
							bt.ShowLoadingText();
							var action= form.Action+(string.IsNullOrEmpty(inputId.Value())?"create":"update");
							jQuery.PostRequest<BLResponse<Fuente>>(action, form.Serialize(), cb=>{},"json")
								.Success(d=>{
									Cayita.Javascript.Firebug.Console.Log("Success guardar recurso",d);
									if(string.IsNullOrEmpty(inputId.Value()) )
										AppendRow(d.Result[0]);
									else
										UpdateRow(d.Result[0]);
									FormDiv.FadeOut();
									GridDiv.Show ();
									
								})
									.Error((request,  textStatus,  error)=>{
										Cayita.Javascript.Firebug.Console.Log("request", request );
										Div.CreateAlertErrorBefore(form.Elements[0],
										                           textStatus+": "+ request.StatusText);
									})
									.Always(a=>{
										bt.ResetLoadingText();
									});
							
						})	
							.AddRule((rule, msg)=>{
								rule.Element=cbTipo.Element();
								rule.Rule.Required();
								msg.Required("Seleccione tipo de Recurso");
							})
							.AddRule((rule,msg)=>{
								rule.Element=fieldNombre.Element();
								rule.Rule.Required().Maxlength(64);
								msg.Required("Indique el nombre del Recurso").Maxlength("Maximo 64 Caracteres");
							}).AddRule((rule,msg)=>{
								rule.Element=fieldCodigo.Element();
								rule.Rule.Required().Maxlength(5);
								msg.Required("Indique el codigo del Recurso").Maxlength("Maximo 5 caracteres");
							});
					
					f.Validate(vo);					
				});
			});

			FormDiv.AppendTo(parent);
		}
Example #4
0
		public void Show()
		{
			Container = Div.CreateContainer(default(Element), container=>{
				Div.CreateRow(container, row=>{
					//
					new Div(row,element=>{

						element.ClassName="span4 offset4 well";
						new Legend(element, new LegendConfig{Text="Por favor inicie session"});
						
						new Form(element, fe=>{
							fe.Action= Config.Action;
							fe.Method = Config.Method;

							var cg = Div.CreateControlGroup(fe);
							
							var user= new InputText(cg.Element(), pe=>{
								pe.ClassName="span4";
								pe.SetPlaceHolder("nombre de usuario");
								pe.Name="UserName";
							});
							
							cg = Div.CreateControlGroup(fe);
							var pass =new InputPassword(cg.Element(), pe=>{
								pe.ClassName="span4";
								pe.SetPlaceHolder("Digite su clave");
								pe.Name="Password";
							});
																												
							var bt = new SubmitButton(fe, b=>{
								b.JSelect().Text("Iniciar Session");
								b.ClassName="btn btn-info btn-block";
								b.LoadingText("  autenticando....");
							});
														
							var vo = new ValidateOptions()
								.SetSubmitHandler( f=>{
									
									bt.ShowLoadingText();
									
									jQuery.PostRequest<LoginResponse>(f.Action, f.Serialize(), cb=>{
										Cayita.Javascript.Firebug.Console.Log("callback", cb);
									},"json")
										.Success(d=>{
											UserName= user.Element().Value;
											if(OnLogin!=null) OnLogin(d,this);
											
										})
											.Error((request,  textStatus,  error)=>{
												Div.CreateAlertErrorBefore(fe.Elements[0],textStatus+": "
												                           +( request.StatusText.StartsWith("ValidationException")?
												  "Usario/clave no validos":
												  request.StatusText));
											})
											.Always(a=>{
												bt.ResetLoadingText();
											})										;
									
									
								})
									.AddRule((rule, msg)=>{
										rule.Element=pass.Element();
										rule.Rule.Minlength(2).Required();
										msg.Minlength("minimo 2 caracteres").Required("Digite su password");
									})
									
									.AddRule( (rule, msg)=> {
										rule.Element= user.Element();
										rule.Rule.Required().Minlength(2);
										msg.Minlength("minimo 2 caracteres");
									});
							
							fe.Validate(vo);			
							
						});
						
					});

				});
			});
			
			Parent.AppendChild(Container.Element());
		}