Ejemplo n.º 1
0
        //点击添加按钮
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FrmLeaveAddOrUpdate leave = new FrmLeaveAddOrUpdate(this.Tag.ToString());

            leave.ShowDialog();
            if (leave.DialogResult == DialogResult.OK)
            {
                //添加完刷新
                QueryAll(this.Tag.ToString());
            }
        }
Ejemplo n.º 2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = e.RowIndex;

            if (e.ColumnIndex == 0 && e.RowIndex > -1)//删除按钮操作
            {
                int leaveId = Convert.ToInt32(dataGridView1.Rows[row].Cells["编号"].Value.ToString());
                var result  = MessageBox.Show("删除后不可恢复,继续?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.OK)
                {
                    bool b = new LeaveBll().DeleteById(leaveId);
                    if (b)
                    {
                        MessageBox.Show("删除成功!");
                        QueryAll(this.Tag.ToString());
                        return;
                    }
                    return;
                }
            }
            if (e.ColumnIndex == 1 && e.RowIndex > -1)//更新按钮操作
            {
                Leave le = new Leave();
                le.Id            = Convert.ToInt32(dataGridView1.Rows[row].Cells["编号"].Value.ToString());;
                le.EmployeeId    = dataGridView1.Rows[row].Cells["员工号"].Value.ToString();
                le.DateTimeStart = Convert.ToDateTime(dataGridView1.Rows[row].Cells["开始时间"].Value.ToString());
                le.DateTimeEnd   = Convert.ToDateTime(dataGridView1.Rows[row].Cells["结束时间"].Value.ToString());
                le.Duration      = (float)Convert.ToDouble(dataGridView1.Rows[row].Cells["时长"].Value.ToString());
                le.Status        = dataGridView1.Rows[row].Cells["状态"].Value.ToString();
                le.Reason        = dataGridView1.Rows[row].Cells["原因"].Value.ToString();
                FrmLeaveAddOrUpdate leave = new FrmLeaveAddOrUpdate(le);
                leave.ShowDialog();
                if (leave.DialogResult == DialogResult.OK)
                {
                    QueryAll(this.Tag.ToString());
                }
            }
        }