/// <summary>
        /// 权限判断
        /// </summary>
        /// <param name="int_comPanyID"></param>
        /// <param name="int_employeeID"></param>
        /// <param name="int_PapersID"></param>
        public bool authorityJudgment(int int_comPanyID, int int_employeeID, int int_PapersID)
        {
            bool bln_author = false;

            if (int_comPanyID == 0)
            {
                Common.Function.jsHint(this, "公司id为空");
            }
            else if (int_PapersID == 0)
            {
                Common.Function.jsHint(this, "试卷id为空");
            }
            else//
            {
                Maticsoft.BLL.PaperManage BPaperManage = new Maticsoft.BLL.PaperManage();
                DataTable dt_PaperManage = BPaperManage.GetList(" PaperID=" + int_PapersID + " and CompanyID=" + int_comPanyID).Tables[0];
                if (dt_PaperManage.Rows.Count > 0)
                {
                    int int_i = 0;
                    foreach (DataRow dr_row in dt_PaperManage.Rows)
                    {
                        if (!bool.Parse(dr_row["IsLongTime"].ToString()))                                                //判断是否长期授权
                        {
                            if (isDateExpired(dr_row["EndTime"].ToString(), DateTime.Now.ToString("yyyy-MM-dd")))        //日期比较是否过期
                            {                                                                                            //false表示过期true表示没有过期
                                if (!isDateExpired(dr_row["StartTime"].ToString(), DateTime.Now.ToString("yyyy-MM-dd"))) //日期比较是否到开始时间
                                {                                                                                        //false表示考试时间已到true表示没有到考试时间
                                    if (int.Parse(dr_row["Used"].ToString()) < int.Parse(dr_row["Num"].ToString()))      //还能不能使用
                                    {
                                        bln_author = true;
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (int.Parse(dr_row["Used"].ToString()) < int.Parse(dr_row["Num"].ToString()))//还能不能使用
                            {
                                bln_author = true;
                                break;
                            }
                        }
                        int_i++;
                    }
                }
                else
                {
                    Common.Function.jsHint(this, "该公司没有权限");
                }
            }
            if (!bln_author)
            {
                Common.Function.jsHint(this, "权限过期或已使用完");
            }

            return(bln_author);
        }
Beispiel #2
0
        /// <summary>
        /// 根据公司id和名称查找指定公司是否存在(不存在则添加并返回id)
        /// 判断是否存在试卷权限,不存在添加
        /// </summary>
        /// <param name="str_ID"></param>
        /// <param name="str_companyName"></param>
        /// <returns></returns>
        private bool GetCompany(string str_ID, string str_companyName)
        {
            string[] arr_paperID = { "122", "123", "125" };                           //试卷id

            Maticsoft.BLL.Company BCompany = new Maticsoft.BLL.Company();             //公司

            Maticsoft.BLL.PaperManage BPaperManage = new Maticsoft.BLL.PaperManage(); //试卷授权

            try
            {
                List <Maticsoft.Model.Company> listCompany = BCompany.GetModelList(" obj_ID=" + int.Parse(str_ID) + " AND Name='" + str_companyName + "' ");
                if (listCompany != null && listCompany.Count > 0)//该公司存在
                {
                    //判断有没有试卷授权
                    List <Maticsoft.Model.PaperManage> listPaperManage = BPaperManage.GetModelList(" CompanyID=" + listCompany[0].ID + " AND PaperID in(122,123,125)");
                    if (listPaperManage != null && listPaperManage.Count > 0)//该公司有试卷授权()
                    {
                        List <string> paperID = new List <string>();

                        for (int i = 0; i < listPaperManage.Count; i++)
                        {
                            paperID.Add(listPaperManage[i].PaperID.ToString());//将授权试卷id拿出来
                        }

                        List <string> list_paperID = new List <string>(); //保存没有授权试卷id
                                                                          //判断是否存在122,123,125这三份试卷
                        for (int i = 0; i < arr_paperID.Length; i++)
                        {
                            if (!paperID.Contains(arr_paperID[i]))//判断授权试卷中有没有122,123,125这三份试卷
                            {
                                list_paperID.Add(arr_paperID[i]);
                            }
                        }
                        if (list_paperID != null && list_paperID.Count > 0)//如果存在没有授权的则添加
                        {
                            for (int j = 0; j < list_paperID.Count; j++)
                            {
                                Maticsoft.Model.PaperManage MPaperManage = new Maticsoft.Model.PaperManage();
                                MPaperManage.PaperID        = int.Parse(list_paperID[j].ToString());
                                MPaperManage.CompanyID      = listCompany[0].ID;
                                MPaperManage.IsLongTime     = true;
                                MPaperManage.CreateDateTime = DateTime.Now;
                                MPaperManage.Title          = listCompany[0].Name + "授权";
                                MPaperManage.Num            = 100;
                                if (BPaperManage.Add(MPaperManage) <= 0)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    else//改公司没有试卷授权
                    {
                        for (int j = 0; j < arr_paperID.Length; j++)
                        {
                            Maticsoft.Model.PaperManage MPaperManage = new Maticsoft.Model.PaperManage();
                            MPaperManage.PaperID        = int.Parse(arr_paperID[j].ToString());
                            MPaperManage.CompanyID      = listCompany[0].ID;
                            MPaperManage.IsLongTime     = true;
                            MPaperManage.CreateDateTime = DateTime.Now;
                            MPaperManage.Title          = listCompany[0].Name + "授权";
                            MPaperManage.Num            = 100;
                            if (BPaperManage.Add(MPaperManage) <= 0)
                            {
                                return(false);
                            }
                        }
                    }
                }
                else//公司不存在(添加)
                {
                    Maticsoft.Model.Company MCompany = new Maticsoft.Model.Company();
                    MCompany.obj_ID     = int.Parse(str_ID);
                    MCompany.Name       = str_companyName;
                    MCompany.CreateTime = DateTime.Now;
                    int int_companyid = BCompany.Add(MCompany);
                    if (int_companyid > 0)//添加成功
                    {
                        //添加试卷授权
                        for (int j = 0; j < arr_paperID.Length; j++)
                        {
                            Maticsoft.Model.PaperManage MPaperManage = new Maticsoft.Model.PaperManage();
                            MPaperManage.PaperID        = int.Parse(arr_paperID[j].ToString());
                            MPaperManage.CompanyID      = int_companyid;
                            MPaperManage.IsLongTime     = true;
                            MPaperManage.CreateDateTime = DateTime.Now;
                            MPaperManage.Title          = str_companyName + "授权";
                            MPaperManage.Num            = 100;
                            if (BPaperManage.Add(MPaperManage) <= 0)
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                throw;
                //return false;
            }

            return(true);
        }