Exemple #1
0
        private void StartSetUser_Load(object sender, EventArgs e)
        {
            DT_SimpleUser = new DataTable();
            DT_SimpleUser.Columns.Add("Account", typeof(string));
            DT_SimpleUser.Columns.Add("Password", typeof(string));
            DT_SimpleUser.Columns.Add("RealName", typeof(string));
            DT_SimpleUser.Columns.Add("UsrType", typeof(int));
            //如果在配置测评时就显示下一步
            if (StartAppraisal.SumScore != 0)
            {
                Btn_Next.Visible   = true;
                Btn_back.Visible   = true;
                Btn_Delete.Visible = true;
                BTN_OK.Visible     = false;
            }
            else//否则显示完成
            {
                Btn_Next.Visible   = false;
                Btn_back.Visible   = false;
                Btn_Delete.Visible = true;
                BTN_OK.Visible     = true;
                string url     = Form1.UrlPre + "ShowAllUser" + "?entrance=" + LogIn.entrance;
                string Httpres = HttpGet.HttpGetFunc(url);
                if (Httpres == null)
                {
                    MessageBox.Show("网络未连接");
                    return;
                }

                //将字符串转换成json
                var Httpjsonresult = JObject.Parse(Httpres);
                //获取json中的data部分
                JToken HttpJsonvalue = Httpjsonresult.GetValue("data");
                int    resultrow     = HttpJsonvalue.Count();

                for (int i = 0; i < resultrow; i++)
                {
                    int           column        = HttpJsonvalue[i].Count();
                    var           s             = HttpJsonvalue[i].ToString();
                    userInfoDatum userInfodatum = JsonConvert.DeserializeObject <userInfoDatum>(s);
                    DataRow       dr            = DT_SimpleUser.NewRow();
                    dr["Account"]  = userInfodatum.Account;
                    dr["Password"] = userInfodatum.Password;
                    dr["RealName"] = userInfodatum.RealName;
                    dr["UsrType"]  = userInfodatum.Type;

                    DT_SimpleUser.Rows.Add(dr);
                }
            }

            //DataGridViewComboBoxColumn myCombo = new DataGridViewComboBoxColumn();
            //myCombo.DataSource = new UsrTypeE[] { UsrTypeE.系统管理员, UsrTypeE.测评带队, UsrTypeE.测评成员 };
            //myCombo.HeaderText = "账号类型";
            //myCombo.Name = "UserType";

            //myCombo.ValueType = typeof(UsrTypeE);
            //myCombo.DataPropertyName = "UsrTypeE";
            //Dgv_SimpleUser.Columns.Add(myCombo);
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string userName = TB_UserName.Text;
            string passWord = TB_PassWord.Text;

            entrance = CB_AppType.Text;
            string url     = Form1.UrlPre + "Oblogin?account=" + userName + "&password="******"&entrance=" + entrance + "&districtCode=0";
            string Httpres = HttpGet.HttpGetFunc(url);

            if (Httpres == null)
            {
                MessageBox.Show("网络未连接");
                this.Close();
                System.Environment.Exit(0);
            }
            //将字符串转换成json
            var Httpjsonresult = JObject.Parse(Httpres);
            //获取json中的data部分
            JToken HttpJsonvalue = Httpjsonresult.GetValue("errorMsg");
            string ErrorMsg      = HttpJsonvalue.ToString();

            string[] accountContent = { userName, passWord, entrance };
            if (ErrorMsg != "成功")
            {
                MessageBox.Show(ErrorMsg);
            }
            else
            {
                //FileStream file = new FileStream(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName+"/countsave.txt",FileMode.OpenOrCreate);

                try
                {
                    if (File.Exists(CountSave_Path))
                    {
                    }
                    else
                    {
                        File.Create(CountSave_Path);
                    }
                    File.WriteAllLines(CountSave_Path, accountContent);
                }
                catch { }


                HttpJsonvalue = Httpjsonresult.GetValue("data");

                userinfosDatum = JsonConvert.DeserializeObject <userInfoDatum>(HttpJsonvalue.ToString());

                if (userinfosDatum == null)
                {
                    userinfosDatum      = new userInfoDatum();
                    userinfosDatum.Type = 0;
                }
                this.DialogResult = DialogResult.OK;
                this.Dispose();
                this.Close();
                //this.Hide();
            }
        }
Exemple #3
0
        private void iniChangeUserPermission()
        {
            userInfoDatas.Clear();
            dgv_user.Rows.Clear();
            CLB_Districts.Items.Clear();
            string url     = Form1.UrlPre + "ShowAllUser" + "?entrance=" + LogIn.entrance;
            string Httpres = HttpGet.HttpGetFunc(url);

            if (Httpres == null)
            {
                MessageBox.Show("网络未连接");
                return;
            }
            //将字符串转换成json
            var Httpjsonresult = JObject.Parse(Httpres);
            //获取json中的data部分
            JToken HttpJsonvalue = Httpjsonresult.GetValue("data");
            int    resultrow     = HttpJsonvalue.Count();

            for (int i = 0; i < resultrow; i++)
            {
                int           column         = HttpJsonvalue[i].Count();
                var           s              = HttpJsonvalue[i].ToString();
                userInfoDatum userinfosDatum = JsonConvert.DeserializeObject <userInfoDatum>(s);
                userInfoDatas.Add(userinfosDatum);
                dgv_user.Rows.Add(userinfosDatum.Account, userinfosDatum.RealName, userinfosDatum.Type);
            }


            //获取所有县/区
            //ShowAlldistrict
            url     = Form1.UrlPre + "ShowAlldistrict" + "?entrance=" + LogIn.entrance;
            Httpres = HttpGet.HttpGetFunc(url);
            if (Httpres == null)
            {
                MessageBox.Show("网络未连接");
                return;
            }
            //将字符串转换成json
            Httpjsonresult = JObject.Parse(Httpres);
            //获取json中的data部分
            HttpJsonvalue = Httpjsonresult.GetValue("data");
            resultrow     = HttpJsonvalue.Count();

            for (int i = 0; i < resultrow; i++)
            {
                int column = HttpJsonvalue[i].Count();
                var s      = HttpJsonvalue[i].ToString();
                DistrictInfoDatum districtInfoDatums = JsonConvert.DeserializeObject <DistrictInfoDatum>(s);
                districtInfoDatas.Add(districtInfoDatums);
                CLB_Districts.Items.Add(districtInfoDatums.DistrictName);
            }
            CurAccount = userInfoDatas[0].Account;
            setClbStatus(CurAccount);
        }