コード例 #1
0
    private void BindGrid()
    {
        int month        = int.Parse(ddl_AccountMonth.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int scheme       = int.Parse(ddl_KPI_Scheme.SelectedValue);
        int staff;

        int.TryParse(select_Staff.SelectValue, out staff);
        int       approveflag = int.Parse(ddl_ApproveFlag.SelectedValue);
        int       position    = int.Parse(ddl_Position.SelectedValue);
        DataTable dt_detail   = KPI_ScoreBLL.KPIGetByAccountMonth(organizecity, month, scheme, staff, approveflag, position);

        if (dt_detail.Rows.Count == 0)
        {
            gv_List.DataBind();
            return;
        }
        dt_detail = MatrixTable.Matrix(dt_detail, new string[] { "ID", "营业部", "办事处", "会计月", "员工姓名", "职位", "审核标志", "KPI总达成率" },
                                       new string[] { "schemename", "detailname" }, "LastValue", false, false);

        gv_List.DataSource = dt_detail;
        gv_List.DataBind();

        if (dt_detail.Columns.Count >= 24)
        {
            gv_List.Width = new Unit(dt_detail.Columns.Count * 55);
        }
        else
        {
            gv_List.Width = new Unit(100, UnitType.Percentage);
        }

        MatrixTable.GridViewMatric(gv_List);
    }
コード例 #2
0
    private void Save()
    {
        KPI_ScoreBLL bll; int id, detailID;

        foreach (GridViewRow row in gv_List.Rows)
        {
            id       = (int)gv_List.DataKeys[row.RowIndex][0];
            detailID = (int)gv_List.DataKeys[row.RowIndex][1];
            bll      = new KPI_ScoreBLL(id);
            KPI_ScoreDetail item = bll.GetDetailModel(detailID);
            item.SelfCheckValue = decimal.Parse(((TextBox)row.FindControl("tbx_SelfCheckValue")).Text);
            item.LeadCheckValue = decimal.Parse(((TextBox)row.FindControl("tbx_LeadCheckValue")).Text);
            item.ApprovedValue  = decimal.Parse(((TextBox)row.FindControl("tbx_ApprovedValue")).Text);
            bll.UpdateDetail(item);
        }
    }
コード例 #3
0
    protected void bt_Approve_Click(object sender, EventArgs e)
    {
        KPI_ScoreBLL bll; int id;
        foreach (GridViewRow row in gv_List.Rows)
        {

            CheckBox chk = (CheckBox)row.FindControl("chk_ID");
            if (chk.Checked)
            {
                id = (int)gv_List.DataKeys[row.RowIndex][0];
                bll = new KPI_ScoreBLL(id);
                bll.Model.ApproveFlag = 1;
                bll.Update();
            }
        }
        BindGrid();
        MessageBox.Show(this, "审核成功");
    }
コード例 #4
0
    protected void bt_Approve_Click(object sender, EventArgs e)
    {
        KPI_ScoreBLL bll; int id;

        foreach (GridViewRow row in gv_List.Rows)
        {
            CheckBox chk = (CheckBox)row.FindControl("chk_ID");
            if (chk.Checked)
            {
                id  = (int)gv_List.DataKeys[row.RowIndex][0];
                bll = new KPI_ScoreBLL(id);
                bll.Model.ApproveFlag = 1;
                bll.Update();
            }
        }
        BindGrid();
        MessageBox.Show(this, "审核成功");
    }
コード例 #5
0
 private void Save()
 {
     KPI_ScoreBLL bll; int id, detailID;
     foreach (GridViewRow row in gv_List.Rows)
     {
         id = (int)gv_List.DataKeys[row.RowIndex][0];
         detailID = (int)gv_List.DataKeys[row.RowIndex][1];
         bll = new KPI_ScoreBLL(id);
         KPI_ScoreDetail item = bll.GetDetailModel(detailID);
         item.SelfCheckValue = decimal.Parse(((TextBox)row.FindControl("tbx_SelfCheckValue")).Text);
         item.LeadCheckValue = decimal.Parse(((TextBox)row.FindControl("tbx_LeadCheckValue")).Text);
         item.ApprovedValue = decimal.Parse(((TextBox)row.FindControl("tbx_ApprovedValue")).Text);
         bll.UpdateDetail(item);
     }
 }
コード例 #6
0
 protected void bt_Find_Click(object sender, EventArgs e)
 {
     ViewState["LabelVisiable"] = true;
     KPI_ScoreBLL.Init(int.Parse(tr_OrganizeCity.SelectValue), int.Parse(ddl_AccountMonth.SelectedValue), (int)Session["UserID"]);
     BindGrid();
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: fuhongliang/GraduateProject
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            if (dt_Data != null)
            {

                HSSFWorkbook hssfworkbook;
                FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite);

                hssfworkbook = new HSSFWorkbook(file);
                ISheet sheet = hssfworkbook.GetSheetAt(0);
                int RowBase = 1;
                if (sheet.GetRow(1).GetCell(sheet.GetRow(1).FirstCellNum).ToString() == "")
                {
                    RowBase = 2;
                }
                decimal lastValue;
                int staffid, month, Scheme;
                KPI_ScoreBLL _bll;
                Hashtable ht_table = new Hashtable();
                for (int x = 0; x < dt_Data.Rows.Count; x++)
                {
                    _bll = new KPI_ScoreBLL();
                    ((BackgroundWorker)sender).ReportProgress((x + 1) * 100 / dt_Data.Rows.Count, x + 1);
                    try
                    {
                        if (dt_Data.Rows[x]["导入标志"].ToString().Trim() != "")
                            continue;
                        string errorText = "";
                        staffid = int.Parse(dt_Data.Rows[x]["员工ID"].ToString());

                        if (ht_table[dt_Data.Rows[x]["会计月"].ToString()] == null)
                        {
                            IList<AC_AccountMonth> _monthlist = AC_AccountMonthBLL.GetModelList("Name='" + dt_Data.Rows[x]["会计月"].ToString() + "'");
                            if (_monthlist.Count > 0)
                            {
                                month = _monthlist[0].ID;
                                ht_table[dt_Data.Rows[x]["会计月"].ToString()] = month;
                            }
                            else
                            {
                                dt_Data.Rows[x]["导入标志"] += "会计月错误;";
                                continue;
                            }
                        }
                        else
                        {
                            month = (int)ht_table[dt_Data.Rows[x]["会计月"].ToString()];
                        }
                        if (ht_table[dt_Data.Rows[x]["考核方案"].ToString()] == null)
                        {
                            IList<KPI_Scheme> _schemelist = KPI_SchemeBLL.GetModelList("Name='" + dt_Data.Rows[x]["考核方案"].ToString() + "'");
                            if (_schemelist.Count > 0)
                            {
                                Scheme = _schemelist[0].ID;
                                ht_table[dt_Data.Rows[x]["考核方案"].ToString()] = Scheme;
                            }
                            else
                            {
                                dt_Data.Rows[x]["导入标志"] += "未找到相应考核方案;";
                                continue;
                            }
                        }
                        else
                        {
                            Scheme = (int)ht_table[dt_Data.Rows[x]["考核方案"].ToString()];
                        }
                        Org_StaffBLL _staffbll = new Org_StaffBLL(staffid);
                        if (_staffbll.Model == null)
                        {
                            dt_Data.Rows[x]["导入标志"] += "未找到相应员工;";
                            continue;
                        }
                        else
                        {
                            IList<KPI_Score> _kpilist = KPI_ScoreBLL.GetModelList("AccountMonth=" + month.ToString() + " AND RelateStaff=" + staffid.ToString() + " AND Scheme=" + Scheme.ToString());
                            if (_kpilist.Count > 0)
                            {
                                if (_kpilist.FirstOrDefault(p => p.ApproveFlag == 1) != null)
                                {
                                    dt_Data.Rows[x]["导入标志"] += "该员工绩效已审核,不能再次导入;";
                                    continue;
                                }
                                else
                                {
                                    _bll = new KPI_ScoreBLL(_kpilist[0].ID);
                                    _bll.Model.UpdateTime = DateTime.Now;
                                    _bll.Items.Clear();
                                }
                            }
                            else
                            {
                                _bll.Model.Scheme = Scheme;
                                _bll.Model.RelateStaff = staffid;
                                _bll.Model.AccountMonth = month;
                                _bll.Model.OrganizeCity = _staffbll.Model.OrganizeCity;
                                _bll.Model.ApproveFlag = 2;
                                _bll.Model.InsertStaff = 1;
                                _bll.Model.Position = _staffbll.Model.Position;
                                _bll.Model.InsertTime = DateTime.Now;

                            }
                        }
                        IList<KPI_ScoreDetail> _details = new List<KPI_ScoreDetail>();
                        for (int y = 9; y < dt_Data.Columns.Count; y++)
                        {
                            KPI_ScoreDetail detail = new KPI_ScoreDetail();
                            if (ht_table[dt_Data.Columns[y].ColumnName.ToString() + "(" + _bll.Model.Scheme.ToString() + ")"] == null)
                            {
                                IList<KPI_SchemeDetail> _SchemeDetailList = new KPI_SchemeBLL().GetDetail("Name='" + dt_Data.Columns[y].ColumnName.ToString() + "' AND Scheme=" + _bll.Model.Scheme.ToString());
                                if (_SchemeDetailList.Count > 0)
                                {
                                    detail.SchemeItem = _SchemeDetailList[0].ID;
                                    ht_table[dt_Data.Columns[y].ColumnName.ToString() + "(" + _bll.Model.Scheme.ToString() + ")"] = _SchemeDetailList[0].ID;
                                }
                                else
                                {
                                    dt_Data.Rows[x]["导入标志"] += "考核指标未找到;";
                                }
                            }
                            else
                            {
                                detail.SchemeItem = (int)ht_table[dt_Data.Columns[y].ColumnName.ToString() + "(" + _bll.Model.Scheme.ToString() + ")"];
                            }
                            if (!decimal.TryParse(dt_Data.Rows[x][y].ToString(), out lastValue))
                            {
                                errorText += dt_Data.Columns[y] + "转换出错;导入失败!";
                                continue;
                            }
                            else
                            {
                                detail.LastValue = lastValue;

                            }
                            errorText = errorText.Replace("导入成功", "");
                            dt_Data.Rows[x]["导入标志"] = errorText == "" ? "导入成功" : errorText;
                            _details.Add(detail);
                        }
                        if (_bll.Model.ID > 0)
                        {
                            _bll.DeleteDetail();     //先清除原先导入的数据
                            _bll.Items = _details;
                            _bll.AddDetail();
                            _bll.Update();
                        }
                        else
                        {
                            _bll.Items = _details;
                            _bll.Add();
                        }
                    }
                    catch (Exception ex)
                    {
                        dt_Data.Rows[x]["导入标志"] = "导入出错";
                        MessageBox.Show(ex.Message);
                        continue;
                    }
                    finally
                    {
                        sheet.GetRow(RowBase + x).GetCell(8).SetCellValue(dt_Data.Rows[x]["导入标志"].ToString());
                    }
                }
                FileStream writefile = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite);
                hssfworkbook.Write(writefile);
                writefile.Close();

                sheet = null;
            }
            else
            {
                if (fileName != "")
                {
                    ConvertToDataTable(fileName);
                }
            }
        }
コード例 #8
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            if (dt_Data != null)
            {
                HSSFWorkbook hssfworkbook;
                FileStream   file = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite);

                hssfworkbook = new HSSFWorkbook(file);
                ISheet sheet   = hssfworkbook.GetSheetAt(0);
                int    RowBase = 1;
                if (sheet.GetRow(1).GetCell(sheet.GetRow(1).FirstCellNum).ToString() == "")
                {
                    RowBase = 2;
                }
                decimal      lastValue;
                int          staffid, month, Scheme;
                KPI_ScoreBLL _bll;
                Hashtable    ht_table = new Hashtable();
                for (int x = 0; x < dt_Data.Rows.Count; x++)
                {
                    _bll = new KPI_ScoreBLL();
                    ((BackgroundWorker)sender).ReportProgress((x + 1) * 100 / dt_Data.Rows.Count, x + 1);
                    try
                    {
                        if (dt_Data.Rows[x]["导入标志"].ToString().Trim() != "")
                        {
                            continue;
                        }
                        string errorText = "";
                        staffid = int.Parse(dt_Data.Rows[x]["员工ID"].ToString());

                        if (ht_table[dt_Data.Rows[x]["会计月"].ToString()] == null)
                        {
                            IList <AC_AccountMonth> _monthlist = AC_AccountMonthBLL.GetModelList("Name='" + dt_Data.Rows[x]["会计月"].ToString() + "'");
                            if (_monthlist.Count > 0)
                            {
                                month = _monthlist[0].ID;
                                ht_table[dt_Data.Rows[x]["会计月"].ToString()] = month;
                            }
                            else
                            {
                                dt_Data.Rows[x]["导入标志"] += "会计月错误;";
                                continue;
                            }
                        }
                        else
                        {
                            month = (int)ht_table[dt_Data.Rows[x]["会计月"].ToString()];
                        }
                        if (ht_table[dt_Data.Rows[x]["考核方案"].ToString()] == null)
                        {
                            IList <KPI_Scheme> _schemelist = KPI_SchemeBLL.GetModelList("Name='" + dt_Data.Rows[x]["考核方案"].ToString() + "'");
                            if (_schemelist.Count > 0)
                            {
                                Scheme = _schemelist[0].ID;
                                ht_table[dt_Data.Rows[x]["考核方案"].ToString()] = Scheme;
                            }
                            else
                            {
                                dt_Data.Rows[x]["导入标志"] += "未找到相应考核方案;";
                                continue;
                            }
                        }
                        else
                        {
                            Scheme = (int)ht_table[dt_Data.Rows[x]["考核方案"].ToString()];
                        }
                        Org_StaffBLL _staffbll = new Org_StaffBLL(staffid);
                        if (_staffbll.Model == null)
                        {
                            dt_Data.Rows[x]["导入标志"] += "未找到相应员工;";
                            continue;
                        }
                        else
                        {
                            IList <KPI_Score> _kpilist = KPI_ScoreBLL.GetModelList("AccountMonth=" + month.ToString() + " AND RelateStaff=" + staffid.ToString() + " AND Scheme=" + Scheme.ToString());
                            if (_kpilist.Count > 0)
                            {
                                if (_kpilist.FirstOrDefault(p => p.ApproveFlag == 1) != null)
                                {
                                    dt_Data.Rows[x]["导入标志"] += "该员工绩效已审核,不能再次导入;";
                                    continue;
                                }
                                else
                                {
                                    _bll = new KPI_ScoreBLL(_kpilist[0].ID);
                                    _bll.Model.UpdateTime = DateTime.Now;
                                    _bll.Items.Clear();
                                }
                            }
                            else
                            {
                                _bll.Model.Scheme       = Scheme;
                                _bll.Model.RelateStaff  = staffid;
                                _bll.Model.AccountMonth = month;
                                _bll.Model.OrganizeCity = _staffbll.Model.OrganizeCity;
                                _bll.Model.ApproveFlag  = 2;
                                _bll.Model.InsertStaff  = 1;
                                _bll.Model.Position     = _staffbll.Model.Position;
                                _bll.Model.InsertTime   = DateTime.Now;
                            }
                        }
                        IList <KPI_ScoreDetail> _details = new List <KPI_ScoreDetail>();
                        for (int y = 9; y < dt_Data.Columns.Count; y++)
                        {
                            KPI_ScoreDetail detail = new KPI_ScoreDetail();
                            if (ht_table[dt_Data.Columns[y].ColumnName.ToString() + "(" + _bll.Model.Scheme.ToString() + ")"] == null)
                            {
                                IList <KPI_SchemeDetail> _SchemeDetailList = new KPI_SchemeBLL().GetDetail("Name='" + dt_Data.Columns[y].ColumnName.ToString() + "' AND Scheme=" + _bll.Model.Scheme.ToString());
                                if (_SchemeDetailList.Count > 0)
                                {
                                    detail.SchemeItem = _SchemeDetailList[0].ID;
                                    ht_table[dt_Data.Columns[y].ColumnName.ToString() + "(" + _bll.Model.Scheme.ToString() + ")"] = _SchemeDetailList[0].ID;
                                }
                                else
                                {
                                    dt_Data.Rows[x]["导入标志"] += "考核指标未找到;";
                                }
                            }
                            else
                            {
                                detail.SchemeItem = (int)ht_table[dt_Data.Columns[y].ColumnName.ToString() + "(" + _bll.Model.Scheme.ToString() + ")"];
                            }
                            if (!decimal.TryParse(dt_Data.Rows[x][y].ToString(), out lastValue))
                            {
                                errorText += dt_Data.Columns[y] + "转换出错;导入失败!";
                                continue;
                            }
                            else
                            {
                                detail.LastValue = lastValue;
                            }
                            errorText = errorText.Replace("导入成功", "");
                            dt_Data.Rows[x]["导入标志"] = errorText == "" ? "导入成功" : errorText;
                            _details.Add(detail);
                        }
                        if (_bll.Model.ID > 0)
                        {
                            _bll.DeleteDetail();     //先清除原先导入的数据
                            _bll.Items = _details;
                            _bll.AddDetail();
                            _bll.Update();
                        }
                        else
                        {
                            _bll.Items = _details;
                            _bll.Add();
                        }
                    }
                    catch (Exception ex)
                    {
                        dt_Data.Rows[x]["导入标志"] = "导入出错";
                        MessageBox.Show(ex.Message);
                        continue;
                    }
                    finally
                    {
                        sheet.GetRow(RowBase + x).GetCell(8).SetCellValue(dt_Data.Rows[x]["导入标志"].ToString());
                    }
                }
                FileStream writefile = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite);
                hssfworkbook.Write(writefile);
                writefile.Close();

                sheet = null;
            }
            else
            {
                if (fileName != "")
                {
                    ConvertToDataTable(fileName);
                }
            }
        }
コード例 #9
0
 private string WirteInSQL(int staffid, string Month, string cycleName, string schemeName, decimal lastValue)
 {
     return(KPI_ScoreBLL.ImportExcel(staffid, Month, cycleName, schemeName, lastValue));
 }