客户管理系统的数验证(OperateAndValidate.cs)

来源:互联网 发布:在手机淘宝买东西流程 编辑:程序博客网 时间:2024/05/16 18:43
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Text.RegularExpressions;
  8. using CrystalDecisions.CrystalReports.Engine;
  9. namespace CRM.BaseClass
  10. {
  11.     class OperateAndValidate
  12.     {
  13.         BaseOperate boperate = new BaseOperate();
  14.         public void cboxBind(string P_str_sqlstr, string P_str_table, string P_str_tbMember, ComboBox cbox)
  15.         {
  16.             DataSet myds = boperate.getds(P_str_sqlstr, P_str_table);
  17.             cbox.DataSource = myds.Tables[P_str_table];
  18.             cbox.DisplayMember = P_str_tbMember;
  19.         }
  20.         public bool validateNum(string P_str_num)
  21.         {
  22.             return Regex.IsMatch(P_str_num, " ^[0-9]*$");
  23.         }
  24.         public bool validatePhone(string P_str_phone)
  25.         {
  26.             return Regex.IsMatch(P_str_phone, @"/d{3,4}-/d{7,8}");
  27.         }
  28.         public bool validateFax(string P_str_fax)
  29.         {
  30.             return Regex.IsMatch(P_str_fax, @"86-/d{2,3}-/d{7,8}");
  31.         }
  32.         public bool validatePostCode(string P_str_postcode)
  33.         {
  34.             return Regex.IsMatch(P_str_postcode, @"/d{6}");
  35.         }
  36.         public bool validateEmail(string P_str_email)
  37.         {
  38.             return Regex.IsMatch(P_str_email, @"/w+([-+.']/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*");
  39.         }
  40.         public bool validateNAddress(string P_str_naddress)
  41.         {
  42.             return Regex.IsMatch(P_str_naddress, @"http(s)?://([/w-]+/.)+[/w-]+(/[/w- ./?%&=]*)?");
  43.         }
  44.         public void autoNum(string P_str_sqlstr, string P_str_table, string P_str_tbColumn, string P_str_codeIndex, string P_str_codeNum, TextBox txt)
  45.         {
  46.             string P_str_Code = "";
  47.             int P_int_Code = 0;
  48.             DataSet myds = boperate.getds(P_str_sqlstr, P_str_table);
  49.             if (myds.Tables[0].Rows.Count == 0)
  50.             {
  51.                 txt.Text = P_str_codeIndex + P_str_codeNum;
  52.             }
  53.             else
  54.             {
  55.                 P_str_Code = Convert.ToString(myds.Tables[0].Rows[myds.Tables[0].Rows.Count - 1][P_str_tbColumn]);
  56.                 P_int_Code = Convert.ToInt32(P_str_Code.Substring(2, 7)) + 1;
  57.                 P_str_Code = P_str_codeIndex + P_int_Code.ToString();
  58.                 txt.Text = P_str_Code;
  59.             }
  60.         }
  61.         public ReportDocument CrystalReports(string P_str_creportName, string P_str_sql)
  62.         {
  63.             ReportDocument reportDocument = new ReportDocument();
  64.             string P_str_creportPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("//")).LastIndexOf("//"));
  65.             P_str_creportPath += @"/SumManage/CReportFile/" + P_str_creportName;
  66.             reportDocument.Load(P_str_creportPath);
  67.             reportDocument.DataDefinition.RecordSelectionFormula = P_str_sql;
  68.             return reportDocument;
  69.         }
  70.     }
  71. }
 
原创粉丝点击