public static bool ShowInputAmount3(EnumInputType type, out string input) { input = null; frmInputText frm = new frmInputText { Text = "输入" }; frm.lblTitle.Text = "优免金额"; switch (type) { case EnumInputType.Discount: frm.rbtAmount.Visible = false; frm.rbtDiscount.Checked = true; break; case EnumInputType.Reduce: frm.rbtDiscount.Visible = false; frm.rbtAmount.Checked = true; break; default: throw new ArgumentOutOfRangeException("type", type, null); } var result = frm.ShowDialog(); input = frm.inputNo; return(result == DialogResult.OK); }
public DisplayAlertViewModel(string title, string message, EnumInputType inputType) { Title = title; Message = message; InputType = inputType; YesCommand = new Command(async() => { await ClosePopUp(EnumOutputType.Yes, InputValue); }); NoCommand = new Command(async() => { await ClosePopUp(EnumOutputType.No, InputValue); }); OkCommand = new Command(async() => { await ClosePopUp(EnumOutputType.Ok, InputValue); }); CancelCommand = new Command(async() => { await ClosePopUp(EnumOutputType.Cancel, InputValue); }); }
/// <summary> /// 将EnumInputType类型的数值转换为KeyType类型枚举 /// </summary> /// <param name="key"></param> /// <returns></returns> private KeyType?ChangeKeyEnum(int key) { EnumInputType enumInputType = (EnumInputType)key; switch (enumInputType) { case EnumInputType.Up: return(KeyType.UP); case EnumInputType.Left: return(KeyType.LEFT); case EnumInputType.Right: return(KeyType.RIGHT); case EnumInputType.Down: return(KeyType.DOWN); case EnumInputType.A: return(KeyType.A); case EnumInputType.B: return(KeyType.B); case EnumInputType.X: return(KeyType.X); case EnumInputType.Y: return(KeyType.Y); case EnumInputType.L3: return(KeyType.LEFT_ROCKER); case EnumInputType.R3: return(KeyType.RIGHT_ROCKER); case EnumInputType.LB: return(KeyType.L1); case EnumInputType.RB: return(KeyType.R1); case EnumInputType.LT: return(KeyType.L2); case EnumInputType.RT: return(KeyType.R2); case EnumInputType.Start: return(KeyType.START); case EnumInputType.Back: return(KeyType.Back); default: return(null); } }
private void init() { string t = "\t"; string n = "\n"; StringBuilder dataAnnotations = new StringBuilder(); EnumInputType inputType = EnumInputType.undefined; foreach (CustomColumn c in CurrentTable.Columns) { //inputType = Globals.GetElementInputType(c); if (!c.IsNullable) { dataAnnotations.AppendLine($@"{t}{t}[Required(ErrorMessage = ""Please enter the {c.ProgramatlyName}."")]"); } if (c.DotNetType == typeof(string)) { dataAnnotations.AppendLine($@"{t}{t}[StringLength({c.MaxLength}, ErrorMessage = ""The {c.ProgramatlyName} must be less than {{1}} characters."")]"); } //if (c.DataTypeAttr != System.ComponentModel.DataAnnotations.DataType.Text) //{ // dataAnnotations.AppendLine($@"{t}{t}[DataType(DataType.{c.DataTypeAttr})]"); //} if (c.HasDefaultValue) { } if (c.DotNetType == typeof(string)) { } if (c.IsIdentifier) { dataAnnotations.AppendLine($@"{t}{t}[RegularExpression(@""^\S*$"", ErrorMessage = ""No white space allowed"")]"); } //dataAnnotations.AppendLine($@"{t}{t}[Display(Name = ""{c.ProgramatlyName}: "")]"); if (!c.IsIdentity && !FormConfigurationBuilder.ExecludedInputs.ToLower().Contains(c.LowerProgramatlyName)) { DynamicProperties.Append(dataAnnotations.ToString()); } //DynamicProperties.Append("\n\t\tpublic " + c.DotNetTypeAlias + optionalprifex + " " + c.ProgramatlyName + " { get; set; }\n"); DynamicProperties.Append($@"{n}{t}{t}public {c.DotNetTypeAlias} {c.ProgramatlyName} {{ get; set; }}"); //Here we will check the default value to add it in the dto if (c.HasDefaultValue) { //formElementInfoAttribute += $", InitialValue = {c.DefaultValue}"; if (c.DotNetType == typeof(bool)) { if (c.DefaultValue == "0") { DynamicProperties.Append(" = false;"); } if (c.DefaultValue == "1") { DynamicProperties.Append(" = true;"); } } else if (c.DotNetType == typeof(DateTime)) { if (c.DefaultValue.ToLower().IndexOf("getdate") > -1) { DynamicProperties.Append(" = DateTime.Now;"); } } else if (c.DotNetType == typeof(string)) { DynamicProperties.Append($@" = ""{c.DefaultValue}"";"); } else { DynamicProperties.Append($@" = {c.DefaultValue};"); } } if (c.IsForeignKey) { FilterProperties.AppendLine($@"{n}{t}public {c.DotNetTypeAlias} {c.ProgramatlyName} {{ get; set; }}"); DynamicProperties.AppendLine($@"{n}{t}{t}public SelectList {c.ProgramatlyName}_Options {{ get; set; }}"); } if (c.IsFile || c.IsPhoto) { string extension = ""; if (c.IsPhoto) { extension = "jpg,jpeg,png,gif"; } AdditionalProperties.AppendLine( $@" //--------------------------------- //{c.ProgramatlyName}PostedFile //--------------------------------- [FileType(""{extension}"")] [AllowFileSize(FileSize = 5 * 1024 * 1024, ErrorMessage = ""Maximum allowed file size is 5 MB"")] public HttpPostedFileBase {c.ProgramatlyName}PostedFile {{ get; set; }} public UploadedFile {c.ProgramatlyName}UploadedFile {{ get; set; }} //--------------------------------- #region ------{c.ProgramatlyName}Url------ //--------------------------------- //{c.ProgramatlyName}Url //--------------------------------- private string _{c.ProgramatlyName}Url; public string {c.ProgramatlyName}Url {{ {t}get {{ if (_{c.ProgramatlyName}Url == null && !string.IsNullOrEmpty(this.{c.ProgramatlyName})) {{ _{c.ProgramatlyName}Url = string.Format(""{{0}}{{1}}/{{2}}"", SiteSettings.{c.ProgramatlyName}VirtualPath, this.{c.ParentTable.ID.ProgramatlyName}, this.{c.ProgramatlyName}); }} return _{c.ProgramatlyName}Url; }} }} //--------------------------------- #endregion "); } if (c.IsPhoto) { AdditionalProperties.AppendLine( $@" #region ------{c.ProgramatlyName}ThumUrl------ //--------------------------------- //{c.ProgramatlyName}ThumUrl //--------------------------------- public string {c.ProgramatlyName}ThumUrl {{ get {{ if (!string.IsNullOrEmpty(this.{c.ProgramatlyName})) {{ return ""/{c.ParentTable.ProgramatlyName}/Thumbnail/"" + this.{c.ParentTable.ID.ProgramatlyName}; }} else return ""/Content/Limitless_2.0.1/Bootstrap 4/Template/global_assets/images/placeholders/placeholder.jpg""; }} }} //--------------------------------- #endregion "); } //---------------------------- DynamicProperties.AppendLine("\n"); if (c.IsFile || c.IsPhoto)//has additional props { AdditionalProperties.AppendLine("\n"); } //clear data annotation dataAnnotations.Clear(); } }
private void init() { //string parametterPattern = "\t\t\t\tmyCommand.Parameters.Add(\"@{0}\", SqlDbType.{1}, {2}).Value = {3}.{0};\n"; //string populatePropPattern = "\n\t\t\t//------------------------------------------------"; //populatePropPattern += "\n\t\t\t//[{2}]"; //populatePropPattern += "\n\t\t\t//------------------------------------------------"; //populatePropPattern += "\n\t\t\tif (reader[\"{0}\"] != DBNull.Value)"; //populatePropPattern += "\n\t\t\t {1}.{2} = ({3})reader[\"{0}\"];"; //populatePropPattern += "\n\t\t\t//------------------------------------------------"; string optionalprifex = ""; string formElementInfoAttribute = ""; EnumInputType inputType = EnumInputType.undefined; string execludedFormElements = "RequestID,ActorServiceProviderID,ActorServiceProviderAccountID,WFFinishDate,IsFinalApprove"; foreach (CustomColumn c in CurrentTable.Columns) { optionalprifex = ""; inputType = Globals.GetElementInputType(c); if (c.IsIdentity) { formElementInfoAttribute = $@"[FormElementInfo(PrimaryKey=true ,InputType = EnumInputType.{inputType.ToString()}, Execlude = true"; } else if (execludedFormElements.Contains(c.ProgramatlyName)) { formElementInfoAttribute = $@"[FormElementInfo(Execlude = true"; } else { formElementInfoAttribute = $@"[FormElementInfo(InputType = EnumInputType.{inputType.ToString()}, ResourceText=""{c.ProgramatlyName}"""; } //[Key] //[DataType(DataType.Password)] //[Required] //[Display(Name = "User name")] //if (c.InPrimaryKey) //{ // DynamicProperties.Append("\n\t\t[Key]"); //} if (c.IsForeignKey) { string dataSource = c.ProgramatlyName.Substring(0, c.ProgramatlyName.Length - 2); string key = c.ProgramatlyName; formElementInfoAttribute += $@",ForeignKey=true, DataSource=""{dataSource}"", DataSourceKey=""{dataSource}"", DataSourceText=""{dataSource}NameAr"", DataSourceTextAr=""{dataSource}NameAr"", DataSourceTextEn=""{dataSource}NameEn"""; } if (c.InPrimaryKey && c.IsIdentity) { optionalprifex = "?"; } else if (!c.IsNullable) { //DynamicProperties.Append("\n\t\t[Required]"); } else if (c.IsNullable) { formElementInfoAttribute += ", Required = false"; } if (c.DataTypeAttr != System.ComponentModel.DataAnnotations.DataType.Text) { //DynamicProperties.AppendFormat("\n\t\t[DataType(DataType.{0})]", c.DataTypeAttr); } if (c.HasDefaultValue) { formElementInfoAttribute += $", InitialValue = {c.dbObject.Default}"; //DynamicProperties.Append("\n\t\t[Editable(false, AllowInitialValue = true)]"); } if (c.SqlDbType == System.Data.SqlDbType.Char) { // DynamicProperties.AppendFormat("\n\t\t[StringLength({0})]", c.MaxLength); } else if (c.SqlDbType == System.Data.SqlDbType.NChar) { //DynamicProperties.AppendFormat("\n\t\t[StringLength({0})]", (c.MaxLength/2)); } if (c.DotNetType == typeof(string)) { formElementInfoAttribute += $", Maxlength = {c.MaxLength}"; } formElementInfoAttribute += ")]"; DynamicProperties.AppendFormat("\n\t\t{0}", formElementInfoAttribute); //DynamicProperties.AppendFormat("\n\t\t[Display(Name = \"{0}\")]" ,c.ProgramatlyName); DynamicProperties.Append("\n\t\tpublic " + c.DotNetTypeAlias + optionalprifex + " " + c.ProgramatlyName + " { get; set; }\n"); if (!c.InPrimaryKey) { //DynamicParameters.AppendFormat(parametterPattern, new string[] { c.ProgramatlyName, c.SqlDbTypeString, c.MaxLength.ToString(), CurrentTable.ModelObject }); //DynamicPopulatedParameters.AppendFormat(populatePropPattern, c.NameInDatabase, CurrentTable.ModelObject, c.ProgramatlyName, c.DotNetTypeAlias); //DynamicProperties.AppendFormat(prop, c.DotNetType, CurrentTable.ProgramatlyName); } } }