コード例 #1
0
ファイル: PositionMgr.aspx.cs プロジェクト: kavilee2012/lzQA
    protected void btn_Delete_Click(object sender, ImageClickEventArgs e)
    {
        string idList = string.Empty;
        foreach (GridViewRow dr in GridView1.Rows)
        {
            CheckBox chk = (CheckBox)dr.FindControl("chk");
            if (chk != null && chk.Checked)
            {
                string _id = "'" + dr.Cells[1].Text.Trim() + "'";
                string _name = dr.Cells[2].Text.Trim();
                if (_name == "系统管理员")
                {
                    UtilityService.Alert(this.Page, "禁止删除系统管理员");
                    return;
                }

                idList += _id + ",";
            }

        }
        if (idList.Length > 0)
        {
            idList = idList.TrimEnd(',');
            bool re = new PositionBLL().DeleteList(idList);
            if (re)
            {
                UtilityService.AlertAndRedirect(this.Page, "删除成功!", "PositionMgr.aspx");
            }
            else
            {
                UtilityService.Alert(this.Page, "删除失败!");
            }
        }
    }
コード例 #2
0
ファイル: PositionController.cs プロジェクト: sosleeply/html5
        public ActionResult Save()
        {
            Position position = new Position();
            try
            {
                string stated = Request.Form["stated"];
                position.Id = Convert.ToInt32(Request.Form["Id"]);
                position.positionName = Request.Form["positionName"];

                PositionBLL pBll = new PositionBLL();
                if (stated == "add")
                {
                    if (pBll.AddEntity(position))
                    {
                        return Content("{'success':'ok'}");
                    }
                }
                else if (stated == "update")
                {
                    if (pBll.ModifyEntity(position))
                    {
                        return Content("{'success':'ok'}");
                    }
                }
            }
            catch { }
            return Content("{}");
        }
コード例 #3
0
ファイル: EmployeeController.cs プロジェクト: sosleeply/html5
        public ActionResult GetEmployee()
        {
            try
            {
                int pageIndex = Convert.ToInt32(Request.QueryString["page"]);
                int pageSize = Convert.ToInt32(Request.QueryString["limit"]);
                string branchIds = Request.QueryString["id"];
                string[] _ids = branchIds.Split(',');
                int[] ids = Array.ConvertAll<string, int>(_ids, id =>
                {
                    return int.Parse(id);
                });
                EmployeeBLL eBll = new EmployeeBLL();
                int rows = 0;
                int totalPages = 0;
                List<Employee> list = eBll.LoadPagedEntitys(pageIndex, pageSize, out rows, out totalPages, t => ids.Contains(t.branchId), true, t => t.Id);
                if (list != null && list.Count > 0)
                {
                    List<Branch> branchList = new BranchBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        branchList.ForEach(y =>
                        {
                            if (t.branchId == y.Id)
                            {
                                t.branchName = y.branchName;
                            }
                        });
                    });
                    List<Role> roleList = new RoleBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        roleList.ForEach(y =>
                        {
                            if (t.roleId == y.Id)
                            {
                                t.roleName = y.roleName;
                            }
                        });
                    });
                    List<Position> positionList = new PositionBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        positionList.ForEach(y =>
                        {
                            if (t.positionId == y.Id)
                            {
                                t.positionName = y.positionName;
                            }
                        });
                    });
                }
                string resJson = Common.Common.JsonSerialize(list);
                resJson = "{total:" + rows + ",root:" + resJson + "}";
                return Content(resJson);
            }
            catch { }

            return Content("{}");
        }
コード例 #4
0
ファイル: PositionAMV.aspx.cs プロジェクト: kavilee2012/lzQA
    public void LoadService()
    {
        string code = Request.QueryString["Code"].ToString();
        Position _p = new PositionBLL().GetModel(code);
        if (_p != null)
        {
            lab_Code.Text = _p.PosiCode;
            txt_Name.Text = _p.PosiName;
            ddl_Father.SelectedValue = _p.FatherCode;

        }
    }
コード例 #5
0
ファイル: PositionController.cs プロジェクト: sosleeply/html5
 public ActionResult DeletePosition()
 {
     string ids = Request.Form["ids"];
     PositionBLL rbll = new PositionBLL();
     if (rbll.DeletePhysicsById(ids))
     {
         return Content("{'success':'ok'}");
     }
     else
     {
         return Content("{}");
     }
 }
コード例 #6
0
ファイル: PositionMgr.aspx.cs プロジェクト: kavilee2012/lzQA
 private void BindGV()
 {
     PositionBLL organBLL = new PositionBLL();
     IList<Position> ds = organBLL.GetModelList(" OrganID = " + (int)Session["OrganID"]);
     foreach (Position o in ds)
     {
         Position oa = organBLL.GetModel(o.FatherCode);
         if (oa == null)
             o.FatherCodeName = "无";
         else
             o.FatherCodeName = oa.PosiName;
     }
     GridView1.DataSource = ds;
     GridView1.DataBind();
 }
コード例 #7
0
ファイル: PositionController.cs プロジェクト: sosleeply/html5
        public ActionResult GetPosition()
        {
            try
            {
                int pageIndex = Convert.ToInt32(Request.QueryString["page"]);
                int pageSize = Convert.ToInt32(Request.QueryString["limit"]);
                PositionBLL pBll = new PositionBLL();
                int rows = 0;
                int totalPages = 0;
                List<Position> list = pBll.LoadPagedEntitys(pageIndex, pageSize, out rows, out totalPages, t=>t.Id>0, true, t => t.Id);
                string resJson = Common.Common.JsonSerialize(list);
                resJson = "{total:" + rows + ",root:" + resJson + "}";
                return Content(resJson);
            }
            catch { }

            return Content("{}");
        }
コード例 #8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            PositionBLL positionBLL = new PositionBLL();

            Position  temp = new  Position();

            temp.Position_name = txtbPositionname.Text.Trim();
            temp.Position_description = txtbPositionDes.Text.Trim();

            if (positionBLL.Add(temp) !=-1)
            {
                MessageBox.ShowAndRedirect(this, "添加成功", "PositionList.aspx");
            }
            else
            {
                MessageBox.ShowAndRedirect(this, "添加失败", "PositionList.aspx");
            }
        }
コード例 #9
0
 protected void btn_Add_Click(object sender, EventArgs e)
 {
     if (list_Aim.Items.Count >= 0)
     {
         List<string> all = new List<string>();
         string _posiCode = Request.QueryString["code"].ToString();
         foreach (ListItem li in list_Aim.Items)
         {
             string c = li.Value.ToString();
             all.Add(c);
         }
         int re = new PositionBLL().AddPosi2User(_posiCode, all);
         if (re > 0)
         {
             UtilityService.Alert(this, "设定完成!");
         }
         else
         {
             UtilityService.Alert(this, "设定失败!");
         }
     }
 }
コード例 #10
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            PositionBLL temp = new PositionBLL();
            int selectCount = 0;
            int position_id = 0;
            foreach (GridViewRow gr in grVPositionManage.Rows)
            {
                CheckBox chk = (CheckBox)gr.Cells[0].FindControl("CB_Select");
                if (chk.Checked)
                {
                    position_id = int.Parse(grVPositionManage.DataKeys[gr.RowIndex].Values["position_id"].ToString());

                    temp.Delete(position_id);
                    selectCount++;
                }
            }
            if (0 == selectCount)
            {
                MessageBox.ShowAndRedirect(this, "请选择一个岗位", "PositionList.aspx");
            }
            temp = null;
            MessageBox.ShowAndRedirect(this, "删除操作成功", "PositionList.aspx");
        }
コード例 #11
0
ファイル: PositionAMV.aspx.cs プロジェクト: kavilee2012/lzQA
    protected void btn_Modity_Click(object sender, EventArgs e)
    {
        if (txt_Name.Text.Trim() == "系统管理员")
        {
            UtilityService.Alert(this.Page, "该名称是非法名,请换一个职位名称!");
            return;
        }

        Position p = new Position();
        p.PosiCode = lab_Code.Text.Trim();
        p.PosiName = txt_Name.Text.Trim();
        p.FatherCode = ddl_Father.SelectedValue.ToString();
        p.OrganID = (int)Session["OrganID"];

        bool re = new PositionBLL().Update(p);
        if (re)
        {
            UtilityService.AlertAndRedirect(this,"修改成功!", "PositionMgr.aspx");
        }
        else
        {
            UtilityService.Alert(this,"修改失败!");
        }
    }
コード例 #12
0
        private void LoadDimSelected()
        {
            if (Request["mode"] != null)
            {
                _mode = Request["mode"].ToString();

                if (!string.IsNullOrEmpty(_mode))
                {
                    if (Int32.Parse(_mode) == POSITION_DEFAULT_TYPE)
                    {
                        if (Request["posid"] != null)
                        {
                            _posID = Request["posid"].ToString();
                            PositionBLL pBll = new PositionBLL();

                            lblSpec.Text = "设置岗位默认维度: " + pBll.GetPositionNmById(Int32.Parse(_posID));
                            lblNotice.Text = string.Empty;
                            LoadDimension(_posID, 0);
                        }
                    }
                    else if (Int32.Parse(_mode) == ACTIVITY_CUSTOM_TYPE)
                    {
                        if (Request["actid"] != null)
                        {
                            _actID = Request["actid"].ToString();
                            ActivityBLL aBll = new ActivityBLL();
                            DataSet dsIncInfo = aBll.GetEUsrInfoByActivityId(Int32.Parse(_actID));

                            lblSpec.Text = "当前公司名称:" +"["+
                                            dsIncInfo.Tables[0].Rows[0][1].ToString() +"]"+
                                            "  当前测评项目名称: " + "[" +
                                            aBll.GetActivityNM(Int32.Parse(_actID)) + "]";

                            LoadDimension(_actID,1);
                            grVDimensionSet.Columns[5].Visible = true;
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
コード例 #13
0
        private void bind()
        {
            if (string.IsNullOrEmpty(users_id))
            {
                return;
            }

            PositionBLL positionBll = new PositionBLL();
            DataSet dsPosition = positionBll.GetPositionAll("");
            ddlPosition.DataSource = dsPosition.Tables[0].DefaultView;
            ddlPosition.DataTextField = "position_name";
            ddlPosition.DataValueField = "position_id";

            ddlPosition.DataBind();
        }
コード例 #14
0
ファイル: LoadUser.aspx.cs プロジェクト: kavilee2012/lzQA
    private string AddPosition(string name,int organID,string fatherName)
    {
        if (name == "0" || name == string.Empty)
        {
            return "";
        }
        PositionBLL pBLL = new PositionBLL();
        bool _re = pBLL.Exists(name, organID);
        if (!_re)
        {
            string _fatherCode = pBLL.GetPosiCode(fatherName, organID);
            if (string.IsNullOrEmpty(_fatherCode))
            {
                _fatherCode = "0";
            }
            Position p = new Position();
            p.PosiName = name;
            p.FatherCode = _fatherCode;
            p.OrganID = organID;
            p.InputBy = Session["UserID"].ToString();

            bool re = pBLL.Add(p);

            if (re)
            {
                //添加数据组
                string _groupName = name + "数据组";
                try
                {
                    ObjectGroup r = new ObjectGroup();
                    r.Name = _groupName;
                    r.TypeCode = "T0001";
                    r.OrganID = organID;
                    r.InputBy = Session["UserID"].ToString();
                    int reOG = new ObjectGroupBLL().Add(r);
                    if (reOG > 0)
                    {
                        string _groupCode = new ObjectGroupBLL().GetObjectGroupCode(_groupName, organID);
                        string _pCode = pBLL.GetPosiCode(name, organID);

                        List<string> ogList = new List<string>();
                        ogList.Add(_groupCode);

                        int reP2O = new PositionBLL().AddPosi2ObjectGroup(_pCode, ogList);

                    }
                }
                catch
                {

                }
            }
        }
        string _Code = pBLL.GetPosiCode(name, organID);
        return _Code;
    }
コード例 #15
0
ファイル: LoadUser.aspx.cs プロジェクト: kavilee2012/lzQA
    private void LoadExcel(string path)
    {
        try
        {
            DataTable dt = null;
            try
            {
                dt = ExcelService.ImportDataTableFromExcel(path, int.Parse(ddl_Name.SelectedItem.Value), 0);

            }
            catch
            { }
            if (dt != null)
            {
                EmployeeBLL iBLL = new EmployeeBLL();
                IList<Employee> iList = new List<Employee>();
                IList<int> iListErrorRowNumber = new List<int>();
                IList<int> iListFailRowNumber = new List<int>();
                int _OrganID = Convert.ToInt32(ddl_Organ.SelectedValue);
                string _InputBy = Session["UserID"].ToString();

                int count = 0;
                int row = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    //excel内容
                    string _UserName = dr["姓名"].ToString();
                    string _PQ = dr["片区"].ToString();
                    string _DZ = dr["大组"].ToString();
                    string _XZ = dr["小组"].ToString();
                    string _RoleName = dr["梯队任职"].ToString();
                    string _IsPrivateStr = dr["是否公估"].ToString();

                    if (string.IsNullOrEmpty(_UserName) || string.IsNullOrEmpty(_PQ) || !ValidateService.IsNumber(_DZ) || string.IsNullOrEmpty(_XZ) || string.IsNullOrEmpty(_RoleName) || string.IsNullOrEmpty(_IsPrivateStr))
                    {
                        row++;
                        iListErrorRowNumber.Add(row);
                        continue;
                    }

                    bool _isPrivate = _IsPrivateStr == "否" ? false : true;

                    //添加用户
                    string _userID = AddUser(_UserName, _OrganID);

                    //添加组织
                    string _PQname = "",_DZname="",_XZname="";
                    string _PQcode = "",_DZcode="",_XZcode="";
                    if (_PQ != "0")
                    {
                        _PQname = _PQ + "片区";
                        _PQcode = AddPosition(_PQname, _OrganID, "市级管理层");
                    }
                    else
                    {
                        _PQcode = AddPosition("市级管理层", _OrganID, "市级管理层");
                    }

                    if (_DZ != "0")
                    {
                        _DZname =_PQname + _DZ + "大组";
                    }
                    _DZcode = AddPosition(_DZname, _OrganID, _PQname);

                    if (_XZ != "0")
                    {
                        if (_DZname != string.Empty)
                        {
                            _XZname = _DZname + _XZ + "小组";
                        }
                        else
                        {
                            _XZname = _PQname + _XZ + "小组";
                        }
                    }
                    _XZcode = AddPosition(_XZname, _OrganID, _DZname);

                    string _posiCode = "";
                    if (!string.IsNullOrEmpty(_PQcode))
                    {
                        _posiCode = _PQcode;
                    }
                    if (!string.IsNullOrEmpty(_DZcode))
                    {
                        _posiCode = _DZcode;
                    }
                    if (!string.IsNullOrEmpty(_XZcode))
                    {
                        _posiCode = _XZcode;
                    }

                    //添加组织关联
                    if (!string.IsNullOrEmpty(_posiCode))
                    {
                        List<string> posiList = new List<string>();
                        posiList.Add(_posiCode);
                        int rePU = new PositionBLL().AddPosi2User(_userID, posiList);
                    }

                    //添加角色
                    string _roleCode = AddRole(_RoleName, _OrganID);

                    //添加角色关联
                    if (!string.IsNullOrEmpty(_roleCode))
                    {
                        List<string> roleList = new List<string>();
                        roleList.Add(_roleCode);
                        int reRU = new UserBLL().AddRole2User(_userID, roleList);
                    }

                    //添加员工
                    AddEmployee(_UserName,_OrganID,_isPrivate);
                    count++;
                }

                string msg = "";
                if (count > 0)
                {
                    msg = msg + "成功上传数据" + count + "条!";
                    msg = msg + "\\n";
                }

                if (iListErrorRowNumber.Count > 0)
                {

                    msg = msg + "数据不全或有误共" + iListErrorRowNumber.Count + "条,请核对以下行号的数据是否有误,并进行修改!";
                    msg = msg + "\\n 有误行号:";
                    foreach (int i in iListErrorRowNumber)
                    {
                        msg += i + ",";
                    }
                    msg = msg + "\\n";
                }

                if (iListFailRowNumber.Count > 0)
                {
                    msg = msg + "车架号已存在共" + iListFailRowNumber.Count + "条!";
                    msg = msg + "\\n 已存在行号:";
                    foreach (int i in iListFailRowNumber)
                    {
                        msg += i + ",";
                    }
                    msg = msg + "\\n";
                }

                UtilityService.Alert(this.Page, msg);

            }
        }
        catch (Exception ex)
        {
            UtilityService.Alert(this.Page, "导入失败!,详细:" + ex.Message);
        }
    }
コード例 #16
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = Int32.Parse(e.CommandArgument.ToString());//获取点击了第几行
            int posID = Int32.Parse(grVPositionManage.DataKeys[rowIndex].Values[0].ToString());

            if (e.CommandName == "DimSetting")
            {
                Response.Redirect("~/System/DimensionSet.aspx?mode=0&posid=" + posID.ToString());
            }
            if (e.CommandName.Equals("Export") || e.CommandName.Equals("ExportNewData"))//答题信息导出 or 数据导出
            {
                PositionBLL temp = new PositionBLL();
                DimensionBLL dBll = new DimensionBLL();

                DataSet dimDS = dBll.GetDimensionAll();
                DataSet dsAll = new DataSet();

                for (int i = 0; i < dimDS.Tables[0].Rows.Count; i++)
                {
                    int dimID = Int32.Parse(dimDS.Tables[0].Rows[i][0].ToString());
                    DataSet dsa =  temp.GetExportDSIncAllDim(posID,dimID);
                    dsa.Tables[0].TableName = dBll.GetDimension(dimID.ToString()).Dimnm;
                    dsAll.Tables.Add(dsa.Tables[0].Copy());
                }

                //2012.3.14,岗位导出时删除无关维度表 begin.
                for (int i = dsAll.Tables.Count - 1; i >= 0; i--)
                {
                    if (dsAll.Tables[i].Rows.Count < 1)
                    {
                        dsAll.Tables.Remove(dsAll.Tables[i]);
                    }
                }
                dsAll.AcceptChanges();
                //2012.3.14,岗位导出时删除无关维度表 end.

                //新的导出格式---数据导出
                DataSet dsPivot = new DataSet();
                if (e.CommandName.Equals("ExportNewData"))
                {
                    //开始进行pivot
                    string activityName = string.Empty;
                    string testerName = string.Empty;

                    TesterInfoBLL tbll = new TesterInfoBLL();
                    ActivityBLL abll = new ActivityBLL();
                    GuidBLL gbll = new GuidBLL();

                    foreach (DataTable t in dsAll.Tables)
                    {
                        Pivot p = new Pivot(t);
                        DataTable dt = p.PivotData("序列号", "原始得分", AggregateFunction.Sum, "题目编号");
                        p = null;
                        dt.TableName = t.TableName;
                        dt.Columns.Add("项目名称").SetOrdinal(0);
                        dt.Columns.Add("姓名").SetOrdinal(1);

                        foreach (DataRow row in dt.Rows)
                        {
                            string guid = row["序列号"].ToString();
                            row["项目名称"] = abll.GetActivityNM(gbll.GetActivityId(guid));
                            row["姓名"] = tbll.GetUserNameByGUID(guid);
                        }
                        dsPivot.Tables.Add(dt);
                    }
                    //pivot结束
                }
                string filePath = Server.MapPath("../userfiles") + @"\position_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".xls";
                string fileName = Path.GetFileName(filePath);

                if (e.CommandName.Equals("Export"))//原始格式--答题信息导出
                {
                    //2013.10.22 add by conghui for export issue begin.
                    foreach (DataTable dt in dsAll.Tables)
                    {
                        for (int i = 0; i < dt.Columns.Count; i++)
                        {
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                if (dt.Rows[j][i] == DBNull.Value || dt.Rows[j][i] == null)//如果单元格为空
                                {
                                    if (i == 2)//第二列是日期列
                                    {
                                        dt.Rows[j][i] = "1900-1-1";
                                    }
                                    else
                                    {
                                        dt.Rows[j][i] = "";
                                    }
                                }
                                else//单元格非空
                                {
                                    if (i == 2)//将日期强制转化为字符串
                                    {
                                        dt.Rows[j][i] = dt.Rows[j][i].ToString();
                                    }
                                }
                            }
                        }
                    }
                    //2013.10.22 add by conghui for export issue end.

                    ExcelLibrary.DataSetHelper.CreateWorkbook(filePath, dsAll);
                }
                else if (e.CommandName.Equals("ExportNewData"))//新的格式--答题数据导出
                {
                    ExcelLibrary.DataSetHelper.CreateWorkbook(filePath, dsPivot);
                }

                Stream stream = null;
                stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                long bytesToRead = stream.Length;
                Response.Clear();
                Response.ContentType = "application/ms-excel";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);

                while (bytesToRead > 0)
                {
                    if (Response.IsClientConnected)
                    {
                        byte[] buffer = new Byte[10000];
                        int length = stream.Read(buffer, 0, 10000);
                        Response.OutputStream.Write(buffer, 0, length);
                        Response.Flush();
                        bytesToRead = bytesToRead - length;
                    }
                    else
                    {
                        bytesToRead = -1;
                    }
                }
            }
        }
コード例 #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ((SiteSystemMaster)Master).InitMenu();
            ((SiteSystemMaster)Master).li2.Attributes.Add("class", "hover ccc");
            ((SiteSystemMaster)Master).b_hmenu1.Style.Add("display", "none");
            ((SiteSystemMaster)Master).b_hmenu2.Style.Clear();
            ((SiteSystemMaster)Master).b_hmenu3.Style.Add("display", "none");
            ((SiteSystemMaster)Master).s_menu2_1.Style.Add("COLOR", "#147ab8");
            ((SiteSystemMaster)Master).s_menu2_1.Style.Add("TEXT-DECORATION", "none");

            /*判断是否是管理员身份*/
            if (Session["username"] == null)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "<script>alert('请先登录系统!');top.location.href='../System/Login.aspx';</script>");
                return;
            }
            else
            {
                if (!IsPostBack)
                {
                    PositionBLL temp = new PositionBLL();
                    DataSet ds = temp.GetPositionAll("");

                    grVPositionManage.DataSource = ds.Tables[0].DefaultView;
                    grVPositionManage.DataSourceID = null;
                    grVPositionManage.DataBind();
                    temp = null;
                }
            }
        }
コード例 #18
0
ファイル: PositionAMV.aspx.cs プロジェクト: kavilee2012/lzQA
    private void BindPositionDLL()
    {
        string strWhere = " OrganID = " + Session["OrganID"].ToString();
        IList<Position> dt = new PositionBLL().GetModelList(strWhere);

        Position p = new Position();
        p.PosiCode = "0";
        p.PosiName = "无";
        if (dt != null)
        {
            dt.Add(p);
        }

        ddl_Father.DataSource = dt;
        ddl_Father.DataValueField = "PosiCode";
        ddl_Father.DataTextField = "PosiName";
        ddl_Father.DataBind();

        ddl_Father.SelectedIndex = dt.Count - 1;
    }
コード例 #19
0
        private void bind()
        {
            //if (string.IsNullOrEmpty(users_id))
            //{
            //    return;
            //}

            PositionBLL positionBll = new PositionBLL();
            DataSet dsPosition = positionBll.GetPositionAll("");
            ddlPosition.DataSource = dsPosition.Tables[0].DefaultView;
            ddlPosition.DataTextField = "position_name";
            ddlPosition.DataValueField = "position_id";

            ddlPosition.DataBind();
            //ActivityBLL temp = new ActivityBLL();
            //DataSet ds = temp.GetActivityByPositionId(ddlPosition.SelectedValue);
            CommentBLL temp = new CommentBLL();
            DataSet ds = temp.GetCommentByPosition(ddlPosition.SelectedValue);
            grVActivityManage.DataSource = ds.Tables[0].DefaultView;
            grVActivityManage.DataSourceID = null;
            grVActivityManage.DataBind();
            temp = null;
        }
コード例 #20
0
        private bool ImportComment(string xlsFileNm)
        {
            try
            {
                if (!File.Exists(xlsFileNm)) return false;

                int posID = Int32.Parse(ddlPosition.SelectedItem.Value);
                Workbook book = Workbook.Load(xlsFileNm);

                PositionBLL posBLL = new PositionBLL();
                DimensionBLL dimBLL = new DimensionBLL();
                CommentBLL comBLL = new CommentBLL();
                Comment com = new Comment();

                DataSet dimDS = dimBLL.GetDimensionAll();
                DataSet posDS = posBLL.GetPositionAll(string.Empty);

                comBLL.DelAllComment(posID);//删除与此岗位相关的所有评语。

                foreach (Worksheet sheet in book.Worksheets)
                {
                    string sheetNm = sheet.Name.Trim();
                    int dimID = -1;//在这里加断点可以监视单个维度的导入情况

                    foreach (DataRow row in dimDS.Tables[0].Rows)
                    {
                        if (row["dimension_name"].ToString().Equals(sheetNm))
                        {
                            dimID = Int32.Parse(row["dimension_id"].ToString().Trim());
                            break;
                        }
                    }
                    for (int rowIndex = sheet.Cells.FirstRowIndex + 1;//忽略第一行(标题行)
                        rowIndex <= sheet.Cells.LastRowIndex; rowIndex++)
                    {
                        Row row = sheet.Cells.GetRow(rowIndex);
                        com.Posion_id = posID;
                        com.Dimension_id = dimID;

                        string score_region = row.GetCell(0).StringValue.Trim();
                        if (score_region.Equals("偏高"))
                        {
                            com.Region_id = 1;
                        }
                        else if (score_region.Equals("适配"))
                        {
                            com.Region_id = 2;
                        }
                        else if (score_region.Equals("稍低"))
                        {
                            com.Region_id = 3;
                        }
                        else if (score_region.Equals("偏低"))
                        {
                            com.Region_id = 4;
                        }

                        for (int i = 1; i < sheet.Cells.LastColIndex + 1; i++)
                        {
                            com.Report_part_id = i;
                            com.Comment_nm = row.GetCell(i).StringValue.Trim();
                            comBLL.Add(com);
                        }
                    }
                }

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }