示例#1
0
        /// <summary>
        /// 数据区点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string          action = dataGridView.Columns[e.ColumnIndex].Name; //操作类型
                        var cells  = dataGridView.Rows[e.RowIndex].Cells;      //当前行所有列的数据

            if (action.Equals("_Update"))
            {
                if (MessageBox.Show("确定修改这行数据吗?", "修改提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    Tb_YZSY yZSY = new Tb_YZSY()
                    {
                        Id         = Convert.ToInt32(cells["_Id"].Value),
                        MDirection = Convert.ToString(cells["_MDirection"].Value),
                        WDirection = Convert.ToString(cells["_WDirection"].Value),
                        DescribeZ  = Convert.ToString(cells["_DescribeZ"].Value),
                        CDirection = Convert.ToString(cells["_CDirection"].Value),
                        DescribeF  = Convert.ToString(cells["_DescribeF"].Value),
                    };
                    List <Tb_YZSY> yZSies = new List <Tb_YZSY>();
                    yZSies.Add(yZSY);
                    DbBaseResult baseResult = YzsyManament.GetInstance().UpdateYzsys(yZSies) as DbBaseResult;
                    if (baseResult == null)
                    {
                        MessageBox.Show("修改失败!");
                    }
                    else
                    {
                        MessageBox.Show($"修改结果:成功{baseResult.SuccessNum}个,总共{baseResult.TotalNum}个!");
                        RefreshYzsyList(Convert.ToInt32(this.comboBox4.SelectedItem.ToString()), currentIndex);
                    }
                }
            }
            if (action.Equals("_Delete"))
            {
                if (MessageBox.Show("确定删除这行数据吗?", "删除提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    var          _id        = cells["_Id"].Value;
                    string[]     idArray    = new string[] { $"{_id}" };
                    DbBaseResult baseResult = YzsyManament.GetInstance().DeleteYzsys(idArray) as DbBaseResult;
                    if (baseResult == null)
                    {
                        MessageBox.Show("删除失败!");
                    }
                    else
                    {
                        MessageBox.Show($"删除结果:成功{baseResult.SuccessNum}个,总共{baseResult.TotalNum}个!");
                        RefreshYzsyList(Convert.ToInt32(this.comboBox4.SelectedItem.ToString()), currentIndex);
                    }
                }
            }
        }
示例#2
0
        private void ComboBoxZ_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectParam selectParam = new SelectParam()
            {
                MDirection = this.comboBox1.SelectedItem.ToString(),
                WDirection = this.comboBox2.SelectedItem.ToString(),
                CDirection = this.comboBox3.SelectedItem.ToString(),
            };
            Tb_YZSY obj = YzsyManament.GetInstance().SelectYzsy(selectParam) as Tb_YZSY;

            if (obj != null)
            {
                this.textBox1.Text = obj.DescribeZ;
                this.textBox2.Text = obj.DescribeF;
            }
            else
            {
                this.textBox1.Text = string.Empty;
                this.textBox2.Text = string.Empty;
            }
        }