private void btnSave_Click(object sender, EventArgs e)
        {
            lblErr.Text = "";

            if (cmbDept.SelectedValue == null || cmbDept.Text.Equals("无"))
            {
                lblErr.ForeColor = Color.Red;
                lblErr.Text      = "请选择部门!";
                return;
            }

            if (cmbEmpName.SelectedValue == null || cmbEmpName.Text.Equals("无"))
            {
                lblErr.ForeColor = Color.Red;
                lblErr.Text      = "请选择姓名!";
                return;
            }
            if (this.txtCodeSenderAddress.Text.Trim() == "")
            {
                lblErr.ForeColor = Color.Red;
                lblErr.Text      = "标识卡号不能为空!";
                return;
            }
            if (this.ddlClassAdd.Items.Count == 0)
            {
                lblErr.ForeColor = Color.Red;
                lblErr.Text      = "没有班制,无法进行下一步的操作!";
                return;
            }

            if (ddlTimerIntervalAdd.Items.Count == 0)
            {
                lblErr.ForeColor = Color.Red;
                lblErr.Text      = "没有时段,无法进行下一步的操作!!";
                return;
            }
            if (dtpBeginTimeAdd.Value > dtpEndTimeAdd.Value)
            {
                lblErr.ForeColor = Color.Red;
                lblErr.Text      = "上班时间不能大于下班时间!";
                return;
            }
            if (dtpEndTimeAdd.Value > DateTime.Now)
            {
                lblErr.ForeColor = Color.Red;
                lblErr.Text      = "下班时间不能大于当前时间!";
                return;
            }
            if (dtpBeginTimeAdd.Value.AddMinutes(30) > dtpEndTimeAdd.Value)
            {
                lblErr.ForeColor = Color.Red;
                lblErr.Text      = "上班时间要比下班时间提前30分钟!";
                return;
            }

            ham.ID_HistoryAttendance = Convert.ToInt64(Afr._id);
            ham.BlockID         = Convert.ToInt32(txtCodeSenderAddress.Text.Trim());
            ham.EmployeeID      = int.Parse(cmbEmpName.SelectedValue.ToString());
            ham.EmployeeName    = cmbEmpName.Text;
            ham.DeptID          = Convert.ToInt32(cmbDept.SelectedValue.ToString());
            ham.ClassID         = Convert.ToInt32(ddlClassAdd.SelectedValue.ToString());
            ham.TimerIntervalID = Convert.ToInt32(ddlTimerIntervalAdd.SelectedValue.ToString());
            ham.ClassShortName  = ddlTimerIntervalAdd.Text.Trim();
            ham.BeginWorkTime   = dtpBeginTimeAdd.Value.ToString();
            ham.EndWorkTime     = dtpEndTimeAdd.Value.ToString();
            ham.DataAttendance  = dtpDataAttendanceAdd.Value.ToString("yyyy-MM-dd");
            ham.Remark          = txtRemarkAdd.Text.Trim();
            ham.OperatorID      = 0;
            if (Afr._isAdd)
            {
                if (MessageBox.Show("是否同意添加数据,添加后将不能修改、删除", "确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    // aBLL.AddEmployeeAttendanceHistory(ham, dtpDataAttendanceAdd.Value.ToString("yyyyM"), out strErr);
                    //Czlt-2010-11-03 - 判断当日补单中有没有重复班次
                    if (IsExists(ham))
                    {
                        MessageBox.Show("员工 " + ham.EmployeeName + " " + ham.DataAttendance + "日 " + ham.ClassShortName + "班次的信息已经存在\n\n           不能进行历史补单操作!", "提示", MessageBoxButtons.OK);
                        return;
                    }

                    //Czlt-2010-11-03 - 向考勤表里面插入一条记录
                    aBLL.AddEmployeeAttendanceHistory(ham, dtpDataAttendanceAdd.Value.ToString("yyyyM"), out strErr);

                    //Czlt-2010-11-03 - 向历史进出分站表里面插入一条上下班记录
                    AddHisInOutStation(ham);


                    if (strErr == "Succeeds")
                    {
                        //获取统计表中该卡的信息
                        DataSet dsKqtj = aBLL.GetKQTJbyCards(txtCodeSenderAddress.Text.Trim(), dtpDataAttendanceAdd.Value, out strErr);


                        if (strErr.Equals("Succeeds"))
                        {
                            //插入信息
                            if (dsKqtj.Tables.Count > 0 && dsKqtj.Tables[0].Rows.Count > 0)
                            {
                            }
                            else
                            {
                                aBLL.AddKQTJ(dtpDataAttendanceAdd.Value, ham.BlockID, ham.EmployeeName, ham.DeptID, cmbDept.Text, out strErr);
                            }

                            aBLL.UpdateKQTJ(dtpDataAttendanceAdd.Value, ham.BlockID, ham.ClassShortName, ham.DeptID, cmbDept.Text, out strErr);

                            //存入日志
                            LogSave.Messages("[AddHistoryAttendance]", LogIDType.UserLogID, "添加历史补单,部门编号为:"
                                             + ham.DeptID.ToString() + ",发码器编号:" + ham.BlockID.ToString() + ",员工姓名:" + ham.EmployeeName
                                             + ",上班时间:" + ham.BeginWorkTime + "。");


                            lblErr.ForeColor = Color.Black;
                            lblErr.Text      = "保存成功!";
                            Afr.RefreshBackUp();
                        }
                        else
                        {
                            lblErr.ForeColor = Color.Red;
                            lblErr.Text      = "保存失败!";
                        }
                    }
                    else
                    {
                        lblErr.ForeColor = Color.Red;
                        lblErr.Text      = "保存失败!";
                    }
                }
            }
            else
            {
                aBLL.UpdateEmployeeAttendanceHistory(ham, out strErr);
                if (strErr == "Succeeds")
                {
                    //存入日志
                    LogSave.Messages("[AddHistoryAttendance]", LogIDType.UserLogID, "修改历史补单,部门编号为:"
                                     + ham.DeptID.ToString() + ",发码器编号:" + ham.BlockID.ToString() + ",员工姓名:" + ham.EmployeeName
                                     + ",上班时间:" + ham.BeginWorkTime + "。");

                    lblErr.ForeColor = Color.Black;
                    lblErr.Text      = "修改成功!";
                    Afr.RefreshBackUp();
                }
                else
                {
                    lblErr.ForeColor = Color.Red;
                    lblErr.Text      = "修改失败!";
                }
            }
        }