您的位置:首页 > 运维架构

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

2008-11-22 17:17 375 查看
using System;

using System.Collections.Generic;

using System.Text;

using System.Windows.Forms;

using System.Data;

using System.Data.SqlClient;

using System.Text.RegularExpressions;

using CrystalDecisions.CrystalReports.Engine;

namespace CRM.BaseClass

{

class OperateAndValidate

{

BaseOperate boperate = new BaseOperate();

public void cboxBind(string P_str_sqlstr, string P_str_table, string P_str_tbMember, ComboBox cbox)

{

DataSet myds = boperate.getds(P_str_sqlstr, P_str_table);

cbox.DataSource = myds.Tables[P_str_table];

cbox.DisplayMember = P_str_tbMember;

}

public bool validateNum(string P_str_num)

{

return Regex.IsMatch(P_str_num, " ^[0-9]*$");

}

public bool validatePhone(string P_str_phone)

{

return Regex.IsMatch(P_str_phone, @"/d{3,4}-/d{7,8}");

}

public bool validateFax(string P_str_fax)

{

return Regex.IsMatch(P_str_fax, @"86-/d{2,3}-/d{7,8}");

}

public bool validatePostCode(string P_str_postcode)

{

return Regex.IsMatch(P_str_postcode, @"/d{6}");

}

public bool validateEmail(string P_str_email)

{

return Regex.IsMatch(P_str_email, @"/w+([-+.']/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*");

}

public bool validateNAddress(string P_str_naddress)

{

return Regex.IsMatch(P_str_naddress, @"http(s)?://([/w-]+/.)+[/w-]+(/[/w- ./?%&=]*)?");

}

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)

{

string P_str_Code = "";

int P_int_Code = 0;

DataSet myds = boperate.getds(P_str_sqlstr, P_str_table);

if (myds.Tables[0].Rows.Count == 0)

{

txt.Text = P_str_codeIndex + P_str_codeNum;

}

else

{

P_str_Code = Convert.ToString(myds.Tables[0].Rows[myds.Tables[0].Rows.Count - 1][P_str_tbColumn]);

P_int_Code = Convert.ToInt32(P_str_Code.Substring(2, 7)) + 1;

P_str_Code = P_str_codeIndex + P_int_Code.ToString();

txt.Text = P_str_Code;

}

}

public ReportDocument CrystalReports(string P_str_creportName, string P_str_sql)

{

ReportDocument reportDocument = new ReportDocument();

string P_str_creportPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("//")).LastIndexOf("//"));

P_str_creportPath += @"/SumManage/CReportFile/" + P_str_creportName;

reportDocument.Load(P_str_creportPath);

reportDocument.DataDefinition.RecordSelectionFormula = P_str_sql;

return reportDocument;

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: