Ejemplo n.º 1
0
        public UserViewModel()
        {
            _querytablecallbackdelegate = new QueryTableCallBackDelegate(QueryTableCallBack);
            _addtablecallbackdelegate   = new AddTableCallBackDelegate(AddTableCallBack);
            _excutesqlCallBackDelegate  = new ExcutesqlCallBackDelegate(ExcutesqlCallBack);

            AddCommand     = new DelegateCommand <object>(Add);
            DeleteCommand  = new DelegateCommand <object>(Delete);
            ModifyCommand  = new DelegateCommand <object>(Modify);
            OperateCommand = new DelegateCommand <object>(Operate);
            QueryCommand   = new DelegateCommand <object>(QueryYongHuguanli);

            FirstPageCommand = new DelegateCommand <object>(FirstPage);
            PrePageCommand   = new DelegateCommand <object>(PrePage);
            NextPageCommand  = new DelegateCommand <object>(NextPage);
            GotoPageCommand  = new DelegateCommand <object>(GotoPage);


            _tableList   = new ObservableCollection <GUANLIYUANModel>();
            _customInfo  = new GUANLIYUANModel();
            _customInfo1 = new GUANLIYUANModel();
            _customInfo1.Youxiaoqikaishi = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd HH:mm:ss");
            _customInfo1.Youxiaoqijieshu = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd HH:mm:ss");

            _pagePercent = "0/0";
        }
Ejemplo n.º 2
0
 private void Add(object obj)
 {
     operateenum = OperateEnum.OperateEnum_Add;
     customInfo1 = new GUANLIYUANModel();
 }
Ejemplo n.º 3
0
        public void QueryTableCallBack(string resultStr, string errorStr)
        {
            Type type = typeof(GUANLIYUANModel);

            if (type == null)
            {
                return;
            }

            System.Reflection.PropertyInfo[] properties = type.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);

            string[] rows = resultStr.Split(';');
            foreach (string row in rows)
            {
                if (row.Length > 0)
                {
                    var model = Activator.CreateInstance(type);

                    string[] cells = row.Split(',');
                    foreach (string cell in cells)
                    {
                        string[] keyvalue = cell.Split(':');
                        if (keyvalue.Length != 2 || keyvalue[1] == null || keyvalue[1].Length == 0)
                        {
                            continue;
                        }

                        foreach (System.Reflection.PropertyInfo item in properties)
                        {
                            if (item.Name == keyvalue[0])
                            {
                                if (item.PropertyType.Name.StartsWith("Int32"))
                                {
                                    item.SetValue(model, Convert.ToInt32(keyvalue[1]), null);
                                }
                                else if (item.PropertyType.Name.StartsWith("Int64"))
                                {
                                    item.SetValue(model, Convert.ToInt64(keyvalue[1]), null);
                                }
                                else if (item.PropertyType.Name.StartsWith("String"))
                                {
                                    switch (item.Name)
                                    {
                                    case "Chengshibianhao":
                                    case "Jubianhao":
                                    case "Shiyongdanweibianhao":
                                    case "Shebeibaifangweizhi":
                                    case "Qianzhuzhonglei":
                                    case "ZhikaZhuangtai":
                                    case "Zhengjianleixing":
                                    case "Xingbie":
                                    case "Yewuleixing":
                                        if (MainWindowViewModel._yingshelList.Keys.Contains(Convert.ToInt32(keyvalue[1])))
                                        {
                                            item.SetValue(model, MainWindowViewModel._yingshelList[Convert.ToInt32(keyvalue[1])], null);
                                        }
                                        break;

                                    case "Riqi":
                                    case "Chushengriqi":
                                    case "Jiaoyiriqi":
                                    case "Youxiaoqikaishi":
                                    case "Youxiaoqijieshu":
                                        DateTime datetime = Common.ConvertIntDateTime(Convert.ToInt64(keyvalue[1]));
                                        item.SetValue(model, datetime.ToString("yyyy-MM-dd HH:mm:ss"), null);
                                        break;

                                    case "IP":
                                        item.SetValue(model, Common.IntToIp(IPAddress.NetworkToHostOrder((Int32)Convert.ToInt64(keyvalue[1]))), null);
                                        break;

                                    default:
                                        item.SetValue(model, keyvalue[1], null);
                                        break;
                                    }
                                }
                                else if (item.PropertyType.Name.StartsWith("Boolean"))
                                {
                                    item.SetValue(model, Convert.ToBoolean(Convert.ToInt32(keyvalue[1])), null);
                                }
                                else
                                {
                                    ;
                                }
                                break;
                            }
                        }
                    }

                    GUANLIYUANModel modelTemp = model as GUANLIYUANModel;

                    modelTemp.operateinfomodel.operatemodel = OperateModelEnum.OperateModel_UserModify;
                    _tableListTemp.Add(modelTemp);

                    _guliyuanList[modelTemp.Yonghuming] = modelTemp;
                }
            }

            Application.Current.Dispatcher.Invoke(
                new Action(() =>
            {
                ShowPage(1);
            }));
        }