public override void Awake() { base.Awake(); if (nomalSprite == null) { nomalSprite = facialPhoto.sprite; } IdText.input.onValueChanged.AddListener((s) => { if (VerifyUtils.IsNumber(s)) { personnel.ID = int.Parse(s); IdText.Verify = true; return; } IdText.Verify = false; }); IdCardText.input.onValueChanged.AddListener((s) => { if (VerifyUtils.IsIDCard(s)) { personnel.IDCard = s; IdCardText.Verify = true; return; } IdCardText.Verify = false; }); archivalPhotoUpdateButton.onClick.AddListener(() => { if (personnel != null) { string file = Win32API.GetOpenFileName(); if (file != null) { archivalPhotoUpdateFileName = file; } } }); archivalPhotoButton.onClick.AddListener(() => { if (personnel != null) { if (!Kernel.Current.Image.View(archivalPhotoUpdateFileName)) { Kernel.Current.Desktop.OpenNew <DialogForm>().SetDialog(null, "打开失败!", "图片不存在或被其他程序占用无法打开."); } } }); FacialPhotoButtion.onClick.AddListener(() => { Sprite s = Kernel.Current.Image.Load(nomalSprite.texture.width, nomalSprite.texture.height); if (s != null) { facialPhoto.sprite = s; } }); PhoneText.input.onValueChanged.AddListener((s) => { if (s?.Length <= 20) { PhoneText.Verify = true; personnel.Phone = s; return; } PhoneText.Verify = false; }); UpdateToSql.onClick.AddListener(() => { switch (state) { case InfoFormWorkMode.ViewAndModifiy: { UpdateImage(); Debug.Log(personnel.ArchivalPhoto); Debug.Log(personnel.FacialPhoto); Kernel.Current.Sql.UpdateEntity(personnel); Kernel.Current.Desktop.OpenNew <DialogForm>().SetDialog(null, "修改完成", "修改成功"); } break; case InfoFormWorkMode.CreateNew: { if (Kernel.Current.Sql.LoadEntity <Personnel>(personnel.ID) == null) { Kernel.Current.Desktop.OpenNew <TextBoxForm>().SetCallback("请输入人员入职信息", (x) => { EntryRecord entryRecord = new EntryRecord(); entryRecord.Info = x; entryRecord.Time = DateTime.Now; entryRecord.PersonnelID = personnel.ID; Kernel.Current.Sql.Insert(entryRecord); UpdateImage(); Kernel.Current.Sql.InsertEntity(personnel); Kernel.Current.Desktop.OpenNew <DialogForm>().SetDialog(null, "修改完成", "修改成功"); }, null); } else { Kernel.Current.Desktop.OpenNew <DialogForm>().SetDialog(null, "此编号已存在", "请尝试其他编号"); } } break; default: break; } }); delete.onClick.AddListener(() => { Kernel.Current.Desktop.OpenNew <TextBoxForm>().SetCallback("添加此人员离职信息.", x => { Kernel.Current.Desktop.OpenNew <YesOrNoForm>().SetDialog(() => { TurnoverRecord turnoverRecord = new TurnoverRecord(); turnoverRecord.Info = x; turnoverRecord.PersonnelID = personnel.ID; turnoverRecord.Time = DateTime.Now; Kernel.Current.Sql.Insert(turnoverRecord); Kernel.Current.Sql.DeleteEntity(personnel); }, null, "确认操作", "确认执行吗?"); }, null); }); SetWorkMode(InfoFormWorkMode.ViewAndModifiy); }
protected override void Awake() { base.Awake(); input = transform.parent.Find("InputField").GetComponent <InputField>(); actionDir.Add("按编号查询", () => { SempleQueryWhere("ID", () => VerifyUtils.IsNumber(input.text), () => Kernel.Current.Desktop.OpenNew <DialogForm>().SetDialog(null, "不是数字!", "编号必须为数字.")); }); actionDir.Add("按民族查询", () => { SempleQueryWhere("Nation", null, () => NullWarmDialog()); }); actionDir.Add("按身份证查询", () => { SempleQueryWhere("IDCard", () => VerifyUtils.IsIDCard(input.text), () => MessageDialog("身份证无效")); }); actionDir.Add("按地址查询", () => { SempleQueryWhere("Address", null, () => NullWarmDialog()); }); actionDir.Add("按政治面貌查询", () => { SempleQueryWhere("PoliticalOutlook", null, () => NullWarmDialog()); }); actionDir.Add("按学历查询", () => { SempleQueryWhere("Education", null, () => NullWarmDialog()); }); actionDir.Add("按部门查询", () => { if (input.text != string.Empty && input.text != null) { var departments = Kernel.Current.Sql.LoadEntitys <Department>(); var id = global::System.Array.Find(departments, x => x.Name == input.text); if (id != null) { Kernel.Current.Desktop.OpenNew <SearchResultForm>().AddItems(new List <Personnel>(Kernel.Current.Sql.QueryWhere <Personnel>("DepartmentID=" + id.ID))); } else { Kernel.Current.Desktop.OpenNew <SearchResultForm>(); } input.text = string.Empty; return; } input.text = string.Empty; NullWarmDialog(); }); actionDir.Add("按姓名查询", () => { SempleQueryWhere("Name", null, () => NullWarmDialog()); }); actionDir.Add("按手机号码查询", () => { SempleQueryWhere("Phone", () => input.text.Length == 11, () => MessageDialog("电话号码必须为11位!")); }); actionDir.Add("按职位查询", () => { if (input.text != string.Empty && input.text != null) { var departments = Kernel.Current.Sql.LoadEntitys <Position>(); var id = global::System.Array.Find(departments, x => x.Name == input.text); if (id != null) { Kernel.Current.Desktop.OpenNew <SearchResultForm>().AddItems(new List <Personnel>(Kernel.Current.Sql.QueryWhere <Personnel>("PositionID=" + id.ID))); } else { Kernel.Current.Desktop.OpenNew <SearchResultForm>(); } input.text = string.Empty; return; } input.text = string.Empty; NullWarmDialog(); }); }