예제 #1
0
        private void dgrd_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            lblErr.Text      = "";
            lblErr.ForeColor = Color.Blue;
            if (e.RowIndex >= 0 && e.ColumnIndex == 0)
            {
                ham.ID_HistoryAttendance   = Convert.ToInt32(dgrd.Rows[e.RowIndex].Cells[2].Value.ToString());
                txtBlockAdd.Text           = dgrd.Rows[e.RowIndex].Cells[3].Value.ToString();
                txtUserNameAdd.Text        = dgrd.Rows[e.RowIndex].Cells[4].Value.ToString();
                ddlDeptAdd.SelectedValue   = dgrd.Rows[e.RowIndex].Cells[5].Value.ToString();
                ddlClass.SelectedValue     = dgrd.Rows[e.RowIndex].Cells[6].Value.ToString();
                ddlTimerIntervalAdd.Text   = dgrd.Rows[e.RowIndex].Cells[8].Value.ToString();
                dtpBeginTimeAdd.Value      = Convert.ToDateTime(dgrd.Rows[e.RowIndex].Cells[9].Value.ToString());
                dtpEndTimeAdd.Value        = Convert.ToDateTime(dgrd.Rows[e.RowIndex].Cells[10].Value.ToString());
                dtpDataAttendanceAdd.Value = Convert.ToDateTime(dgrd.Rows[e.RowIndex].Cells[13].Value.ToString());
                ShowOrHidden(true);
                btnModifyAndAdd.CaptionTitle = "修 改";
            }
            if (e.RowIndex >= 0 && e.ColumnIndex == 1)
            {
                if (MessageBox.Show("你确定要删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    //存入日志
                    LogSave.Messages("[AddHistoryAttendance]", LogIDType.UserLogID, "删除历史补单,部门编号为:"
                                     + dgrd.Rows[e.RowIndex].Cells[5].Value.ToString()
                                     + ",发码器编号:" + dgrd.Rows[e.RowIndex].Cells[3].Value.ToString() + ",员工姓名:" + dgrd.Rows[e.RowIndex].Cells[4].Value.ToString()
                                     + ",上班时间:" + dgrd.Rows[e.RowIndex].Cells[9].Value.ToString() + "。");

                    aBLL.DeleteHistoryAttendance(Convert.ToInt32(dgrd.Rows[e.RowIndex].Cells[2].Value.ToString()), out strErr);
                    lblErr.Text = "删除成功!";


                    if (!New_DBAcess.IsDouble)
                    {
                        BindDataDataGridView();
                    }
                    else
                    {
                        timer1.Start();
                    }
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            bool   isDeleteflag = true;
            string strErr       = "";

            if (dgrd.Rows.Count > 0)
            {
                for (int j = 0; j < dgrd.Rows.Count; j++)
                {
                    if (((DataGridViewCheckBoxCell)dgrd.Rows[j].Cells[0]).Value == ((DataGridViewCheckBoxCell)dgrd.Rows[j].Cells[0]).TrueValue)
                    {
                        isDeleteflag = false;
                        aBLL.DeleteHistoryAttendance(Int64.Parse(dgrd.Rows[j].Cells[1].Value.ToString()), int.Parse(dgrd.Rows[j].Cells[2].Value.ToString()), "", DateTime.Parse(dgrd.Rows[j].Cells["dataAttendance"].Value.ToString()), out strErr);

                        RefreshBackUp();
                    }
                }
                if (isDeleteflag)
                {
                    MessageBox.Show("没有选择要删除的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }