Пример #1
0
        public frmGameSetting(Game_Setting obj)
        {
            try { InitializeComponent();
                  Init();
                  this.game_Setting            = obj;
                  this.txtUrl.Text             = obj.Url;
                  this.txtUserName.Text        = obj.UserName;
                  this.txtPassWord.Text        = obj.PassWord;
                  this.txtRemark.Text          = obj.ReMark;
                  this.cbTryType.SelectedIndex = this.cbTryType.FindString(obj.TryType.ToString());
                  this.cbDevices.SelectedIndex = this.cbDevices.FindString(obj.Devices.ToString());
                  this.swbtnIsCompleted.Value  = obj.IsCompleted;


                  //超出控件的范围处理
                  if (obj.DeadLine < DateTimePicker.MinimumDateTime || obj.DeadLine > DateTimePicker.MaximumDateTime)
                  {
                  }
                  else
                  {
                      this.dpDeadLine.Value = obj.DeadLine;
                  }
                  this.Text = "修改"; }

            catch (Exception ex)
            {
                MessageBox.Show("系统发生异常,请联系管理员!", "错误");
                LogHelper.WriteLog("窗体异常", ex);
            }
        }
        public async Task <ActionResult <Game_Setting> > PostGame_Settings(Game_Setting game_Setting)
        {
            _context.Game_Settings.Add(game_Setting);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGame_Settings", new { id = game_Setting.Id }, game_Setting));
        }
        private void btnEdit_Click()
        {
            try {
                string[] str = new string[dataGridView1.Rows.Count];
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    if (dataGridView1.Rows[i].Selected == true)
                    {
                        Game_Setting game_SettingObject = new Game_Setting();
                        game_SettingObject.Id          = Convert.ToInt64(dataGridView1.Rows[i].Cells[0].Value);
                        game_SettingObject.Url         = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value);
                        game_SettingObject.UserName    = Convert.ToString(dataGridView1.Rows[i].Cells[2].Value);
                        game_SettingObject.PassWord    = Convert.ToString(dataGridView1.Rows[i].Cells[3].Value);
                        game_SettingObject.ReMark      = Convert.ToString(dataGridView1.Rows[i].Cells[4].Value);
                        game_SettingObject.CreateDate  = Convert.ToDateTime(dataGridView1.Rows[i].Cells[5].Value);
                        game_SettingObject.DeadLine    = Convert.ToDateTime(dataGridView1.Rows[i].Cells[6].Value);
                        game_SettingObject.TryType     = (TryTypeEnum)Enum.Parse(typeof(TryTypeEnum), dataGridView1.Rows[i].Cells[7].Value.ToString(), false);
                        game_SettingObject.Devices     = (DevicesEnum)Enum.Parse(typeof(DevicesEnum), dataGridView1.Rows[i].Cells[8].Value.ToString(), false);
                        game_SettingObject.IsCompleted = Convert.ToBoolean(dataGridView1.Rows[i].Cells[9].Value);


                        frmGameSetting f1 = new frmGameSetting(game_SettingObject); //实例化窗体
                        this.Visible = false;                                       //设置当前窗体为不可视
                        f1.ShowDialog();                                            //打开窗体f1
                        this.Visible = true;
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("系统发生异常,请联系管理员!", "错误");
                LogHelper.WriteLog("窗体异常", ex);
            }
        }
        public async Task <IActionResult> PutGame_Settings(long id, Game_Setting game_Setting)
        {
            if (id != game_Setting.Id)
            {
                return(BadRequest());
            }

            _context.Entry(game_Setting).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Game_SettingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #5
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (game_Setting.Id > 0)
                {//编辑
                    if (string.IsNullOrEmpty(this.txtUrl.Text))
                    {
                        MessageBox.Show("请填写必填项!", "警告");
                        this.txtUrl.Focus();
                        return;
                    }
                    if (string.IsNullOrEmpty(this.txtUserName.Text))
                    {
                        MessageBox.Show("请填写必填项!", "警告");
                        this.txtUserName.Focus();
                        return;
                    }
                    if (string.IsNullOrEmpty(this.txtPassWord.Text))
                    {
                        MessageBox.Show("请填写必填项!", "警告");
                        this.txtPassWord.Focus();
                        return;
                    }

                    if (string.IsNullOrEmpty(this.txtRemark.Text))
                    {
                        MessageBox.Show("请填写必填项!", "警告");
                        this.txtRemark.Focus();
                        return;
                    }
                    game_Setting.Url         = this.txtUrl.Text;
                    game_Setting.UserName    = this.txtUserName.Text;
                    game_Setting.PassWord    = this.txtPassWord.Text;
                    game_Setting.ReMark      = this.txtRemark.Text;
                    game_Setting.DeadLine    = this.dpDeadLine.Value;
                    game_Setting.TryType     = (TryTypeEnum)Enum.Parse(typeof(TryTypeEnum), this.cbTryType.SelectedItem.ToString(), false);
                    game_Setting.Devices     = (DevicesEnum)Enum.Parse(typeof(DevicesEnum), this.cbDevices.SelectedItem.ToString(), false);
                    game_Setting.IsCompleted = this.swbtnIsCompleted.Value;
                    game_Setting.UsersId     = LoginInfo.CurrentUser.ID;

                    string jsonbody  = JsonConvert.SerializeObject(game_Setting);
                    string url       = "/Game_Settings/" + game_Setting.Id;
                    bool   isSuccess = HttpClientUtil.doPutMethodToObj(url, jsonbody);
                    if (isSuccess)
                    {
                        MessageBox.Show("修改成功!", "信息");
                        ClearControl();
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(this.txtUrl.Text))
                    {
                        MessageBox.Show("请填写必填项!", "警告");
                        this.txtUrl.Focus();
                        return;
                    }
                    if (string.IsNullOrEmpty(this.txtUserName.Text))
                    {
                        MessageBox.Show("请填写必填项!", "警告");
                        this.txtUserName.Focus();
                        return;
                    }
                    if (string.IsNullOrEmpty(this.txtPassWord.Text))
                    {
                        MessageBox.Show("请填写必填项!", "警告");
                        this.txtPassWord.Focus();
                        return;
                    }

                    if (string.IsNullOrEmpty(this.txtRemark.Text))
                    {
                        MessageBox.Show("请填写必填项!", "警告");
                        this.txtRemark.Focus();
                        return;
                    }
                    string       url = "/Game_Settings";
                    Game_Setting game_SettingInput = new Game_Setting();
                    game_SettingInput.Url         = this.txtUrl.Text;
                    game_SettingInput.UserName    = this.txtUserName.Text;
                    game_SettingInput.PassWord    = this.txtPassWord.Text;
                    game_SettingInput.ReMark      = this.txtRemark.Text;
                    game_SettingInput.CreateDate  = DateTime.Now;
                    game_SettingInput.DeadLine    = this.dpDeadLine.Value;
                    game_SettingInput.TryType     = (TryTypeEnum)Enum.Parse(typeof(TryTypeEnum), this.cbTryType.SelectedItem.ToString(), false);
                    game_SettingInput.Devices     = (DevicesEnum)Enum.Parse(typeof(DevicesEnum), this.cbDevices.SelectedItem.ToString(), false);
                    game_SettingInput.IsCompleted = this.swbtnIsCompleted.Value;
                    game_SettingInput.UsersId     = LoginInfo.CurrentUser.ID;
                    string jsonbody = JsonConvert.SerializeObject(game_SettingInput);

                    //string jsonbody = "{\"Name\":\"" + this.txtUserName.Text + "\",\"ReMark\":\"" + this.txtRemark.Text + "\"}";
                    Game_Setting game_Setting = HttpClientUtil.doPostMethodToObj <Game_Setting>(url, jsonbody);
                    if (game_Setting != null && game_Setting.UserName != null)
                    {
                        MessageBox.Show("添加成功!", "信息");
                        ClearControl();
                    }
                    else
                    {
                        MessageBox.Show("添加失败!", "信息");
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("系统发生异常,请联系管理员!", "错误");
                LogHelper.WriteLog("窗体异常", ex);
            }
        }