示例#1
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            bool blnvalue = false;

            if (this.dataGridView1.Rows.Count == 1)
            {
                if (this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells[3].Value.ToString() == "單一主機")
                {
                    MessageBox.Show("單一主機只有一條記錄,不能再新增!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    blnvalue = true;
                }
            }
            if (blnvalue)
            {
                return;
            }
            frmLabelNoDbEdit f = new frmLabelNoDbEdit(IntFlag);
            if (this.dataGridView1.Rows.Count == 0)
                f.blnCanEdit = true;
            else
                f.blnCanEdit = false;
            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                SetBtnEnabled("");
        }
示例#2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string KeyValue = this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells[2].Value.ToString();
            if (KeyValue == "")
                return;
            if (e.ColumnIndex == 0)
            {
                frmLabelNoDbView f = new frmLabelNoDbView(IntFlag, KeyValue);

                f.ShowDialog();
                SetBtnEnabled("");
            }
            else if (e.ColumnIndex == 1)
            {
                if (this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells["Column13"].Value.ToString().Trim().Length > 0)
                {
                    MessageBox.Show("已被覆核,不可編輯!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                frmLabelNoDbEdit f = new frmLabelNoDbEdit(IntFlag, KeyValue);
                if (this.dataGridView1.Rows.Count == 1)
                {
                    f.blnCanEdit = true;
                }
                else
                {
                    f.blnCanEdit = false;
                }
                if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    SetBtnEnabled("");
            }
        }