Пример #1
0
 public Position GetPositionById(int id)
 {
     Position position = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", id),
     };
     string sql = "SELECT id, name FROM positions WHERE id = @id; SELECT PA.module_id, PA.accessible, PA.writable FROM position_authorizations AS PA, positions AS P WHERE P.id = PA.position_id and P.id = @id";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             position = new Position();
             position.Id = dr.GetInt32(0);
             position.Name = dr.GetString(1);
         }
         if (position != null)
         {
             dr.NextResult();
             position.ModuleAuthorizations = new List<ModuleAuthorization>();
             while (dr.Read())
             {
                 ModuleAuthorization ma = new ModuleAuthorization();
                 ma.ModuleId = dr.GetInt32(0);
                 ma.Accessible = dr.GetBoolean(1);
                 ma.Writable = dr.GetBoolean(2);
                 position.ModuleAuthorizations.Add(ma);
             }
         }
     }
     return position;
 }
Пример #2
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        List<ModuleAuthorization> mas = new List<ModuleAuthorization>();
        for (int i = 0; i < rpModule.Items.Count; i++)
        {
            RepeaterItem ri = rpModule.Items[i];
            RuleAuthorizationModule ram = rams[i];
            CheckBox chkAccess = (CheckBox)ri.FindControl("chkAccess");
            ModuleAuthorization ma = new ModuleAuthorization();
            ma.ModuleId = ram.Id;
            ma.Accessible = chkAccess.Checked;
            ma.Writable = true;
            mas.Add(ma);
        }
        CompanyOperation.UpdateCompanyAuthorization(id, mas);

        lblMsg.Text = "修改成功!";
    }
Пример #3
0
 private User GetUser(string condition, SqlParameter param)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append("SELECT id, username, password, real_name, id_card, phone, mobile, email, address, nation, company_id, sex, birthday, department_id, marital_status, join_date, contract_date, education, commission, create_date, position_id FROM users WHERE ");
     sb.Append(condition);
     sb.Append(";SELECT OA.module_id, OA.accessible, OA.writable FROM operator_Authorizations AS OA, users AS O WHERE O.is_delete = 0 AND O.id = OA.operator_id and O.");
     sb.Append(condition);
     User user = null;
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sb.ToString(), new SqlParameter[] { param }))
     {
         while (dr.Read())
         {
             user = new User();
             user.Id = dr.GetInt32(0);
             user.Username = dr.GetString(1);
             user.Password = dr.GetString(2);
             user.RealName = dr.GetString(3);
             user.IdCard = dr.GetString(4);
             user.Phone = dr.GetString(5);
             user.Mobile = dr.GetString(6);
             user.Email = dr.GetString(7);
             user.Address = dr.GetString(8);
             user.Nation = dr.GetString(9);
             user.CompanyId = dr.GetInt32(10);
             user.Sex = dr.GetBoolean(11);
             user.Birthday = dr.GetDateTime(12);
             user.DepartmentId = dr.GetInt32(13);
             user.MaritalStatus = dr.GetString(14);
             user.JoinDate = dr.GetDateTime(15);
             user.ContractDate = dr.GetDateTime(16);
             user.Education = dr.GetString(17);
             user.Commission = dr.GetDecimal(18);
             user.CreateDate = dr.GetDateTime(19);
             user.PositionId = dr.GetByte(20);
         }
         if (user != null)
         {
             dr.NextResult();
             user.ModuleAuthorizations = new List<ModuleAuthorization>();
             while (dr.Read())
             {
                 ModuleAuthorization ma = new ModuleAuthorization();
                 ma.ModuleId = dr.GetInt32(0);
                 ma.Accessible = dr.GetBoolean(1);
                 ma.Writable = dr.GetBoolean(2);
                 user.ModuleAuthorizations.Add(ma);
             }
         }
     }
     return user;
 }
Пример #4
0
 public Company GetCompanyById(int id)
 {
     Company company = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", id),
     };
     string sql = "SELECT id, name, area_code, address, contact_person, phone, email, smtp, commission, email_password, qq, msn FROM companies WHERE id = @id; SELECT CA.module_id, CA.accessible, CA.writable FROM company_authorizations AS CA, companies AS C WHERE C.id = CA.company_id and C.id = @id";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             company = new Company();
             company.Id = dr.GetInt32(0);
             company.Name = dr.GetString(1);
             company.AreaCode =EnumConvertor.ConvertToAreaCode(dr.GetByte(2));
             company.Address = dr.GetString(3);
             company.ContactPerson = dr.GetString(4);
             company.Phone = dr.GetString(5);
             company.Email = dr.GetString(6);
             company.Smtp = dr.GetString(7);
             company.Commission = dr.GetDecimal(8);
             company.EmailPassword = dr.GetString(9);
             company.QQ = dr.GetString(10);
             company.MSN = dr.GetString(11);
         }
         if (company != null)
         {
             dr.NextResult();
             company.ModuleAuthorizations = new List<ModuleAuthorization>();
             while (dr.Read())
             {
                 ModuleAuthorization ma = new ModuleAuthorization();
                 ma.ModuleId = dr.GetInt32(0);
                 ma.Accessible = dr.GetBoolean(1);
                 ma.Writable = dr.GetBoolean(2);
                 company.ModuleAuthorizations.Add(ma);
             }
         }
     }
     return company;
 }