コード例 #1
0
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        KPI_SchemeBLL bll = (int)ViewState["ID"] > 0 ? new KPI_SchemeBLL((int)ViewState["ID"]) : new KPI_SchemeBLL();

        DV_KPIScheme.GetData(bll.Model);
        if ((int)ViewState["ID"] > 0)
        {
            KPI_SchemeDetail detailModel = ViewState["DetailID"] == null ? new KPI_SchemeDetail() : bll.GetDetailModel((int)ViewState["DetailID"]);
            DV_KPISchemeDetail.GetData(detailModel);
            bll.Update();
            if (detailModel.ID > 0)
            {
                bll.UpdateDetail(detailModel);
            }
            else if (DV_KPISchemeDetail.Visible)
            {
                detailModel.Scheme = (int)ViewState["ID"];
                bll.AddDetail(detailModel);
            }
        }
        else
        {
            ViewState["ID"] = bll.Add();
        }
        MessageBox.ShowAndRedirect(this, "保存成功!", "KPI_SchemeDetail.aspx?ID=" + ViewState["ID"].ToString());
    }
コード例 #2
0
    protected void gv_List_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        int detailID = int.Parse(gv_List.DataKeys[e.NewSelectedIndex]["ID"].ToString());

        ViewState["DetailID"] = detailID;
        KPI_SchemeDetail model = new KPI_SchemeBLL((int)ViewState["ID"]).GetDetailModel(detailID);

        DV_KPISchemeDetail.BindData(model);
        DV_KPISchemeDetail.Visible = true;
    }
コード例 #3
0
 private void doApprove(int ApproveFlag, string message)
 {
     if ((int)ViewState["ID"] != 0)
     {
         KPI_SchemeBLL bll = new KPI_SchemeBLL((int)ViewState["ID"]);
         bll.Model.ApproveFlag = ApproveFlag;
         bll.Update();
         MessageBox.ShowAndRedirect(this, message, "KPI_SchemeDetail.aspx?ID=" + ViewState["ID"].ToString());
     }
 }
コード例 #4
0
    private void BindData()
    {
        KPI_Scheme model = new KPI_SchemeBLL((int)ViewState["ID"]).Model;

        DV_KPIScheme.BindData(model);
        gv_List.BindGrid(new KPI_SchemeBLL((int)ViewState["ID"]).Items);
        if (model.ApproveFlag == 1)
        {
            bt_Add.Visible     = false;
            bt_Approve.Visible = false;
            bt_del.Visible     = false;
            bt_Save.Visible    = false;
            gv_List.Columns[gv_List.Columns.Count - 1].Visible = false;
        }
        else
        {
            bt_CancelApprove.Visible = false;
        }
    }
コード例 #5
0
 protected void gv_List_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
 {
     int detailID = int.Parse(gv_List.DataKeys[e.NewSelectedIndex]["ID"].ToString());
     ViewState["DetailID"] = detailID;
     KPI_SchemeDetail model = new KPI_SchemeBLL((int)ViewState["ID"]).GetDetailModel(detailID);
     DV_KPISchemeDetail.BindData(model);
     DV_KPISchemeDetail.Visible = true;
 }
コード例 #6
0
 private void doApprove(int ApproveFlag, string message)
 {
     if ((int)ViewState["ID"] != 0)
     {
         KPI_SchemeBLL bll = new KPI_SchemeBLL((int)ViewState["ID"]);
         bll.Model.ApproveFlag = ApproveFlag;
         bll.Update();
         MessageBox.ShowAndRedirect(this, message, "KPI_SchemeDetail.aspx?ID=" + ViewState["ID"].ToString());
     }
 }
コード例 #7
0
 private void BindData()
 {
     KPI_Scheme model = new KPI_SchemeBLL((int)ViewState["ID"]).Model;
     DV_KPIScheme.BindData(model);
     gv_List.BindGrid(new KPI_SchemeBLL((int)ViewState["ID"]).Items);
     if (model.ApproveFlag == 1)
     {
         bt_Add.Visible = false;
         bt_Approve.Visible = false;
         bt_del.Visible = false;
         bt_Save.Visible = false;
         gv_List.Columns[gv_List.Columns.Count - 1].Visible = false;
     }
     else
     {
         bt_CancelApprove.Visible = false;
     }
 }
コード例 #8
0
    private void BindDropDown()
    {
        Org_StaffBLL staff     = new Org_StaffBLL((int)Session["UserID"]);
        string       condition = "ApproveFlag=1";

        #region 绑定考核方案
        switch ((int)ViewState["CheckType"])
        {
        case 0:
            // Response.Redirect("~/SubModule/desktop.aspx");
            break;

        case 1:
            condition += " and RelatePosition=" + staff.Model.Position.ToString() + " AND ID IN (SELECT Scheme FROM MCS_OA.dbo.KPI_SchemeDetail WHERE AllowSelfcheck=1)";
            gv_List.Columns[gv_List.Columns.Count - 4].Visible = false;
            gv_List.Columns[gv_List.Columns.Count - 3].Visible = false;
            gv_List.Columns[gv_List.Columns.Count - 2].Visible = false;
            break;

        case 2:
            condition += " AND ID IN (SELECT Scheme FROM MCS_OA.dbo.KPI_SchemeDetail WHERE CheckPosition=" + staff.Model.Position.ToString() + ")";
            gv_List.Columns[gv_List.Columns.Count - 3].Visible = false;
            gv_List.Columns[gv_List.Columns.Count - 2].Visible = false;
            break;

        case 3:
            condition += " AND ID IN (SELECT Scheme FROM MCS_OA.dbo.KPI_SchemeDetail WHERE ApprovePosition=" + staff.Model.Position.ToString() + ")";
            break;
        }
        ddl_KPI_Scheme.DataSource = KPI_SchemeBLL.GetModelList(condition);
        ddl_KPI_Scheme.DataBind();
        ddl_KPI_Scheme.Items.Insert(0, new ListItem("请选择", "0"));
        #endregion

        #region
        ddl_Position.DataSource = Org_PositionBLL.GetModelList("ID IN(Select RelatePosition FROM MCS_OA.dbo.KPI_Scheme WHERE Cycle=1)");
        ddl_Position.DataBind();
        ddl_Position.Items.Insert(0, new ListItem("请选择", "0"));
        #endregion


        #region 绑定用户可管辖的片区
        ViewState["Position"]      = staff.Model.Position;
        tr_OrganizeCity.DataSource = staff.GetStaffOrganizeCity();

        if (tr_OrganizeCity.DataSource.Select("ID = 1").Length > 0)
        {
            tr_OrganizeCity.RootValue   = "0";
            tr_OrganizeCity.SelectValue = "1";
        }
        else
        {
            tr_OrganizeCity.RootValue   = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString();
            tr_OrganizeCity.SelectValue = staff.Model.OrganizeCity.ToString();
        }
        #endregion

        ddl_AccountMonth.DataSource = AC_AccountMonthBLL.GetModelList("");
        ddl_AccountMonth.DataBind();
        ddl_AccountMonth.SelectedValue = (AC_AccountMonthBLL.GetCurrentMonth() - 1).ToString();



        ddl_ApproveFlag.DataSource = DictionaryBLL.GetDicCollections("PUB_ApproveFlag");
        ddl_ApproveFlag.DataBind();
        ddl_ApproveFlag.Items.Insert(0, new ListItem("所有", "0"));
    }
コード例 #9
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);
                }
            }
        }
コード例 #10
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);
                }
            }
        }