#region 单击单元格
        private void dataGridView_main_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dataGridView_main.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex > -1)
                {
                    if (this.dataGridView_main.CurrentCell.FormattedValue.ToString() == "编辑")
                    {
                        DlgUnitEdit dlgunt = new DlgUnitEdit();
                        //获得当前选中的行   
                        int rowindex = e.RowIndex;
                        //获得选中行中列名为"Column_pe_unit_id"的值
                        int unitid = Convert.ToInt32(dataGridView_main.Rows[rowindex].Cells["Column_pe_unit_id"].Value);
                        dlgunt.unit_Id = unitid;
                        //显示对话框
                        if (DialogResult.OK == dlgunt.ShowDialog())
                        {
                            Init();
                        }
                    }
                    else if (this.dataGridView_main.CurrentCell.FormattedValue.ToString() == "删除")
                    {
                        string sMsg = String.Format("确定要删除吗?");
                        if (MessageBox.Show(sMsg, "确认删除体检单位", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            //获得当前选中的行   
                            int rowindex = e.RowIndex;
                            //获得选中行中列名为"Column_pe_unit_id"的值
                            int unitid = Convert.ToInt32(dataGridView_main.Rows[rowindex].Cells["Column_pe_unit_id"].Value);
                            WebResult<bool> result = PeBookingMgr.DelPeUnit(new pe_unit() { pe_unit_id = unitid });
                            if (WebResultCode.CALL_SUCCESS.REquals(result.code) && result.data)
                            {
                                MessageBox.Show("删除成功!");
                                Init();
                            }
                            else
                            {
                                MessageBox.Show("删除失败!");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "分诊工作站", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        } 
        #endregion

 

posted on 2018-10-08 10:18  蒙蒙浮霁月  阅读(5996)  评论(0编辑  收藏  举报