/// <summary>
        /// 绩效考核报表--修改
        /// </summary>
        public object UpdateExamInformation(Module.ExamManager exam, out string mag)
        {
            mag = string.Empty;
            string strSQL = @"Update FY_Performance_ExamineInformation Set FBaseExamine=@FBaseExamine,FCoefficient=@FCoefficient,FBaseResult=@FBaseResult
            ,FAcAttend=@FAcAttend,FAbsented=@FAbsented,FAmount=@FAmount,FFloatAmount=@FFloatAmount,FRemark=@FRemark Where FID=@FID ";

            SqlParameter[] paras = new SqlParameter[] {
                new SqlParameter("@FBaseExamine", exam.FBaseExamine),
                new SqlParameter("@FCoefficient", exam.FCoefficient),
                new SqlParameter("@FBaseResult", exam.FBaseResult),
                new SqlParameter("@FAcAttend", exam.FAcAttend),
                new SqlParameter("@FAbsented", exam.FAbsented),
                new SqlParameter("@FAmount", exam.FAmount),
                new SqlParameter("@FFloatAmount", exam.FFloatAmount),
                new SqlParameter("@FRemark", exam.FRemark),
                new SqlParameter("@FID", exam.FID),
            };
            object result = null;

            try {
                result = mSSQL.GetUpdateByText(strSQL, paras);
                if (Convert.ToInt32(result) != 1)
                {
                    result = null;
                }
            }
            catch (Exception ex) {
                mag = ex.Message;
            }
            return(result);
        }
        /// <summary>
        /// 绩效考核报表--新增
        /// </summary>
        public object InsertExamInformation(Module.ExamManager exam, out string mag)
        {
            mag = string.Empty;
            string strSQL = @"Insert Into FY_Performance_ExamineInformation(FCDate,FEmCode,FYear,FMonth,FBaseExamine,FCoefficient,FBaseResult,FAcAttend
            ,FAbsented,FAmount,FFloatAmount,FRemark,FStatus) Values(@FCDate,@FEmCode,@FYear,@FMonth,@FBaseExamine,@FCoefficient
            ,@FBaseResult,@FAcAttend,@FAbsented,@FAmount,@FFloatAmount,@FRemark,@FStatus)";

            SqlParameter[] paras = new SqlParameter[] {
                new SqlParameter("@FCDate", exam.FCDate),
                new SqlParameter("@FEmCode", exam.FEmCode),
                new SqlParameter("@FYear", exam.FYear),
                new SqlParameter("@FMonth", exam.FMonth),
                new SqlParameter("@FBaseExamine", exam.FBaseExamine),
                new SqlParameter("@FCoefficient", exam.FCoefficient),
                new SqlParameter("@FBaseResult", exam.FBaseResult),
                new SqlParameter("@FAcAttend", exam.FAcAttend),
                new SqlParameter("@FAbsented", exam.FAbsented),
                new SqlParameter("@FAmount", exam.FAmount),
                new SqlParameter("@FFloatAmount", exam.FFloatAmount),
                new SqlParameter("@FRemark", exam.FRemark),
                new SqlParameter("@FStatus", exam.FStatus),
            };
            object result = null;

            try {
                result = mSSQL.GetUpdateByText(strSQL, paras);
                if (Convert.ToInt32(result) != 1)
                {
                    result = null;
                }
            }
            catch (Exception ex) {
                mag = ex.Message;
            }
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// 保存
        /// </summary>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string mag       = string.Empty;
            int    count     = 0;
            bool   isChecked = false;

            foreach (GridViewRow row in GridView1.Rows)
            {
                Control  ctl   = row.FindControl("chkRow");
                CheckBox check = ctl as CheckBox;
                if (check.Checked)
                {
                    TextBox            txtAcAttend = row.FindControl("txtAcAttend") as TextBox;
                    TextBox            txtAbsented = row.FindControl("txtAbsented") as TextBox;
                    TextBox            txtFAmount  = row.FindControl("txtFAmount") as TextBox;
                    TextBox            txtRemark   = row.FindControl("txtRemark") as TextBox;
                    Module.ExamManager exam        = new Module.ExamManager {
                        FCDate       = DateTime.Now.Date,
                        FID          = row.Cells[2].Text,
                        FEmCode      = row.Cells[3].Text,
                        FYear        = labYear.Text,
                        FMonth       = labMonth.Text,
                        FBaseExamine = Convert.ToDouble(row.Cells[6].Text),
                        FCoefficient = Convert.ToDouble(row.Cells[7].Text),
                        FBaseResult  = Convert.ToDouble(row.Cells[8].Text),
                        FFloatAmount = Convert.ToDecimal(row.Cells[12].Text),
                        FStatus      = true,
                    };
                    exam.FAcAttend = Convert.ToDouble(string.IsNullOrEmpty(txtAcAttend.Text) ? "0" : txtAcAttend.Text);
                    exam.FAbsented = Convert.ToDouble(string.IsNullOrEmpty(txtAbsented.Text) ? "0" : txtAbsented.Text);
                    exam.FAmount   = Convert.ToDouble(string.IsNullOrEmpty(txtFAmount.Text) ? "0" : txtFAmount.Text);
                    exam.FRemark   = txtRemark.Text;
                    //**验证是否完成绩效计算**
                    if (exam.FBaseResult != 0 && exam.FFloatAmount == 0)
                    {
                        string saveOk = string.Empty;
                        if (isChecked)
                        {
                            saveOk = $@"已完成【{count}】条记录保存,";
                        }
                        mag = @"请先完成【绩效浮动奖金】计算。";
                        Response.Write($@"<script language=javaScript>alert('{saveOk}编号:【{exam.FEmCode}】数据保存失败,原因: {mag}');</script>");
                        btnRefresh_Click(null, null);
                        return;
                    }

                    //**新增状态*
                    if (isNewData)
                    {
                        //*插入新记录*
                        object result = manageAction.InsertExamInformation(exam, out mag);
                        if (result == null)
                        {
                            Response.Write($@"<script language=javaScript>alert('已完成更新{count}条记录,【{exam.FEmCode}】数据新增失败');</script>");
                            btnRefresh_Click(null, null);
                            return;
                        }
                        else
                        {
                            //*更新【考核成绩结果】的单据状态为已审核*
                            result = null;
                            result = manageAction.UpdateExamResultApprove(exam.FEmCode, exam.FYear, exam.FMonth, out mag);
                            if (result == null)
                            {
                                Response.Write($@"<script language=javaScript>alert('【绩效结果表】审核状态修改失败,原因: {mag}');</script>");
                                btnRefresh_Click(null, null);
                                return;
                            }
                        }
                        count    += 1;
                        isChecked = true;
                    }
                    //**修改状态**
                    if (!isNewData)
                    {
                        exam.FID = row.Cells[2].Text;
                        object result = manageAction.UpdateExamInformation(exam, out mag);
                        if (result == null)
                        {
                            Response.Write($@"<script language=javaScript>alert('{count}条记录更新完成,【{exam.FEmCode}】更新失败。');</script>");
                            btnRefresh_Click(null, null);
                            return;
                        }
                        count    += 1;
                        isChecked = true;
                    }
                }
            }
            if (!isChecked)
            {
                mag = $"请先选择要保存的行。";
                Response.Write($@"<script language=javaScript>alert('{mag}');</script>");
                return;
            }
            else
            {
                mag = $"数据更新成功,共更新【{count.ToString()}】条数据。";
                Response.Write($@"<script language=javaScript>alert('{mag}');</script>");
                btnRefresh_Click(null, null);
                btnSave.Enabled = false;
            }
        }