/// <summary> /// 窗体数据初始化 /// </summary> private void formInit() { dataGridView1.AutoGenerateColumns = false; GSSBLL.GameConfig bll = new GSSBLL.GameConfig(); DataSet ds = bll.GetAllList(); dataGridView1.DataSource = ds.Tables[0]; }
/// <summary> /// 保存数据 /// </summary> private void SaveData() { //验证数据项 string msg = CheckData(); if (msg.Length > 0) { MessageBox.Show(msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //数据准备 GSSModel.GameConfig model = new GSSModel.GameConfig(); model.F_ID = Convert.ToInt32(f_IDTextBox.Text); model.F_Name = f_NameTextBox.Text; model.F_ValueGame = f_ValueGamerichTextBox.Text; model.F_ParentID = Convert.ToInt32(f_ParentIDTextBox.Text); model.F_Value = f_ValueTextBox.Text; model.F_Value1 = f_Value1TextBox.Text; model.F_Sort = Convert.ToInt32(f_SortTextBox.Text); model.F_IsUsed = f_IsUsedCheckBox.Checked; //数据提交 GSSBLL.GameConfig bll = new GSSBLL.GameConfig(); bool isok = false; //检测是否已经存在 if (_id > 0) { isok = bll.Update(model); } else { if (model.F_ID == 0) { MessageBox.Show(LanguageResource.Language.Tip_IDShouldGatherThan0); return; } isok = bll.Add(model); } if (isok) { MessageBox.Show("数据保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("数据保存失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void toolStripButtonDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要删除选中的数据吗?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return; } int iSelectRowCount = dataGridView1.SelectedRows.Count; //判断是否选择了行 if (iSelectRowCount > 0) { //循环删除行 foreach (DataGridViewRow dgvRow in dataGridView1.SelectedRows) { GSSBLL.GameConfig bll = new GSSBLL.GameConfig(); if (bll.Delete(Convert.ToInt32(dgvRow.Cells[0].Value))) { dataGridView1.Rows.Remove(dgvRow); } } } }
/// <summary> /// 初始化窗体 /// </summary> private void InitForm() { if (_id > 0) { this.Text = "游戏配置修改"; f_IDTextBox.Enabled = true; if (_id > 0) { f_IDTextBox.Enabled = false; } GSSBLL.GameConfig bll = new GSSBLL.GameConfig(); GSSModel.GameConfig model = bll.GetModel(_id); f_IDTextBox.Text = model.F_ID.ToString(); f_ParentIDTextBox.Text = model.F_ParentID.ToString(); f_NameTextBox.Text = model.F_Name; f_ValueTextBox.Text = model.F_Value; f_Value1TextBox.Text = model.F_Value1; f_ValueGamerichTextBox.Text = model.F_ValueGame; f_SortTextBox.Text = model.F_Sort.ToString(); f_IsUsedCheckBox.Checked = model.F_IsUsed; } }