Asp.net源码专业站
首页->学教实践->人才招聘系统(NIIT学生作品)>>App-Code/classes/Company.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:人才招聘系统(NIIT学生作品)
当前文件:文件类型 NiitJob/App_Code/classes/Company.cs[12K,2009-6-12 11:50:17]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Data.SqlClient; 4using System.Collections; 5using System.Configuration; 6using System.Security.Cryptography; 7using System.Text; 8//该源码下载自www.51aspx.com(51aspx.com) 9 10namespace My.Hr 11{ 12 /// <summary> 13 /// User Class 14 /// Manage users 15 /// </summary> 16 public class Company:DbBase.Base 17 { 18 private string m_Password; 19 private string m_Mail; 20 21 22 /// <summary> 23 /// Property:password 24 /// </summary> 25 public string Password 26 { 27 get 28 { 29 return m_Password; 30 } 31 set 32 { 33 m_Password = value; 34 } 35 } 36 37 38 39 /// <summary> 40 /// Property:Email 41 /// </summary> 42 public string Mail 43 { 44 get 45 { 46 return m_Mail; 47 } 48 set 49 { 50 m_Mail = value; 51 } 52 } 53 54 55 public Company() 56 { 57 58 } 59 60 61 /// <summary> 62 /// Add new user 63 /// need Name、Password、Mail. 64 /// </summary> 65 public void Add() 66 { 67 68 if(IsExist()) 69 { 70 throw new Exception("This name was registered!"); 71 } 72 else 73 { 74 strSQL = "Insert into company (Name,Password,Mail) Values(" 75 + "'" + this.Name + "'," 76 + "'" + Functions.Encrypt(this.Password,1) + "'," 77 + "'" + this.Mail + "')"; 78 79 try 80 { 81 ExecuteSql(strSQL); 82 } 83 catch 84 { 85 throw new Exception("Register FAILED!"); 86 } 87 } 88 89 strSQL = "Select Max(companyID) From company"; 90 int companyId; 91 92 try 93 { 94 companyId = ExecuteSql4Value(strSQL); 95 } 96 catch 97 { 98 throw new Exception("Register FAILED!"); 99 } 100 101 102 strSQL = "Insert into giveJobInfo (companyID) Values("+"'"+ companyId.ToString() +"')"; 103 104 try 105 { 106 ExecuteSql(strSQL); 107 } 108 catch 109 { 110 throw new Exception("Register FAILED!"); 111 } 112 } 113 114 115 /// <summary> 116 /// Add new user(register). 117 /// </summary> 118 public static void Add(string name,string password,string mail) 119 { 120 if(IsExist(name)) 121 { 122 throw new Exception("This name was registered!"); 123 } 124 else 125 { 126 strSQL = "Insert into company (Name,Password,Mail) Values(" 127 + "'" + name + "'," 128 + "'" + Functions.Encrypt(password,1) + "'," 129 + "'" + mail + "')"; 130 131 try 132 { 133 ExecuteSql(strSQL); 134 } 135 catch 136 { 137 throw new Exception("Register FAILED!"); 138 } 139 } 140 strSQL = "Select Max(companyID) From company"; 141 int companyId; 142 143 try 144 { 145 companyId = ExecuteSql4Value(strSQL); 146 } 147 catch 148 { 149 throw new Exception("Register FAILED!"); 150 } 151 152 153 strSQL = "Insert into giveJobInfo (companyID) Values("+"'"+ companyId.ToString() +"')"; 154 155 try 156 { 157 ExecuteSql(strSQL); 158 } 159 catch 160 { 161 throw new Exception("Register FAILED!"); 162 } 163 } 164 165 166 /// <summary> 167 /// Change password 168 /// need Name & Password 169 /// </summary> 170 /// <param name="newPassword">new password (string)</param> 171 172 public void ChangePassword(string newPassword) 173 { 174 strSQL = "Update company Set " 175 + "Password='" + Functions.Encrypt(newPassword,1) + "'" 176 + " Where Name='" + this.Name + "'" 177 + " And Password='" + Functions.Encrypt(this.Password,1) + "'"; 178 179 try 180 { 181 ExecuteSql(strSQL); 182 } 183 catch 184 { 185 throw new Exception("Change password FAILED!"); 186 } 187 } 188 189 190 191 /// <summary> 192 /// Change password 193 /// </summary> 194 /// <param name="name"></param> 195 /// <param name="oldPassword">Old password(string)</param> 196 /// <param name="newPassword">New password(string)</param> 197 198 public static void ChangePassword(string name,string oldPassword,string newPassword) 199 { 200 strSQL = "Update company Set " 201 + "Password='" + Functions.Encrypt(newPassword,1) + "'" 202 + " Where Name='" + name + "'" 203 + " And Password='" + Functions.Encrypt(oldPassword,1) + "'"; 204 205 try 206 { 207 ExecuteSql(strSQL); 208 } 209 catch 210 { 211 throw new Exception("Change password FAILED!"); 212 } 213 } 214 215 216 /// <summary> 217 /// Check user(for getting lost password) 218 /// </summary> 219 /// <returns>return bool value</returns> 220 public bool Check() 221 { 222 strSQL = "Select companyID from company Where Name='" 223 + Name + "'" 224 + " And Mail='" + Mail +"'"; 225 226 try 227 { 228 ExecuteSql4Value(strSQL); 229 return true; 230 } 231 catch 232 { 233 return false; 234 } 235 236 } 237 238 239 /// <summary> 240 /// Check user(for getting lost password) 241 /// </summary> 242 /// <param name="name">Name</param> 243 /// <param name="mail">Email</param> 244 /// <returns>return bool value</returns> 245 public static bool Check(string name,string mail) 246 { 247 strSQL = "Select companyID from company Where Name='" 248 + name + "'" 249 + " And Mail='" + mail +"'"; 250 251 try 252 { 253 ExecuteSql4Value(strSQL); 254 return true; 255 } 256 catch 257 { 258 return false; 259 } 260 261 } 262 263 264 265 /// <summary> 266 /// Delete user 267 /// </summary> 268 /// <param name="companyID">User companyID(int)</param> 269 public static void Delete(int id) 270 { 271 strSQL = "Delete From company Where companyID="+id; 272 273 try 274 { 275 ExecuteSql(strSQL); 276 } 277 catch 278 { 279 throw new Exception("Delete user FAILED!"); 280 } 281 } 282 283 284 /// <summary> 285 /// Delete user 286 /// </summary> 287 public void Delete() 288 { 289 strSQL = "Delete From company Where Name="+Name; 290 291 try 292 { 293 ExecuteSql(strSQL); 294 } 295 catch 296 { 297 throw new Exception("Delete user FAILED!"); 298 } 299 } 300 301 302 /// <summary> 303 /// Delete user 304 /// </summary> 305 /// <param name="Name">User name(string)</param> 306 public static void Delete(string name) 307 { 308 strSQL = "Delete From company Where Name="+name; 309 310 try 311 { 312 ExecuteSql(strSQL); 313 } 314 catch 315 { 316 throw new Exception("Delete user FAILED!"); 317 } 318 } 319 320 321 /// <summary> 322 /// Delete a group user 323 /// </summary> 324 /// <param name="names">Users' names</param> 325 public static void DeleteGroup(string names) 326 { 327 strSQL = "Delete From company Where Name in ('" + names + "')"; 328 329 try 330 { 331 ExecuteSql(strSQL); 332 } 333 catch 334 { 335 throw new Exception("Delete user FAILED!"); 336 } 337 } 338 339 340 /// <summary> 341 /// Does this user exist? 342 /// </summary> 343 /// <returns>return bool value</returns> 344 public bool IsExist() 345 { 346 strSQL = "Select companyID from company Where Name='" 347 + this.Name + "'"; 348 349 try 350 { 351 ExecuteSql4Value(strSQL); 352 return true; 353 } 354 catch 355 { 356 return false; 357 } 358 359 } 360 361 362 /// <summary> 363 /// Does this user exist? 364 /// </summary> 365 /// <param name="name">user name(string)</param> 366 /// <returns>return bool value</returns> 367 public static bool IsExist(string name) 368 { 369 strSQL = "Select companyID from company Where Name='" 370 + name + "'"; 371 372 try 373 { 374 ExecuteSql4Value(strSQL); 375 return true; 376 } 377 catch 378 { 379 return false; 380 } 381 382 } 383 384 385 /// <summary> 386 /// Is a supervisor 387 /// </summary> 388 /// <returns>return bool value</returns> 389 public bool IsSupervisor() 390 { 391 string strManager = ConfigurationSettings.AppSettings["Manager"]; 392 string [] names = strManager.Split(','); 393 int i; 394 395 for(i=0;i<names.Length;i++) 396 { 397 if(Name == names[i]) 398 { 399 return true; 400 } 401 } 402 403 return false; 404 } 405 406 407 /// <summary> 408 /// Is a supervisor 409 /// </summary> 410 /// <param name="name">User Name</param> 411 /// <returns>return bool value</returns> 412 public static bool IsSupervisor(string name) 413 { 414 string strManager = ConfigurationSettings.AppSettings["Manager"]; 415 string [] names = strManager.Split(','); 416 int i; 417 418 for(i=0;i<names.Length;i++) 419 { 420 if(name == names[i]) 421 { 422 return true; 423 } 424 } 425 426 return false; 427 } 428 429 430 /// <summary> 431 /// Get password 432 /// </summary> 433 /// <returns>Password</returns> 434 public string GetPassword() 435 { 436 Random rnd = new Random(); 437 StringBuilder sb = new StringBuilder(); 438 int i; 439 for(i=0;i<32;i++) 440 { 441 sb.Append(rnd.Next(0,9).ToString()); 442 } 443 string Password = sb.ToString();//ASCIIEncoding.ASCII.GetString(random); 444 string EnPassword = Functions.Encrypt(Password,1); 445 446 strSQL = "Update company Set Password = '" 447 + EnPassword + "'" 448 + " Where Name='" + Name + "'"; 449 450 try 451 { 452 ExecuteSql(strSQL); 453 return Password; 454 } 455 catch 456 { 457 throw new Exception("Get Password FAILED"); 458 } 459 } 460 461 462 /// <summary> 463 /// Get password 464 /// </summary> 465 /// <param name="name">User name(string)</param> 466 /// <returns>password</returns> 467 public static string GetPassword(string name) 468 { 469 Random rnd = new Random(); 470 StringBuilder sb = new StringBuilder(); 471 int i; 472 for(i=0;i<32;i++) 473 { 474 sb.Append(rnd.Next(0,9).ToString()); 475 } 476 string Password = sb.ToString();//ASCIIEncoding.ASCII.GetString(random); 477 string EnPassword = Functions.Encrypt(Password,1); 478 479 strSQL = "Update company Set Password = '" 480 + EnPassword + "'" 481 + " Where Name='" + name + "'"; 482 483 try 484 { 485 ExecuteSql(strSQL); 486 return Password; 487 } 488 catch 489 { 490 throw new Exception("Get Password FAILED"); 491 } 492 } 493 494 495 496 /// <summary> 497 /// Login 498 /// Need : Name、Password 499 /// </summary> 500 /// <returns>return bool</returns> 501 public bool Login() 502 { 503 strSQL = "Select companyID from company Where Name='" 504 + this.Name + "'" 505 + " And Password='" + Functions.Encrypt(this.Password,1) +"'"; 506 507 try 508 { 509 ExecuteSql4Value(strSQL); 510 return true; 511 } 512 catch 513 { 514 return false; 515 } 516 } 517 518 519 /// <summary> 520 /// Login 521 /// </summary> 522 /// <param name="name">User name</param> 523 /// <param name="password">Password</param> 524 /// <returns></returns> 525 public static bool Login(string name,string password) 526 { 527 strSQL = "Select companyID from company Where Name='" 528 + name + "'" 529 + " And Password='" + Functions.Encrypt(password,1) +"'"; 530 531 try 532 { 533 ExecuteSql4Value(strSQL); 534 return true; 535 } 536 catch 537 { 538 return false; 539 } 540 } 541 542 543 544 /// <summary> 545 /// Update user information 546 /// Need : Name、Mail、Password. 547 /// </summary> 548 /// <returns></returns> 549 public bool Update() 550 { 551 strSQL = "Update company Set " 552 + "Mail='" + this.Mail 553 +"' Where Name='"+this.Name + "'" 554 + " And Password='" + Functions.Encrypt(this.Password,1) +"'"; 555 556 try 557 { 558 ExecuteSql(strSQL); 559 return true; 560 } 561 catch 562 { 563 throw new Exception("Update failed!"); 564 } 565 } 566 567 568 569 /// <summary> 570 /// Update user information. 571 /// </summary> 572 /// <param name="name">Email(string)</param> 573 /// <param name="mail">User name(string)</param> 574 /// <param name="password">Password(string)</param> 575 /// <returns></returns> 576 public static bool Update(string mail,string name,string password) 577 { 578 strSQL = "Update company Set " 579 + "Mail='" + mail 580 +"' Where Name='"+name + "'" 581 + " And Password='" + Functions.Encrypt(password,1) +"'"; 582 583 try 584 { 585 ExecuteSql(strSQL); 586 return true; 587 } 588 catch 589 { 590 throw new Exception("Update failed!"); 591 } 592 } 593 594 595 596 /// <summary> 597 /// Get all the users 598 /// </summary> 599 /// <returns>return DataSet</returns> 600 public static DataSet GetUsers() 601 { 602 strSQL = "SELECT * FROM company"; 603 604 try 605 { 606 return ExecuteSql4Ds(strSQL); 607 } 608 catch 609 { 610 throw new Exception("Get all the Users Information failed!"); 611 } 612 } 613 614 615 /// <summary> 616 /// Get user info 617 /// </summary> 618 /// <returns></returns> 619 public bool GetUserInfo() 620 { 621 strSQL = "Select * from company Where Name='" 622 + this.Name + "'"; 623 SqlConnection myCn = new SqlConnection(strConn); 624 myCn.Open(); 625 SqlCommand myCmd = new SqlCommand(strSQL,myCn); 626 try 627 { 628 myCmd.ExecuteNonQuery(); 629 SqlDataReader reader = myCmd.ExecuteReader(); 630 if(reader.Read()) 631 { 632 this.ID = reader.GetInt32(0); 633 this.Mail = reader.GetString(3); 634 return true; 635 } 636 else 637 { 638 return false; 639 } 640 } 641 catch(System.Data.SqlClient.SqlException e) 642 { 643 throw new Exception(e.Message); 644 } 645 finally 646 { 647 myCmd.Dispose(); 648 myCn.Close(); 649 } 650 } 651 652 public static DataSet GetCompanyStore(int CompanyId) 653 { 654 strSQL = "Select * from CompanyStoreV Where CompanyId=" + CompanyId.ToString(); 655 try 656 { 657 return ExecuteSql4Ds(strSQL); 658 } 659 catch 660 { 661 throw new Exception("Get Company store failed!"); 662 } 663 } 664 } 665} 666
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:人才招聘系统(NIIT学生作品)
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146