申请会员 ID:seaven[申请通过]
ID:seavenEmai:seaven@vip.qq.com
个人简介:在一家做应用软件的公司上班.主要语言用的是c#.业余做c++开发。
作品:项目中的一些通用代码
/// <summary>
/// 通用上传文件类
/// </summary>
public class FileUpLoadCommon
{
#region "Private Variables"
private string _path; // 上传文件的路径
private string _fileName; // 文件名称
private string _newFileName=""; // 新的文件名
private string _fileName_s; // 缩略图文件名称
private string _fileName_sy; // 水印图文件名称(文字)
private string _fileName_syp; // 水印图文件名称(图片)
private string _webFilePath; // 服务器端文件路径
private string _webFilePath_s; // 服务器端缩略图路径
private string _webFilePath_sy; // 服务器端带水印图路径(文字)
private string _webFilePath_syp; // 服务器端带水印图路径(图片)
private string _webFilePath_sypf; // 服务器端水印图路径(图片)
private string _errorMsg; // 错误信息
private bool _isDate = true; // 是否加上日期
private bool _isThumbnail = true; // 是否产生缩图
private bool _isWatermarkT = false; // 是否产生水印文字
private bool _isWatermarkP = false; // 是否产生水印叠加图片
private bool _isOnly = true; // 是否只产生一个文件,原始文件+加水印文字+加水印图片
//private bool _isImage = true; // 是否只充许图片
private int _width = Common.UpImgWidth; // 缩图宽度
private int _height = Common.UpImgHeight; // 缩图高度
private string _mode = "Auto"; // 缩图模式 "HW"://指定高宽缩放(可能变形)"W"//指定宽,高按比例 "H"//指定高,宽按比例"Cut"://指定高宽裁减(不变形) Auto:自动
private string _addText = "supesoft.com"; // 水印文字
private string _addPicture = Common.UpLoadDir+"shuiyin.jpg"; // 水印文字
private int _fileSize = 0; // 图片大小
private int _fileWidth = 0; // 图片宽度
private int _fileHeight = 0; // 图片高度
private string _fileType; // 文件类型
private string _fileExt; //文件扩展名
#endregion
#region "出错信息"
/// <summary>
/// 出错信息
/// </summary>
public string errorMsg
{
get {
return _errorMsg;
}
}
#endregion
#region 属性 -- 旧文件名
/// <summary>
/// 旧文件名
/// </summary>
public string fileName
{
get
{
return _fileName;
}
}
#endregion
#region 属性 -- 上传后新文件名
/// <summary>
/// 上传后新文件名
/// </summary>
public string newFileName
{
get
{
return _newFileName;
}
}
#endregion
#region 属性 -- 缩图文件名
/// <summary>
/// 缩图文件名
/// </summary>
public string fileName_s
{
get
{
return _fileName_s;
}
}
#endregion
#region 属性 -- 加文字水印的图片
/// <summary>
/// 加文字水印的图片
/// </summary>
public string fileName_sy
{
get
{
return _fileName_sy;
}
}
#endregion
#region 属性 -- 加图片水印的图片
/// <summary>
/// 加图片水印的图片
/// </summary>
public string fileName_syp
{
get
{
return _fileName_syp;
}
}
#endregion
#region 属性 -- 上传的文件的路径
/// <summary>
/// 上传的文件的路径
/// </summary>
public string path
{
get
{
return _path;
}
}
#endregion
#region 属性 -- 文件大小
/// <summary>
/// 文件大小
/// </summary>
public int fileSize
{
get
{
return _fileSize;
}
}
#endregion
#region 属性 -- 图片原始的宽度
/// <summary>
/// 图片原始的宽度
/// </summary>
public int fileWidth
{
get
{
return _fileWidth;
}
}
#endregion
#region 属性 -- 图片原始的高度
/// <summary>
/// 图片原始的高度
/// </summary>
public int fileHeight
{
get { return _fileHeight; }
}
#endregion
#region 属性 -- 文件的类型
/// <summary>
/// 文件的类型
/// </summary>
public string fileType
{
get { return _fileType; }
}
#endregion
#region 属性 -- 设置水印文字
/// <summary>
/// 设置水印文字
/// </summary>
public string addText
{
set { _addText = value; }
}
#endregion
#region 属性 -- 设置水印图片
/// <summary>
/// 设置水印图片
/// </summary>
public string addPicture
{
set { _addPicture = value; }
}
#endregion
#region "文件扩展名"
/// <summary>
/// 文件扩展名
/// </summary>
public string fileExt
{
get {
return _fileExt;
}
}
#endregion
#region 构造函数
/// <summary>
/// 构造函数
/// </summary>
public FileUpLoadCommon()
: this("/public/", true)
{
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="filePath">文件路径</param>
/// <param name="isDate">是否按日期创建目录</param>
public FileUpLoadCommon(string filePath, bool isDate)
{
_path = filePath;
_isDate = isDate;
if (_isDate)
_path += DateTime.Now.ToString("yyyyMMdd") + "/";
string p = HttpContext.Current.Server.MapPath(_path);
//如果目录不存在,将创建目录
if (!Directory.Exists(p))
Directory.CreateDirectory(p);
}
#endregion
#region 方法 -- 保存文件
/// <summary>
/// 指定缩图的宽高
/// </summary>
/// <param name="fu">文件类型</param>
/// <param name="Width">宽</param>
/// <param name="Height">高</param>
/// <returns></returns>
public bool SaveImage(HttpPostedFile fu, int Width, int Height)
{
_width = Width;
_height = Height;
return SaveFile(fu,true);
}
/// <summary>
/// 指定缩图的宽高
/// </summary>
/// <param name="fu">文件类型</param>
/// <param name="Width">宽</param>
/// <param name="Height">高</param>
/// <param name="Mode">缩图模式 "HW"://指定高宽缩放(可能变形)"W"//指定宽,高按比例 "H"//指定高,宽按比例"Cut"://指定高宽裁减(不变形) </param>
/// <returns></returns>
public bool SaveImage(HttpPostedFile fu, int Width, int Height, string Mode)
{
_width = Width;
_height = Height;
_mode = Mode;
return SaveFile(fu,true);
}
#endregion
#region 方法 -- 保存文件
/// <summary>
/// 保存文件
/// </summary>
/// <param name="fu">上传文件对象</param>
/// <param name="IsImage">是否图片</param>
/// <param name="IsMakeSize">是否缩图</param>
/// <returns>成功/失败</returns>
public bool SaveFile(HttpPostedFile fu,bool IsImage,bool IsMakeSize)
{
_isThumbnail = IsMakeSize;
if (fu.ContentLength > 0)
{
string fileContentType = fu.ContentType;
string name = fu.FileName; // 客户端文件路径
FileInfo file = new FileInfo(name);
_fileExt = file.Extension;
_fileType = fu.ContentType;
_fileSize = fu.ContentLength;
bool isfileTypeImages = false;
if (fileContentType == "image/x-png" || fileContentType == "image/bmp" || fileContentType == "image/gif" || fileContentType == "image/pjpeg" || fileContentType == "image/jpeg")
{
isfileTypeImages = true;
}
if (IsImage == true && isfileTypeImages == false)
{
_errorMsg = "文件类型不是图片!";
return false;
}
//检测文件扩展名是否正确
if (!Common.Check_Char_Is(file.Extension.Substring(1).ToLower(), FrameSystemInfo.GetSystemInfoTable.S_SystemConfigData.C_UploadFileExt.ToLower()))
{
_errorMsg = string.Format("文件扩展名不符合系统需求:{0}", FrameSystemInfo.GetSystemInfoTable.S_SystemConfigData.C_UploadFileExt);
//fu.Dispose();
return false;
}
if (_fileSize / 1024 > FrameSystemInfo.GetSystemInfoTable.S_SystemConfigData.C_UploadSizeKb)
{
_errorMsg = string.Format("上传文件超过系统允许大小:{0}K", FrameSystemInfo.GetSystemInfoTable.S_SystemConfigData.C_UploadSizeKb);
//fu.Dispose();
return false;
}
_fileName = file.Name; // 文件名称
_newFileName = CreateFileName() + file.Extension;
_webFilePath = HttpContext.Current.Server.MapPath(_path + _newFileName); // 服务器端文件路径
if (isfileTypeImages)
{
_fileName_s = "s_" + _newFileName; // 缩略图文件名称
if (_isOnly)
{
_fileName_sy = _newFileName; // 水印图文件名称(文字)
_fileName_syp = _newFileName; // 水印图文件名称(图片)
}
else
{
_fileName_sy = "sy_" + _newFileName; // 水印图文件名称(文字)
_fileName_syp = "syp_" + _newFileName; // 水印图文件名称(图片)
}
_webFilePath_s = HttpContext.Current.Server.MapPath(_path + _fileName_s); // 服务器端缩略图路径
_webFilePath_sy = HttpContext.Current.Server.MapPath(_path + _fileName_sy); // 服务器端带水印图路径(文字)
_webFilePath_syp = HttpContext.Current.Server.MapPath(_path + _fileName_syp); // 服务器端带水印图路径(图片)
_webFilePath_sypf = HttpContext.Current.Server.MapPath(_addPicture); // 服务器端水印图路径(图片)
//检查文件是否存在
if (!File.Exists(_webFilePath))
{
try
{
fu.SaveAs(_webFilePath); // 使用 SaveAs 方法保存文件
if (_isWatermarkT)
AddShuiYinWord(_webFilePath, _webFilePath_sy);
if (_isWatermarkP)
AddShuiYinPic(_webFilePath, _webFilePath_syp, _webFilePath_sypf);
if (_isThumbnail)
MakeThumbnail(_webFilePath, _webFilePath_s, _width, _height, _mode); // 生成缩略图方法
// 只有上传完了,才能获取图片大小
if (File.Exists(_webFilePath))
{
System.Drawing.Image originalImage = System.Drawing.Image.FromFile(_webFilePath);
try
{
_fileHeight = originalImage.Height;
_fileWidth = originalImage.Width;
}
finally
{
originalImage.Dispose();
}
}
_errorMsg = string.Format("提示:文件“{0}”成功上传,并生成“{1}”缩略图,文件类型为:{2},文件大小为:{3}B", _newFileName, _fileName_s, fu.ContentType, fu.ContentLength);
//fu.Dispose();
return true;
}
catch (Exception ex)
{
_errorMsg = "提示:文件上传失败,失败原因:" + ex.Message;
}
}
else
{
_errorMsg = "提示:文件已经存在,请重命名后上传";
}
}
else
{
//上传文件
//检查文件是否存在
if (!File.Exists(_webFilePath))
{
try
{
fu.SaveAs(_webFilePath); // 使用 SaveAs 方法保存文件
_errorMsg = string.Format("提示:文件“{0}”成功上传,并生成“{1}”缩略图,文件类型为:{2},文件大小为:{3}B", _newFileName, _fileName_s, fu.ContentType, fu.ContentLength);
//fu.Dispose();
return true;
}
catch (Exception ex)
{
_errorMsg = "提示:文件上传失败,失败原因:" + ex.Message;
}
}
else
_errorMsg = "提示:文件已经存在,请重命名后上传";
}
}
else {
_errorMsg = "提示:文件不能为空,请选择要上传文件!";
}
return false;
}
/// <summary>
/// 保存文件
/// </summary>
/// <param name="fu">文件对象</param>
/// <param name="IsImage">是否图片</param>
/// <returns>成功/失败</returns>
public bool SaveFile(HttpPostedFile fu, bool IsImage)
{
return SaveFile(fu, IsImage, true);
}
/// <summary>
/// 保存文件
/// </summary>
/// <param name="fu">上传文件对象</param>
/// <param name="IsImage">是否图片</param>
/// <returns>成功/失败</returns>
public bool SaveFile(FileUpload fu, bool IsImage)
{
bool rBool = false;
rBool = SaveFile(fu.PostedFile, IsImage);
fu.Dispose();
return rBool;
}
#endregion
#region 方法 -- 创建新的文件名
/// <summary>
/// 创建新的文件名
/// </summary>
/// <returns></returns>
public string CreateFileName()
{
string guid = System.Guid.NewGuid().ToString().ToLower();
guid = guid.Replace("-", "");
return DateTime.Now.ToString("yyyyMMddhhmmss") + guid.Substring(0, 4);
}
#endregion
#region 方法 -- 删除文件
/// <summary>
/// 删除文件
/// </summary>
/// <param name="filename"></param>
public static void DeleteFile(string filename)
{
string s = HttpContext.Current.Server.MapPath(filename);
if (File.Exists(s))
{
try
{
File.Delete(s);
}
catch
{ }
}
}
#endregion
#region 方法 -- 生成缩略图
/**/
/// <summary>
/// 生成缩略图
/// </summary>
/// <param name="originalImagePath">源图路径(物理路径)</param>
/// <param name="thumbnailPath">缩略图路径(物理路径)</param>
/// <param name="width">缩略图宽度</param>
/// <param name="height">缩略图高度</param>
/// <param name="mode">生成缩略图的方式</param>
public static void MakeThumbnail(string originalImagePath, string thumbnailPath, int width, int height, string mode)
{
System.Drawing.Image originalImage = System.Drawing.Image.FromFile(originalImagePath);
int towidth = width;
int toheight = height;
int x = 0;
int y = 0;
int ow = originalImage.Width;
int oh = originalImage.Height;
if (ow < towidth && oh < toheight)
{
originalImage.Save(thumbnailPath);
}
else
{
switch (mode.ToUpper())
{
case "HW"://指定高宽缩放(可能变形)
break;
case "W"://指定宽,高按比例
toheight = originalImage.Height * width / originalImage.Width;
break;
case "H"://指定高,宽按比例
towidth = originalImage.Width * height / originalImage.Height;
break;
case "CUT"://指定高宽裁减(不变形)
if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight)
{
oh = originalImage.Height;
ow = originalImage.Height * towidth / toheight;
y = 0;
x = (originalImage.Width - ow) / 2;
}
else
{
ow = originalImage.Width;
oh = originalImage.Width * height / towidth;
x = 0;
y = (originalImage.Height - oh) / 2;
}
break;
case "AUTO": //自动适应高度
if (ow > oh)
{
//newwidth = 200;
toheight = (int)((double)oh / (double)ow * (double)towidth);
}
else
{
//newheight = 200;
towidth = (int)((double)ow / (double)oh * (double)toheight);
}
break;
default:
break;
}
//进行缩图
Bitmap img = new Bitmap(towidth, toheight);
img.SetResolution(72f, 72f);
Graphics gdiobj = Graphics.FromImage(img);
gdiobj.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gdiobj.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
gdiobj.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
gdiobj.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
gdiobj.FillRectangle(new SolidBrush(Color.White), 0, 0,
towidth, toheight);
Rectangle destrect = new Rectangle(0, 0,
towidth, toheight);
gdiobj.DrawImage(originalImage, destrect, 0, 0, ow,
oh, GraphicsUnit.Pixel);
System.Drawing.Imaging.EncoderParameters ep = new System.Drawing.Imaging.EncoderParameters(1);
ep.Param = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)100);
System.Drawing.Imaging.ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
try
{
if (ici != null)
{
img.Save(thumbnailPath, ici, ep);
}
else
{
img.Save(thumbnailPath, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
catch (System.Exception e)
{
throw e;
}
finally
{
gdiobj.Dispose();
img.Dispose();
}
}
originalImage.Dispose();
}
private static System.Drawing.Imaging.ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
System.Drawing.Imaging.ImageCodecInfo[] encoders;
encoders = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders();
for (j = 0; j < encoders.Length; ++j)
{
if (encoders.MimeType == mimeType)
return encoders;
}
return null;
}
#endregion
#region 方法 -- 在图片上增加文字水印
/**/
/// <summary>
/// 在图片上增加文字水印
/// </summary>
/// <param name="Path">原服务器图片路径</param>
/// <param name="Path_sy">生成的带文字水印的图片路径</param>
protected void AddShuiYinWord(string Path, string Path_sy)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(image, 0, 0, image.Width, image.Height);
System.Drawing.Font f = new System.Drawing.Font("Verdana", 16);
System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);
g.DrawString(_addText, f, b, 15, 15);
g.Dispose();
image.Save(Path_sy);
image.Dispose();
}
#endregion
#region 方法 -- 在图片上生成图片水印
/**/
/// <summary>
/// 在图片上生成图片水印
/// </summary>
/// <param name="Path">原服务器图片路径</param>
/// <param name="Path_syp">生成的带图片水印的图片路径</param>
/// <param name="Path_sypf">水印图片路径</param>
protected void AddShuiYinPic(string Path, string Path_syp, string Path_sypf)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
g.Dispose();
image.Save(Path_syp);
image.Dispose();
}
#endregion
}
图像处理类,由于分层了,不能一一贴出来,贴一部分。
public class DrawWords
{
public DrawWords(){}
public Image DrawFont(String words, Font font, Color wordColor, Color bordColor, int weith, int height,int left,int top)
{
Bitmap bmp = new Bitmap(weith,height);
Graphics g = Graphics.FromImage(bmp);
SolidBrush brush = new SolidBrush(wordColor);
//g.DrawString(words, font, brush, new PointF(left, top));
int singtonlength = Convert.ToInt16(font.Size);
int stringlength = words.Length;
int totellength = singtonlength * stringlength;
if (totellength > bmp.Width)
{
int wordinline = weith / singtonlength - 3;
int tl = stringlength % wordinline;
int line;
if (tl != 0)
{
line = stringlength / wordinline + 1;
for (int i = 1; i <= line; i++)
{
if (i == 1)
{
g.DrawString(words.Substring(0, wordinline), font, brush, new PointF(left, top));
}
else if (i != line)
{
g.DrawString(words.Substring((i - 1) * wordinline, wordinline), font, brush, new PointF(left, (i - 1) * (font.Size + 5) + top));
}
else
{
g.DrawString(words.Substring((i - 1) * wordinline, tl), font, brush, new PointF(left, (i - 1) * (font.Size + 5) + top));
}
}
}
else
{
line = stringlength / wordinline;
for (int i = 1; i < line + 1; i++)
{
if (i == 1)
{
g.DrawString(words.Substring(0, wordinline), font, brush, new PointF(left, top));
}
else
{
g.DrawString(words.Substring((i - 1) * wordinline, wordinline), font, brush, new PointF(left, (i - 1) * (font.Size + 5) + top));
}
}
}
}
else
{
g.DrawString(words, font, brush, new PointF(left, top));
}
brush.Dispose();
g.Dispose();
GC.Collect();
for (int i = 0; i < bmp.Width; i++)
{
for (int j = 0; j < bmp.Height; j++)
{
if (!ColorEquals(bmp.GetPixel(i, j), wordColor))
{
if (i < bmp.Width - 1 && j < bmp.Height - 1)
{
if (ColorEquals(bmp.GetPixel(i + 1, j), wordColor) || ColorEquals(bmp.GetPixel(i, j + 1), wordColor) || ColorEquals(bmp.GetPixel(i + 1, j + 1), wordColor))
{
bmp.SetPixel(i, j, bordColor);
}
}
if (i > 0 && j > 0)
{
if (ColorEquals(bmp.GetPixel(i - 1, j), wordColor) || ColorEquals(bmp.GetPixel(i, j - 1), wordColor) || ColorEquals(bmp.GetPixel(i - 1, j - 1), wordColor))
{
bmp.SetPixel(i, j, bordColor);
}
}
}
}
}
return bmp;
}
private bool ColorEquals(Color c1, Color c2)
{
if (c1.A != c2.A)
return false;
if (c1.R != c2.R)
return false;
if (c1.G != c2.G)
return false;
if (c1.B != c2.B)
return false;
return true;
}
} http://blog.csdn.net/lee576/archive/2008/10/08/3033911.aspx
这07年的东西是你写的? 回复 2# Hmily
这个是项目中的,通用类。只要是这个项目开发人员都可以去添加修改。这个项目不是某一个人完成的。
难道非要写明项目中的某一个模块是自己做写的吗?即使同一个类,有些方法也不是一个人完成的。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.IO;
using mmclub.Common;
using mmclub.Model.SmsInfoEntities;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
namespace mmclub.DAL.SmsInfoManager
{
public class SmsInfoAccessor
{
public SmsInfoAccessor()
{
//构造函数
}
/// <summary>
/// 首页得到10条短信种子数据
/// </summary>
/// <returns></returns>
public static DataSet GetSmsSeed()
{
DataBase db = new DataBase();
string strSql = "SELECT TOP 10 ROW_NUMBER() OVER (ORDER BY a.addTime DESC)AS Row, a.smsId,a.mobileNo,SUBSTRING(a.smsContent,1,20)smsName,a.smsContent,a.addTime,a.flag,a.classId,a.stat,a.toStat,b.className FROM SmsInfo a,ClassMmInfo AS bWHERE a.classid = b.classid AND isSeed = 3";
return db.GetDataSet(strSql);
}
/// <summary>
/// 得到种子库数据
/// </summary>
/// <returns></returns>
public static DataSet GetSmsSeeds(int startIndex, int endIndex, byte docount)
{
DataBase db = new DataBase();
SqlParameter[] parameters = {
new SqlParameter("@startIndex",SqlDbType.Int),
new SqlParameter("@endIndex",SqlDbType.Int),
new SqlParameter("@docount",SqlDbType.Bit)};
parameters.Value = Convert.ToInt32(startIndex);
parameters.Value = Convert.ToInt32(endIndex);
parameters.Value = Convert.ToByte(docount);
return db.ExecuteProcReturnDataSet("mm_getsmsseed", parameters);
}
/// <summary>
/// 根据短信种子编号得到短信详细数据
/// </summary>
/// <param name="smsId"></param>
/// <returns></returns>
public static DataSet GetSmsSeedInfo(Int64 smsId)
{
DataBase db = new DataBase();
SqlParameter[] parameters = {
new SqlParameter("@smsId",SqlDbType.BigInt)};
parameters.Value = Convert.ToInt64(smsId);
string strSql = "SELECT * FROM SmsInfo WHERE smsId = @smsId";
return db.GetDataSetPara(strSql,parameters);
}
/// <summary>
/// 上传一条短信种子
/// </summary>
/// <param name="_smsData">短信种子实体</param>
/// <returns></returns>
public static Int32 Insert_Sms(SmsInfoData _smsData)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "INSERT INTO dbo.SmsInfo(mobileNo,smsContent,classId,addTime,uploadCount,isSeed,isDemand) OUTPUT INSERTED.mobileNo VALUES(@mobileNo,@smsContent,@classId,@addTime,@uploadCount,@isSeed,@isDemand)";
DbCommand command = db.GetSqlStringCommand(strSql);
db.AddInParameter(command, "@mobileNo", DbType.Int64, _smsData.mobileNo);
db.AddInParameter(command, "@smsContent", DbType.String, _smsData.smsContent);
db.AddInParameter(command, "@classId", DbType.Int32, _smsData.classId);
db.AddInParameter(command, "@addTime", DbType.DateTime, _smsData.addTime);
db.AddInParameter(command, "@uploadCount", DbType.Int32, _smsData.uploadCount);
db.AddInParameter(command, "@isSeed", DbType.Int32, _smsData.isSeed);
db.AddInParameter(command, "@isDemand", DbType.Int32, _smsData.isDemand);
try
{
return db.ExecuteNonQuery(command);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 把昨天的全发后的一条种子短信的状态更新为3用于网站显示
/// </summary>
/// <returns></returns>
public static Int32 UpdateSmsIsSeedStat()
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "UPDATE dbo.SmsInfo SET isSeed = 3 WHERE mobileNo = 8 AND isSeed = 5";
try
{
return db.ExecuteNonQuery(CommandType.Text, strSql);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 修改短信发送标志为成功代码为"1"
/// </summary>
/// <param name="smsId">短信编号</param>
public static void SetSendFlag(Int64 smsId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "UPDATE SmsInfo SET flag = 1 WHERE smsId = @smsId";
DbCommand command = db.GetSqlStringCommand(strSql);
db.AddInParameter(command, "@smsId", DbType.Int64, smsId);
try
{
db.ExecuteNonQuery(command);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 根据关键词或分类ID查询短信
/// </summary>
/// <param name="startIndex">起始页</param>
/// <param name="endIndex">结束页</param>
/// <param name="docount">是否统计总数</param>
/// <param name="keyword">关键词</param>
/// <param name="classId">分类ID</param>
/// <returns>DataSet</returns>
public static DataSet GetSmsInfo(int startIndex, int endIndex, byte docount,string keyword,int classId)
{
DataBase db = new DataBase();
SqlParameter[] parameters = {
new SqlParameter("@startIndex",SqlDbType.Int),
new SqlParameter("@endIndex",SqlDbType.Int),
new SqlParameter("@docount",SqlDbType.Bit),
new SqlParameter("@keyword",SqlDbType.VarChar,100),
new SqlParameter("@classId",SqlDbType.Int)};
parameters.Value = Convert.ToInt32(startIndex);
parameters.Value = Convert.ToInt32(endIndex);
parameters.Value = Convert.ToByte(docount);
parameters.Value = Common.Common.inSQL(keyword);
parameters.Value = Convert.ToInt32(classId);
return db.ExecuteProcReturnDataSet("mm_smsinfo_select", parameters);
}
/// <summary>
/// 得到短信分类
/// </summary>
/// <returns></returns>
public static DataSet GetClass()
{
DataBase db = new DataBase();
string strSql = "SELECT * FROM ClassMmInfo";
return db.GetDataSet(strSql);
}
/// <summary>
/// 根据短信编号得到短信内容
/// </summary>
/// <param name="smsId">短信编号</param>
/// <returns>短信内容</returns>
public static string GetSmsContent(Int64 smsId)
{
string smsContent = "";
DataBase db = new DataBase();
SqlParameter[] parameters = {
new SqlParameter("@smsId",SqlDbType.BigInt)};
parameters.Value = Convert.ToInt64(smsId);
string strSql = "SELECT * FROM SmsInfo WHERE smsId = @smsId";
DataSet ds = db.GetDataSetPara(strSql,parameters);
if (ds.Tables.Rows.Count > 0)
{
smsContent = ds.Tables.Rows["smsContent"].ToString();
return smsContent;
}
else
{
return smsContent;
}
}
/// <summary>
/// 下载此短信后,短信的下载次数自动加一
/// </summary>
/// <param name="smsId">短信ID</param>
public static void UpdateSmsBrowseStat(Int64 smsId)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand command = db.GetStoredProcCommand("mm_updatesmsbrowsestat");
db.AddInParameter(command, "@smsId", DbType.Int64, smsId);
try
{
db.ExecuteScalar(command);
}
catch(Exception ex)
{
throw ex;
}
}
/// <summary>
/// 得到短信转发排行版
/// </summary>
/// <returns></returns>
public static DataSet GetSmsDownloadStatTop()
{
DataBase db = new DataBase();
string strSql = "SELECT TOP 10 ROW_NUMBER() OVER (ORDER BY toStat DESC)AS Row,SUBSTRING(smsContent,1,6)smsName, * FROM dbo.SmsInfo WHERE isSeed = 3 OR isSeed = 5";
return db.GetDataSet(strSql);
}
/// <summary>
/// 用户下载成功后改变短信的上传次数为1
/// </summary>
/// <param name="infoData">SmsInfoData</param>
public static void SetSmsSeed(SmsInfoData infoData)
{
DataBase db = new DataBase();
SqlParameter[] parameters = {
new SqlParameter("@smsId",SqlDbType.BigInt),
new SqlParameter("@setSeedTime",SqlDbType.DateTime)};
parameters.Value = Convert.ToInt64(infoData.smsId);
parameters.Value = Convert.ToDateTime(infoData.setSeedTime);
db.ExecuteScalarProc("mm_smsseeduploadcount", parameters);
}
/// <summary>
/// 审核用户上传的短信为种子
/// </summary>
/// <param name="startIndex">起始页</param>
/// <param name="endIndex">结束页</param>
/// <param name="docount">是否统计总数</param>
/// <returns>DataSet</returns>
public static DataSet GetMemberUploadSms(int startIndex, int endIndex, byte docount)
{
DataBase db = new DataBase();
SqlParameter[] parameters = {
new SqlParameter("@startIndex",SqlDbType.Int),
new SqlParameter("@endIndex",SqlDbType.Int),
new SqlParameter("@docount",SqlDbType.Bit)};
parameters.Value = Convert.ToInt32(startIndex);
parameters.Value = Convert.ToInt32(endIndex);
parameters.Value = Convert.ToByte(docount);
return db.ExecuteProcReturnDataSet("mm_memberuploadsmsmanage", parameters);
}
/// <summary>
/// 审核用户上传的短信为种子,根据条件查询,(条件为(1未审核,2,未审核,3审核通过))
/// </summary>
/// <param name="startIndex">起始页</param>
/// <param name="endIndex">结束页</param>
/// <param name="docount">是否统计总数</param>
/// <param name="auditStat">1未审核,2,未审核,3审核通过</param>
/// <returns>DataSet</returns>
public static DataSet GetMemberUploadSms(int startIndex, int endIndex, byte docount, int auditStat)
{
DataBase db = new DataBase();
SqlParameter[] parameters = {
new SqlParameter("@startIndex",SqlDbType.Int),
new SqlParameter("@endIndex",SqlDbType.Int),
new SqlParameter("@docount",SqlDbType.Bit),
new SqlParameter("@auditStat",SqlDbType.Int)};
parameters.Value = Convert.ToInt32(startIndex);
parameters.Value = Convert.ToInt32(endIndex);
parameters.Value = Convert.ToByte(docount);
parameters.Value = Convert.ToInt32(auditStat);
return db.ExecuteProcReturnDataSet("mm_memberuploadsmsmanageisaudit", parameters);
}
/// <summary>
/// 后台验证短信是否为种子 3为审核通过
/// </summary>
/// <param name="mmsId">短信编号</param>
/// <returns></returns>
public static bool IsSmsSeed(Int64 smsId)
{
DataBase db = new DataBase();
SqlParameter[] parameters = {
new SqlParameter("@smsId",SqlDbType.BigInt)};
parameters.Value = Convert.ToInt64(smsId);
string strSql = "SELECT isSeed FROM SmsInfo WHERE smsId = @smsId AND mobileNo != 8";
int isseed = 0;
DataSet ds = db.GetDataSetPara(strSql, parameters);
if(ds.Tables.Rows.Count > 0)
{
isseed = Convert.ToInt32(ds.Tables.Rows["isSeed"].ToString());
}
if (isseed == 3) // 3 审核通过
{
return true;
}
else
{
return false; // 如果不是种子就返回false,用于页面显示没打上勾。
}
}
/// <summary>
/// 根据短信的编号得到短信的分类ID
/// </summary>
/// <param name="smsId">短信编号</param>
/// <returns>分类ID</returns>
public static int GetSmsClass(Int64 smsId)
{
DataBase db = new DataBase();
SqlParameter[] parameters = {
new SqlParameter("@smsId",SqlDbType.BigInt)};
parameters.Value = Convert.ToInt64(smsId);
string strSql = "SELECT classId FROM SmsInfo WHERE smsId = @smsId";
int classId = 0;
DataSet ds = db.GetDataSetPara(strSql,parameters);
if(ds.Tables.Rows.Count > 0)
{
classId = Convert.ToInt32(ds.Tables.Rows["classId"].ToString());
}
return classId;
}
/// <summary>
/// 把用户短信审核为种子等操作,1 未审核短信 ,2 审核未通过短信, 3 审核通过短信
/// </summary>
/// <param name="smsId">短信编号</param>
/// <param name="isSeed">1 未审核 ,2 审核未通过, 3 审核通过</param>
/// <returns></returns>
public static bool SetMemberSmsSeed(Int64 smsId,Int32 isSeed,Int32 classId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "UPDATE SmsInfo SET isSeed = @isSeed,classId = @classId WHERE smsId = @smsId";
DbCommand command = db.GetSqlStringCommand(strSql);
db.AddInParameter(command, "@smsId", DbType.Int64, smsId);
db.AddInParameter(command, "@isSeed", DbType.Int32, isSeed);
db.AddInParameter(command, "@classId", DbType.Int32, classId);
try
{
Int32 result = db.ExecuteNonQuery(command);
if (result > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
command.Dispose();
command.Parameters.Clear();
}
}
/// <summary>
/// 审核短信时设置短信的分类
/// </summary>
/// <param name="smsId">短信编号</param>
/// <param name="classId">分类ID</param>
/// <returns></returns>
public static bool SetSmsClass(Int64 smsId,Int32 classId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "UPDATE SmsInfo SET classId = @classId WHERE smsId = @smsId";
DbCommand command = db.GetSqlStringCommand(strSql);
db.AddInParameter(command, "@classId", DbType.Int32, classId);
db.AddInParameter(command, "@smsId", DbType.Int64, smsId);
try
{
Int32 result = Convert.ToInt32(db.ExecuteScalar(command));
if (result >= 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 数据库里面全字匹配是否有当前条短信 如过有返回true m没有返回false
/// </summary>
/// <param name="strSmsContent">用户上传的短信内容</param>
/// <returns></returns>
public static bool IsLikeDataSms(string strSmsContent)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT * FROM SmsInfo WHERE smsContent = @smsContent";
DbCommand command = db.GetSqlStringCommand(strSql);
db.AddInParameter(command, "@smsContent", DbType.String, strSmsContent);
try
{
DataSet ds = db.ExecuteDataSet(command);
if (ds.Tables.Rows.Count > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
command.Dispose();
command.Parameters.Clear();
}
}
/// <summary>
/// 判断用户保管箱短信是否大于50
/// </summary>
/// <param name="mobileNo">用户手机号码</param>
/// <returns></returns>
public static bool IsMemberDepositBoxThan(Int64 mobileNo)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT COUNT(*) FROM SmsInfo WHERE mobileNo = @mobileNo AND isSeed = 0";
DbCommand command = db.GetSqlStringCommand(strSql);
db.AddInParameter(command, "@mobileNo", DbType.Int64, mobileNo);
try
{
DataSet ds = db.ExecuteDataSet(command);
if (ds.Tables.Rows.Count >= 50)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
command.Dispose();
command.Parameters.Clear();
}
}
/// <summary>
/// 根据时间得到日程提醒的数据
/// </summary>
/// <param name="yy">年</param>
/// <param name="mm">月</param>
/// <param name="dd">日</param>
/// <param name="hh">时</param>
/// <param name="minute">分</param>
/// <returns>DataSet</returns>
public static DataSet GetMemberBoxSms(int yy, int mm, int dd, int hh, int minute)
{
Database db = DatabaseFactory.CreateDatabase();
StringBuilder sb = new StringBuilder();
sb.AppendFormat("SELECT mobileNo,I_Content FROM Itinerary WHEREDATEPART(year, remindTime) ={0} ANDDATEPART(month, remindTime) ={1} AND DATEPART(day, remindTime) ={2} and DATEPART(hour, remindTime) ={3} AND DATEPART(minute, remindTime) ={4}", yy, mm, dd, hh, minute);
try
{
return db.ExecuteDataSet(CommandType.Text, sb.ToString());
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 上传种子短信
/// </summary>
public static void UploadSmsSeed()
{
//DateTime startTime = DateTime.Parse(DateTime.Now.ToShortDateString()); //得到零时的数据
DateTime endTime = DateTime.Now; //得到当前时间
string seedName = Common.Common.SmsSeedFilePath + "seeds_" + DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00") + ".txt";
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT addTime,smsContent,smsId,isDemand FROM SmsInfo WHERE isSeed = 3 OR isSeed = 5";
DataSet ds = db.ExecuteDataSet(CommandType.Text, strSql);
StreamWriter seedWriter = null;
try
{
seedWriter = new StreamWriter(seedName, false, Encoding.GetEncoding("gb2312"));
string strSeed = "";
for (int i = 0; i < ds.Tables.Rows.Count; i++)
{
int I_len = 0;
byte[] arr = System.Text.Encoding.Default.GetBytes(ds.Tables.Rows.ToString()); //短信内容
double len = arr.Length; //短信内容的字节长度
if (len < 140)
{
I_len = 1;
}
else
{
double a = len / 140; //只入不舍的方法
int b = (int)a;
if (a > b)
{
I_len = b + 1;
}
else
{
I_len = b;
}
}
strSeed = endTime.AddDays(1).ToString() + "|" + ds.Tables.Rows.ToString() + "|" + I_len + "|" + ds.Tables.Rows + "|" + ds.Tables.Rows.ToString();
seedWriter.WriteLine(strSeed);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (seedWriter != null)
{
seedWriter.Close();
ds.Dispose();
}
}
try
{
FtpState ftpState = new FtpState();
ftpState.RemoteHost = "218.205.xxx.xxx";
ftpState.RemoteUser = "lthxxx";
ftpState.RemotePass = "lthx&srdxxxx";
ftpState.RemotePath = "/seed/";
ftpState.RemotePort = 21;
ftpState.Put(seedName);
}
catch (Exception ex)
{
throw ex;
}
}
#region 点播短信
/// <summary>
/// 根据分类ID得到分类短信
/// </summary>
/// <param name="classId">分类ID</param>
/// <returns></returns>
public static DataSet GetSmsInfo(Int32 classId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT smsId,smsContent FROM SmsInfo WHERE isSeed = 3 AND classId = " + classId + "";
try
{
return db.ExecuteDataSet(CommandType.Text, strSql);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 判断数据库里面是否有这个手机号码的指令,如果没有这个指令就返回-1,有这个指令就返回点播次数
/// </summary>
/// <param name="mobileNo">手机号码</param>
/// <param name="strDectate">点播指令</param>
/// <returns></returns>
public static Int32 IsSmsDictate(Int64 mobileNo,string strDectate)
{
Int32 stat = 0;
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT stat FROM SmsDemandRecord WHERE mobileNo = @mobileNo AND dictate = @dectate";
DbCommand command = db.GetSqlStringCommand(strSql);
db.AddInParameter(command, "@mobileNo", DbType.Int64, mobileNo);
db.AddInParameter(command, "@dectate", DbType.String, strDectate);
try
{
DataSet ds = db.ExecuteDataSet(command);
if (ds.Tables.Rows.Count > 0)
{
if (ds.Tables.Rows.ToString() != "")
{
stat = Convert.ToInt32(ds.Tables.Rows.ToString());
}
}
return stat;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 如果数据库没有这个用户的指令就插入这个指令
/// </summary>
/// <param name="mobileNo">手机号码</param>
/// <param name="strDectate">点播指令</param>
public static void InsertSmsDictate(Int64 mobileNo, string strDectate)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand command = db.GetStoredProcCommand("sys_insertsmsdictate");
db.AddInParameter(command, "@mobileNo", DbType.Int64, mobileNo);
db.AddInParameter(command, "@Dectate", DbType.String, strDectate);
try
{
db.ExecuteScalar(command);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 用户点播一次,该指令点播次数就增加一次
/// </summary>
/// <param name="mobileNo">用户手机号码</param>
/// <param name="strDectate">点播次数</param>
public static void UpdateSmsDictateDemandStat(Int64 mobileNo, string strDictate)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand command = db.GetStoredProcCommand("sys_updatesmsdemandrecordcount");
db.AddInParameter(command, "@mobileNo", DbType.Int64, mobileNo);
db.AddInParameter(command, "@dictate", DbType.String, strDictate);
try
{
db.ExecuteScalar(command);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 根据用户编号查询出用户一天的点播短信的总数
/// </summary>
/// <param name="mobileNo">手机号码</param>
/// <returns></returns>
//public static Int32 GetDayMemberSmsDictateDemandStat(Int64 mobileNo)
//{
// DateTime startTime = DateTime.Parse(DateTime.Now.ToShortDateString()); //得到月初零时的数据
// DateTime endTime = DateTime.Now; //得到当前时间
// Int32 stat = 0;
// DataBase db = new DataBase();
// SqlParameter[] parameters = {
// new SqlParameter("@mobileNo",SqlDbType.BigInt),
// new SqlParameter("@startTime",SqlDbType.DateTime),
// new SqlParameter("@endTime",SqlDbType.DateTime)};
// parameters.Value = Convert.ToInt64(mobileNo);
// parameters.Value = startTime;
// parameters.Value = endTime;
// string strSql = "SELECT SUM(stat) AS stat FROM dbo.SmsDemandRecord WHERE mobileNo = @mobileNo AND addTime BETWEEN @startTime AND @endTime";
// DataSet ds = db.GetDataSetPara(strSql, parameters);
// if (ds.Tables.Rows.Count > 0)
// {
// if (ds.Tables.Rows["stat"].ToString() != "")
// {
// stat = Convert.ToInt32(ds.Tables.Rows["stat"].ToString());
// }
// }
// return stat;
//}
/// <summary>
/// 查询用户发送次数,如果数据库没有用户发送次数记录 就插入用户发送次数初始值发送次数100,有次数不做操作,直接查出当前次数
/// </summary>
/// <param name="mobileNo">用户号码</param>
/// <returns></returns>
public static Int32 GetDayMemberSmsDictateDemandCount(Int64 mobileNo)
{
Int32 sendcount = 0;
try
{
sendcount = SeacrhCount(mobileNo);
if (sendcount == 0)
{
if (InsertCount(mobileNo) > 0)
{
sendcount = SeacrhCount2(mobileNo);
}
}
else
{
sendcount = SeacrhCount2(mobileNo);
}
return sendcount;
}
catch (Exception ex)
{
throw ex;
}
}
public static Int32 SeacrhCount(Int64 mobileNo)
{
int result = 0;
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT mobileNo FROM dbo.SmsSendCount WHERE mobileNo = " + mobileNo + "";
DataSet ds = db.ExecuteDataSet(CommandType.Text,strSql);
if (ds.Tables.Rows.Count > 0)
{
result = ds.Tables.Rows.Count;
}
return result;
}
public static Int32 SeacrhCount2(Int64 mobileNo)
{
int result = 0;
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT sendCount FROM dbo.SmsSendCount WHERE mobileNo = " + mobileNo + "";
DataSet ds = db.ExecuteDataSet(CommandType.Text, strSql);
if (ds.Tables.Rows.Count > 0)
{
result = Convert.ToInt32(ds.Tables.Rows["sendCount"].ToString());
}
return result;
}
public static int InsertCount(Int64 mobileNo)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "INSERT dbo.SmsSendCount(mobileNo,sendCount)VALUES(" + mobileNo + ",99)";
return db.ExecuteNonQuery(CommandType.Text,strSql);
}
/// <summary>
/// 如果用户每类指令短信发完一遍就把每类指令的发送次数更新为0
/// </summary>
/// <param name="mobileNo">手机号</param>
public static void UpdateDemandCount(Int64 mobileNo)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "UPDATE dbo.SmsDemandRecord SET stat = 1 WHERE mobileNo = @mobileNo";
DbCommand command = db.GetSqlStringCommand(strSql);
db.AddInParameter(command, "@mobileNo", DbType.Int64, mobileNo);
try
{
db.ExecuteScalar(command);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 用户每发送一次短信每天发送次数就减少一次
/// </summary>
/// <param name="mobileNo">用户号码</param>
public static bool UpdateSendCount(Int64 mobileNo)
{
StringBuilder sb = new StringBuilder();
Database db = DatabaseFactory.CreateDatabase();
sb.AppendFormat("DECLARE @count int SET @count = (SELECT sendCount FROM dbo.SmsSendCount WHERE mobileNo = {0}) UPDATE dbo.SmsSendCount SET sendCount = @count - 1 WHERE mobileNo = {1}",mobileNo,mobileNo);
try
{
int result = db.ExecuteNonQuery(CommandType.Text, sb.ToString());
if (result > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 每天定时用户发送总数为100 从0条开始发 所以更新99条
/// </summary>
public static void UpdateSendDemandRecord()
{
try
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "UPDATE SmsSendCount SET sendCount = 99";
db.ExecuteNonQuery(CommandType.Text, strSql);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 插入用户指令
/// </summary>
/// <param name="mobileNo">手机号</param>
/// <param name="demand">指令</param>
/// <returns></returns>
public static bool InsertSendDemand(Int64 mobileNo,string demand)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "INSERT INTO MemeberDemand(mobileNo,demand)VALUES(" + mobileNo + ",'" + demand + "')";
try
{
int result = db.ExecuteNonQuery(CommandType.Text, strSql);
if (result > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 删除用户指令
/// </summary>
/// <param name="mobileNo">用户号码</param>
/// <param name="demand">指令</param>
/// <returns></returns>
public static bool DeleteSendDemand(Int64 Id)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "DELETE FROM MemeberDemand WHERE Id = " + Id + "";
try
{
int result = db.ExecuteNonQuery(CommandType.Text, strSql);
if (result > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 查询出所有用户指令
/// </summary>
/// <returns></returns>
public static DataSet GetSmsSendDemand()
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT TOP 200 Id,mobileNo,demand FROM MemeberDemand";
try
{
return db.ExecuteDataSet(CommandType.Text, strSql);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
/// <summary>
/// 验证短信是否为种子
/// </summary>
/// <param name="smscontent">短信内容</param>
/// <returns></returns>
public static bool ValidateSmsSeed(string smscontent)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT * FROM SmsInfo WHERE smsContent LIKE '%" + smscontent + "%' AND isSeed = 3";
try
{
DataSet ds = db.ExecuteDataSet(CommandType.Text, strSql);
if (ds.Tables.Rows.Count > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 用户发送短信成功后,插入发送记录表
/// </summary>
/// <param name="_sendData">短信发送记录实体</param>
/// <returns></returns>
public static bool InsertSmsSendRecord(SmsSendRecordData _sendData)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "INSERT INTO dbo.SmsSendRecord(sendTime,mobileNo,smsContent,smsId)VALUES(@sendTime,@mobileNo,@smsContent,@smsId)";
DbCommand command = db.GetSqlStringCommand(strSql);
db.AddInParameter(command, "@sendTime", DbType.DateTime, _sendData.sendTime);
db.AddInParameter(command, "@mobileNo", DbType.Int64, _sendData.mobileNo);
db.AddInParameter(command, "@smsContent", DbType.String, _sendData.smsContent);
db.AddInParameter(command, "@smsId", DbType.Int64, _sendData.smsId);
try
{
int result = db.ExecuteNonQuery(command);
if (result > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
command.Dispose();
command.Parameters.Clear();
}
}
/// <summary>
/// 导入传过来的全发短信后的记录
/// </summary>
/// <param name="filePath">全发记录保存的路径</param>
/// <returns></returns>
public static bool ImportSmsSendRecord(string filePath)
{
try
{
Database db = DatabaseFactory.CreateDatabase();
StringBuilder sb = new StringBuilder();
sb.AppendFormat("EXEC sys_import_sms_sendrecord '''{0}'''", filePath);
int result = db.ExecuteNonQuery(CommandType.Text, sb.ToString());
if (result > 0)
{
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}
/// <summary>
/// 上传种子发送记录到服务器
/// </summary>
public static void UploadSmsSendRecord()
{
DateTime startTime = DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString()); //得到昨天零时的数据
DateTime endTime = DateTime.Now; //得到当前时间
string y_Name = Common.Common.SendDrecord + "down_" + DateTime.Now.AddDays(-1).ToString("yyyyMMdd") + ".txt";//得到昨天传来的文件名
string t_Name = Common.Common.SmsSeedFilePath +"down_" + DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00") + ".txt";
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT sendTime,mobileNo,smsContent,smsId FROM SmsSendRecord WHERE sendTime >= '" + startTime + "' AND sendTime < '" + endTime + "' ";
DataSet ds = db.ExecuteDataSet(CommandType.Text, strSql);
StreamWriter sw = null;
try
{
sw = new StreamWriter(y_Name, true, Encoding.GetEncoding("gb2312"));
string strSeed = "";
for (int i = 0; i < ds.Tables.Rows.Count; i++) //追加本地短信发送的记录
{
strSeed = ds.Tables.Rows.ToString() + "|" + ds.Tables.Rows.ToString() + "|" + ds.Tables.Rows.ToString() + "|" + ds.Tables.Rows.ToString();
sw.WriteLine(strSeed);
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
if (sw != null)
{
sw.Flush();
sw.Close();
ds.Dispose();
}
}
try
{
File.Copy(y_Name, t_Name);
}
catch (Exception ex)
{
throw ex;
}
try
{
FtpState ftpState = new FtpState();
ftpState.RemoteHost = "218.205.xxx.xxx";
ftpState.RemoteUser = "lthxxx";
ftpState.RemotePass = "lthx&srdxxxx";
ftpState.RemotePath = "/down/";
ftpState.RemotePort = 21;
ftpState.Put(t_Name);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 下载短信转发次数记录
/// </summary>
/// <returns></returns>
public static bool DownLoadSmsTransmitCount()
{
try
{
string tsName = "ts_" + DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00") + ".txt";
FtpState ftpState = new FtpState();
ftpState.RemoteHost = "218.205.xxx.xxx";
ftpState.RemoteUser = "lthxxx";
ftpState.RemotePass = "lthx&srdxxxx";
ftpState.RemotePath = "/transmit/";
ftpState.RemotePort = 21;
ftpState.Get(tsName, Common.Common.TransmitUrl, tsName);
bool i_Result = ImportSmsTransmitCount(Common.Common.TransmitUrl + "/" + tsName);
if (i_Result == true)
{
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
throw ex;
}
}
/// <summary>
/// 导入短信转发次数
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static bool ImportSmsTransmitCount(string filePath)
{
Database db = DatabaseFactory.CreateDatabase();
StringBuilder sb = new StringBuilder();
sb.AppendFormat("sys_import_transmit '''{0}'''", filePath);
try
{
int result = db.ExecuteNonQuery(CommandType.Text, sb.ToString());
if (result > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 得到待审核的种子
/// </summary>
/// <returns></returns>
public static DataSet GetWaitSmsSeed(string sql)
{
Database db = DatabaseFactory.CreateDatabase();
StringBuilder sb = new StringBuilder();
sb.Append("SELECT ROW_NUMBER() OVER (ORDER BY addTime desc)AS Row, * from SmsInfo WHERE isSeed = 1 AND smsId IN ");
sb.Append("(");
sb.Append(sql);
sb.Append(")");
try
{
return db.ExecuteDataSet(CommandType.Text,sb.ToString());
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 种子下架
/// </summary>
/// <returns></returns>
public static bool SmsSeedShelves()
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "UPDATE SmsInfo SET isSeed = 1 WHERE isSeed = 3";
try
{
Int32 result = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, strSql));
if (result >= 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using House.Model;
namespace House.DAL
{
public class BuildingAccessor
{
public BuildingAccessor()
{ }
/// <summary>
/// 插入一条楼书记录
/// </summary>
/// <param name="buildingData">楼书实体</param>
/// <returns>插入成功后返回当前楼书编号,失败返回0</returns>
public static int InsertBuilding(BuildingData buildingData)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand command = db.GetStoredProcCommand("Building_InsertUpdateDelete");
db.AddInParameter(command, "@DataTable_Action_", DbType.String, buildingData.DataTable_Action_);
db.AddInParameter(command, "@BuildingCode", DbType.String, buildingData.BuildingCode);
db.AddInParameter(command,"@BuildingName",DbType.String,buildingData.BuildingName);
db.AddInParameter(command,"@BuildingAddress",DbType.String,buildingData.BuildingAddress);
db.AddInParameter(command,"@BuildingLocation",DbType.Int32,buildingData.BuildingLocation);
db.AddInParameter(command, "@BuildingRegional", DbType.Int32, buildingData.BuildingRegional);
db.AddInParameter(command, "@BuildingLevel", DbType.Int32, buildingData.BuildingLevel);
db.AddInParameter(command, "@BuildingProperty", DbType.Int32, buildingData.BuildingProperty);
db.AddInParameter(command, "@BuildingYear", DbType.Int32, buildingData.BuildingYear);
db.AddInParameter(command, "@BuildingOwensType", DbType.Int32, buildingData.BuildingOwensType);
db.AddInParameter(command,"@BuildingArea",DbType.Decimal,buildingData.BuildingArea);
db.AddInParameter(command,"@BuildingMinOffice",DbType.Decimal,buildingData.BuildingMinOffice);
db.AddInParameter(command,"@BuildingMaxOffice", DbType.Decimal,buildingData.BuildingMaxOffice);
db.AddInParameter(command,"@BuildingMinRent", DbType.Decimal,buildingData.BuildingMinRent);
db.AddInParameter(command,"@BuildingMaxRent", DbType.Decimal,buildingData.BuildingMaxRent);
db.AddInParameter(command,"@BuildingMinSale", DbType.Decimal,buildingData.BuildingMinSale);
db.AddInParameter(command,"@BuildingMaxSale", DbType.Decimal,buildingData.BuildingMaxSale);
db.AddInParameter(command,"@BuildingMinProperty", DbType.Decimal,buildingData.BuildingMinProperty);
db.AddInParameter(command,"@BuildingMaxProperty", DbType.Decimal,buildingData.BuildingMaxProperty);
db.AddInParameter(command,"@BuildingOverFloors",DbType.Int32,buildingData.BuildingOverFloors);
db.AddInParameter(command,"@BuildingBelowFloors", DbType.Int32,buildingData.BuildingBelowFloors);
db.AddInParameter(command,"@BuildingParkingSpaces", DbType.Int32,buildingData.BuildingParkingSpaces);
db.AddInParameter(command,"@BuildingAir", DbType.Int32,buildingData.BuildingAir);
db.AddInParameter(command,"@BuildingAirConditioning", DbType.String,buildingData.BuildingAirConditioning);
db.AddInParameter(command,"@BuildingElevator",DbType.String,buildingData.BuildingElevator);
db.AddInParameter(command,"@BuildingPower",DbType.String,buildingData.BuildingPower);
db.AddInParameter(command,"@BuildingCommunications",DbType.String,buildingData.BuildingCommunications);
db.AddInParameter(command,"@BuildingSecurity",DbType.String,buildingData.BuildingSecurity);
db.AddInParameter(command,"@BuildingFire",DbType.String,buildingData.BuildingFire);
db.AddInParameter(command,"@BuildingFacilities",DbType.String,buildingData.BuildingFacilities);
db.AddInParameter(command,"@BuildingTraffic",DbType.String,buildingData.BuildingTraffic);
db.AddInParameter(command,"@BuildingFinancial",DbType.String,buildingData.BuildingFinancial);
db.AddInParameter(command,"@BuildingHotels",DbType.String,buildingData.BuildingHotels);
db.AddInParameter(command,"@BuildingFun",DbType.String,buildingData.BuildingFun);
db.AddInParameter(command,"@BuildingCustomers",DbType.String,buildingData.BuildingCustomers);
db.AddInParameter(command,"@BuildingDescription",DbType.String,buildingData.BuildingDescription);
db.AddInParameter(command,"@BuildingDevelopers", DbType.String,buildingData.BuildingDevelopers);
db.AddInParameter(command,"@BuildingPropertyCompany", DbType.String,buildingData.BuildingPropertyCompany);
db.AddInParameter(command, "@BuildingHallAddress", DbType.String, buildingData.BuildingHallAddress);
db.AddInParameter(command,"@BuildingFax", DbType.String,buildingData.BuildingFax);
db.AddInParameter(command,"@BuildingContact", DbType.String,buildingData.BuildingContact);
db.AddInParameter(command,"@BuildingPhone", DbType.String,buildingData.BuildingPhone);
db.AddInParameter(command,"@BuildingMobile", DbType.String,buildingData.BuildingMobile);
db.AddInParameter(command,"@BuildingEmail", DbType.String,buildingData.BuildingEmail);
db.AddInParameter(command,"@BuildingStandbyContact", DbType.String,buildingData.BuildingStandbyContact);
db.AddInParameter(command,"@BuildingAltPhone", DbType.String,buildingData.BuildingAltPhone);
db.AddInParameter(command,"@BuildingStandbyMobile", DbType.String,buildingData.BuildingStandbyMobile);
db.AddInParameter(command,"@BuildingStandEmail", DbType.String,buildingData.BuildingStandEmail);
db.AddInParameter(command,"@BuildingCooType", DbType.Int32,buildingData.BuildingCooType);
db.AddInParameter(command,"@BuildingRentPercent",DbType.String,buildingData.BuildingRentPercent);
db.AddInParameter(command, "@BuildingIntermediary", DbType.String, buildingData.BuildingIntermediary);
db.AddInParameter(command,"@CreatorId", DbType.Int32,buildingData.CreatorId);
db.AddInParameter(command,"@CreateTime",DbType.DateTime,buildingData.CreateTime);
db.AddInParameter(command,"@OwnerId", DbType.Int32,buildingData.OwnerId);
db.AddInParameter(command,"@UpdateTime",DbType.DateTime,buildingData.UpdateTime);
db.AddInParameter(command,"@BuildingIntroduction", DbType.String,buildingData.BuildingIntroduction);
db.AddInParameter(command,"@BuildingPhotos",DbType.String,buildingData.BuildingPhotos);
db.AddInParameter(command,"@Id",DbType.Int32,buildingData.Id);
try
{
return Convert.ToInt32(db.ExecuteScalar(command));
//Id = int.Parse(db.GetParameterValue(command, "@Id").ToString());
//return Id;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 根据表名查询出对应表主键字段最大ID
/// </summary>
/// <param name="tableName">表名</param>
/// <returns>最大ID</returns>
public static string MaxCode(string tableName)
{
string rCode = "0";
Database db = DatabaseFactory.CreateDatabase();
StringBuilder sb = new StringBuilder();
DateTime dTime = DateTime.Now;
sb.AppendFormat("SELECT MAX(Id) AS ID FROM {0}", tableName);
try
{
DataSet ds = db.ExecuteDataSet(CommandType.Text, sb.ToString());
if (ds.Tables.Rows.Count > 0)
{
if (ds.Tables.Rows.ToString() != "")
rCode = (Convert.ToInt32(ds.Tables.Rows.ToString()) + 1).ToString();
}
return dTime.ToString("yyyyMMdd") + rCode;
}
catch (Exception ex)
{
throw ex;
}
}
//public static bool BuildingOwner(string strBuildingId,Int32 EmployeeId)
//{
// Database db = DatabaseFactory.CreateDatabase();
// string strSql = "UPDATE Building SET OwnerId = "
//}
/// <summary>
/// 分配楼书、房源、客户,并插入到记录表
/// </summary>
/// <param name="infoId">房源或楼书、或客户ID</param>
/// <param name="acquisitionId">获得人ID</param>
/// <param name="OwnerId">当前拥有人ID</param>
/// <param name="infoType">类型,building,office,customer</param>
/// <returns></returns>
public static Int32 ShareInfo(Int32 infoId, Int32 acquisitionId, Int32 OwnerId, string infoType)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand command = db.GetStoredProcCommand("ShareInfo");
db.AddInParameter(command, "@infoId", DbType.Int32, infoId);
db.AddInParameter(command, "@acquisitionId", DbType.Int32, acquisitionId);
db.AddInParameter(command, "@OwnerId", DbType.Int32, OwnerId);
db.AddInParameter(command, "@infoType", DbType.String, infoType);
try
{
return db.ExecuteNonQuery(command);
}
catch (Exception e)
{
throw e;
}
}
/// <summary>
/// 将记录集转为BuildingEntity实体类 (Building)
/// </summary>
/// <param name="dt.Rows">记录集</param>
/// <param name="Fileds">字段名列表</param>
/// <returns>BuildingEntity</returns>
public static BuildingData BuildingEntity(DataTable dt)
{
BuildingData nc = new BuildingData();
if (dt.Rows["Id"].ToString() != "") nc.Id = Convert.ToInt32(dt.Rows["Id"]); // Id
if (!Convert.IsDBNull(dt.Rows["BuildingCode"])) nc.BuildingCode = Convert.ToString(dt.Rows["BuildingCode"]).Trim(); // 楼书编号
if (!Convert.IsDBNull(dt.Rows["BuildingName"])) nc.BuildingName = Convert.ToString(dt.Rows["BuildingName"]).Trim(); // BuildingName
if (!Convert.IsDBNull(dt.Rows["BuildingAddress"])) nc.BuildingAddress = Convert.ToString(dt.Rows["BuildingAddress"]).Trim(); // BuildingAddt.Rowsess
if (!Convert.IsDBNull(dt.Rows["BuildingLocation"])) nc.BuildingLocation = Convert.ToInt32(dt.Rows["BuildingLocation"]); // 区位
if (!Convert.IsDBNull(dt.Rows["BuildingRegional"])) nc.BuildingRegional = Convert.ToInt32(dt.Rows["BuildingRegional"]); // 行政区域
if (!Convert.IsDBNull(dt.Rows["BuildingLevel"])) nc.BuildingLevel = Convert.ToInt32(dt.Rows["BuildingLevel"]); // 楼盘等级
if (!Convert.IsDBNull(dt.Rows["BuildingProperty"])) nc.BuildingProperty = Convert.ToInt32(dt.Rows["BuildingProperty"]); // 楼盘性质
if (!Convert.IsDBNull(dt.Rows["BuildingYear"])) nc.BuildingYear = Convert.ToInt32(dt.Rows["BuildingYear"]); // 建成年份
if (!Convert.IsDBNull(dt.Rows["BuildingOwensType"])) nc.BuildingOwensType = Convert.ToInt32(dt.Rows["BuildingOwensType"]); // 业主类型
if (!Convert.IsDBNull(dt.Rows["BuildingArea"])) nc.BuildingArea = Convert.ToDouble(dt.Rows["BuildingArea"]); // 建筑面积
if (!Convert.IsDBNull(dt.Rows["BuildingMinOffice"])) nc.BuildingMinOffice = Convert.ToDouble(dt.Rows["BuildingMinOffice"]); // 面积划分开始
if (!Convert.IsDBNull(dt.Rows["BuildingMaxOffice"])) nc.BuildingMaxOffice = Convert.ToDouble(dt.Rows["BuildingMaxOffice"]); // 面积划分结束
if (!Convert.IsDBNull(dt.Rows["BuildingMinRent"])) nc.BuildingMinRent = Convert.ToDouble(dt.Rows["BuildingMinRent"]); // 参考租价开始
if (!Convert.IsDBNull(dt.Rows["BuildingMaxRent"])) nc.BuildingMaxRent = Convert.ToDouble(dt.Rows["BuildingMaxRent"]); // 参考租价最大
if (!Convert.IsDBNull(dt.Rows["BuildingMinSale"])) nc.BuildingMinSale = Convert.ToDouble(dt.Rows["BuildingMinSale"]); // 参考售价最小
if (!Convert.IsDBNull(dt.Rows["BuildingMaxSale"])) nc.BuildingMaxSale = Convert.ToDouble(dt.Rows["BuildingMaxSale"]); // 最大
if (!Convert.IsDBNull(dt.Rows["BuildingMinProperty"])) nc.BuildingMinProperty = Convert.ToDouble(dt.Rows["BuildingMinProperty"]); // 物管费最少
if (!Convert.IsDBNull(dt.Rows["BuildingMaxProperty"])) nc.BuildingMaxProperty = Convert.ToDouble(dt.Rows["BuildingMaxProperty"]); // 物管费最多
if (!Convert.IsDBNull(dt.Rows["BuildingOverFloors"])) nc.BuildingOverFloors = Convert.ToInt32(dt.Rows["BuildingOverFloors"]); // 地面层数
if (!Convert.IsDBNull(dt.Rows["BuildingBelowFloors"])) nc.BuildingBelowFloors = Convert.ToInt32(dt.Rows["BuildingBelowFloors"]); // 地下层数
if (!Convert.IsDBNull(dt.Rows["BuildingParkingSpaces"])) nc.BuildingParkingSpaces = Convert.ToInt32(dt.Rows["BuildingParkingSpaces"]); // 车位数
if (!Convert.IsDBNull(dt.Rows["BuildingAir"])) nc.BuildingAir = Convert.ToInt32(dt.Rows["BuildingAir"]); // 1、中央空调2、分体中央空调3、无中央空调4、待定
if (!Convert.IsDBNull(dt.Rows["BuildingAirConditioning"])) nc.BuildingAirConditioning = Convert.ToString(dt.Rows["BuildingAirConditioning"]).Trim(); // 空调描述
if (!Convert.IsDBNull(dt.Rows["BuildingElevator"])) nc.BuildingElevator = Convert.ToString(dt.Rows["BuildingElevator"]).Trim(); // 电梯
if (!Convert.IsDBNull(dt.Rows["BuildingPower"])) nc.BuildingPower = Convert.ToString(dt.Rows["BuildingPower"]).Trim(); // 水电
if (!Convert.IsDBNull(dt.Rows["BuildingCommunications"])) nc.BuildingCommunications = Convert.ToString(dt.Rows["BuildingCommunications"]).Trim(); // BuildingCommunications
if (!Convert.IsDBNull(dt.Rows["BuildingSecurity"])) nc.BuildingSecurity = Convert.ToString(dt.Rows["BuildingSecurity"]).Trim(); // 安保
if (!Convert.IsDBNull(dt.Rows["BuildingFire"])) nc.BuildingFire = Convert.ToString(dt.Rows["BuildingFire"]).Trim(); // 消防
if (!Convert.IsDBNull(dt.Rows["BuildingFacilities"])) nc.BuildingFacilities = Convert.ToString(dt.Rows["BuildingFacilities"]).Trim(); // 配套设施
if (!Convert.IsDBNull(dt.Rows["BuildingTraffic"])) nc.BuildingTraffic = Convert.ToString(dt.Rows["BuildingTraffic"]).Trim(); // 周边交通
if (!Convert.IsDBNull(dt.Rows["BuildingFinancial"])) nc.BuildingFinancial = Convert.ToString(dt.Rows["BuildingFinancial"]).Trim(); // 周边金融
if (!Convert.IsDBNull(dt.Rows["BuildingHotels"])) nc.BuildingHotels = Convert.ToString(dt.Rows["BuildingHotels"]).Trim(); // 周边酒店
if (!Convert.IsDBNull(dt.Rows["BuildingFun"])) nc.BuildingFun = Convert.ToString(dt.Rows["BuildingFun"]).Trim(); // 餐饮娱乐
if (!Convert.IsDBNull(dt.Rows["BuildingCustomers"])) nc.BuildingCustomers = Convert.ToString(dt.Rows["BuildingCustomers"]).Trim(); // 入驻企业
if (!Convert.IsDBNull(dt.Rows["BuildingDescription"])) nc.BuildingDescription = Convert.ToString(dt.Rows["BuildingDescription"]).Trim(); // 大楼介绍
if (!Convert.IsDBNull(dt.Rows["BuildingDevelopers"])) nc.BuildingDevelopers = Convert.ToString(dt.Rows["BuildingDevelopers"]).Trim(); // 发展商
if (!Convert.IsDBNull(dt.Rows["BuildingPropertyCompany"])) nc.BuildingPropertyCompany = Convert.ToString(dt.Rows["BuildingPropertyCompany"]).Trim(); // 物管公司
if (!Convert.IsDBNull(dt.Rows["BuildingHallAddress"])) nc.BuildingHallAddress = Convert.ToString(dt.Rows["BuildingHallAddress"]).Trim(); // 租售办公地址
if (!Convert.IsDBNull(dt.Rows["BuildingFax"])) nc.BuildingFax = Convert.ToString(dt.Rows["BuildingFax"]).Trim(); // BuildingFax
if (!Convert.IsDBNull(dt.Rows["BuildingContact"])) nc.BuildingContact = Convert.ToString(dt.Rows["BuildingContact"]).Trim(); // 联系人1/职务
if (!Convert.IsDBNull(dt.Rows["BuildingPhone"])) nc.BuildingPhone = Convert.ToString(dt.Rows["BuildingPhone"]).Trim(); // 联系电话
if (!Convert.IsDBNull(dt.Rows["BuildingMobile"])) nc.BuildingMobile = Convert.ToString(dt.Rows["BuildingMobile"]).Trim(); // 手机
if (!Convert.IsDBNull(dt.Rows["BuildingEmail"])) nc.BuildingEmail = Convert.ToString(dt.Rows["BuildingEmail"]).Trim(); // E-Mail
if (!Convert.IsDBNull(dt.Rows["BuildingStandbyContact"])) nc.BuildingStandbyContact = Convert.ToString(dt.Rows["BuildingStandbyContact"]).Trim(); // 联系人2/职务
if (!Convert.IsDBNull(dt.Rows["BuildingAltPhone"])) nc.BuildingAltPhone = Convert.ToString(dt.Rows["BuildingAltPhone"]).Trim(); // 电话
if (!Convert.IsDBNull(dt.Rows["BuildingStandbyMobile"])) nc.BuildingStandbyMobile = Convert.ToString(dt.Rows["BuildingStandbyMobile"]).Trim(); // 手机
if (!Convert.IsDBNull(dt.Rows["BuildingStandEmail"])) nc.BuildingStandEmail = Convert.ToString(dt.Rows["BuildingStandEmail"]).Trim(); // E-Mail
if (!Convert.IsDBNull(dt.Rows["BuildingCooType"])) nc.BuildingCooType = Convert.ToInt32(dt.Rows["BuildingCooType"]); // 0请选择,1待定,2合作,3合作
if (!Convert.IsDBNull(dt.Rows["BuildingRentPercent"])) nc.BuildingRentPercent = Convert.ToString(dt.Rows["BuildingRentPercent"]).Trim(); // 物业合作描述
if (!Convert.IsDBNull(dt.Rows["BuildingIntermediary"])) nc.BuildingIntermediary = Convert.ToString(dt.Rows["BuildingIntermediary"]).Trim(); // BuildingIntermediary
if (!Convert.IsDBNull(dt.Rows["CreatorId"])) nc.CreatorId = Convert.ToInt32(dt.Rows["CreatorId"]); // 创建人ID
if (!Convert.IsDBNull(dt.Rows["CreateTime"])) nc.CreateTime = Convert.ToDateTime(dt.Rows["CreateTime"]); // 创建时间
if (!Convert.IsDBNull(dt.Rows["OwnerId"])) nc.OwnerId = Convert.ToInt32(dt.Rows["OwnerId"]); // 归属人ID
if (!Convert.IsDBNull(dt.Rows["UpdateTime"])) nc.UpdateTime = Convert.ToDateTime(dt.Rows["UpdateTime"]); // 更新时间
if (!Convert.IsDBNull(dt.Rows["BuildingIntroduction"])) nc.BuildingIntroduction = Convert.ToString(dt.Rows["BuildingIntroduction"]).Trim(); // 备注信息
if (!Convert.IsDBNull(dt.Rows["BuildingPhotos"])) nc.BuildingPhotos = Convert.ToString(dt.Rows["BuildingPhotos"]).Trim(); // 照片信息
return nc;
}
public static string GetTaskName(string TableName,Int32 Id,string filed)
{
string taskName = "";
Database db = DatabaseFactory.CreateDatabase();
StringBuilder sb = new StringBuilder();
if (TableName == "Office")
{
sb.AppendFormat("SELECT BuildingName AS Filed FROM Building WHERE Id = (SELECT OfficeBuildingId FROM Office WHERE Id = {0})", Id);
}
else
{
sb.AppendFormat("SELECT {0} AS Filed FROM {1} WHERE Id = {2}", filed, TableName,Id);
}
try
{
DataSet ds = db.ExecuteDataSet(CommandType.Text, sb.ToString());
if (ds.Tables.Rows.Count > 0)
{
if (ds.Tables.Rows.ToString() != "")
taskName = ds.Tables.Rows.ToString();
}
return taskName;
}
catch (Exception ex)
{
throw ex;
}
}
public static int Application(string ShareId, string ShareType, Int32 ApplicationId, string AuditId)
{
Int32 result = -1;
Database db = DatabaseFactory.CreateDatabase();
string strSql = "";
string[] arrayId;
string[] arrayOwener;
arrayOwener = AuditId.Split(',');
arrayId = ShareId.Split(',');
for (int i = 0; i < arrayId.Length; i++)
{
strSql = "INSERT INTO ShareList(ShareId,ShareType,ApplicationId,AuditId,ApplicationDate,AuditDate,status) VALUES(" + Convert.ToInt32(arrayId) + ",'" + ShareType + "'," + ApplicationId + "," + Convert.ToInt32(arrayOwener) + ",GETDATE(),GETDATE(),3)";
result = db.ExecuteNonQuery(CommandType.Text, strSql);
}
return result;
}
public static string BuildingName(Int32 BuildingId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT BuildingName FROM Building WHERE Id = " + BuildingId + "";
DataSet ds = db.ExecuteDataSet(CommandType.Text, strSql);
if (ds.Tables.Rows.Count > 0)
{
return ds.Tables.Rows["BuildingName"].ToString();
}
else
{
return "";
}
}
public static string BuildingCode(Int32 BuildingId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT BuildingCode FROM Building WHERE Id = " + BuildingId + "";
DataSet ds = db.ExecuteDataSet(CommandType.Text, strSql);
if (ds.Tables.Rows.Count > 0)
{
return ds.Tables.Rows["BuildingCode"].ToString();
}
else
{
return "";
}
}
public static int SetBuildingEmployee(string id,string ShareId,string ApplicationId,Int32 stat)
{
Int32 result = -1;
Database db = DatabaseFactory.CreateDatabase();
string strSql = "";
string[] arrayShareId;
string[] arrayId;
string[] arrayApp;
arrayApp = ApplicationId.Split(','); //申请人ID
arrayId = id.Split(','); //申请记录ID
arrayShareId = ShareId.Split(',');
for (int i = 0; i < arrayId.Length; i++)
{
strSql = "UPDATE ShareList SET status = " + stat + "WHERE Id = " + Convert.ToInt32(arrayId) + "";
result = db.ExecuteNonQuery(CommandType.Text, strSql);
if (stat == 1)
UpdateBuilding(Convert.ToInt32(arrayShareId), Convert.ToInt32(arrayApp));
}
return result;
}
public static void UpdateBuilding(Int32 BuildingId,Int32 OwnerId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "UPDATE Building SET OwnerId = "+OwnerId+"WHERE Id = "+ BuildingId +"";
db.ExecuteNonQuery(CommandType.Text,strSql);
}
}
}
public partial class office : System.Web.UI.Page
{
Int32 id = (Int32)Common.sink("id", Common.MethodType.Get, 10, 0, Common.DataType.Int);
string CMD = (string)Common.sink("CMD", Common.MethodType.Get, 10, 1, Common.DataType.Str);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OnStartData();
if (CMD == "Edit")
{
OnStart(id);
}
}
}
protected void OnStart(Int32 id)
{
QueryParam qp = new QueryParam();
qp.Where = "Where a.Id= " + id + "";
qp.PageIndex = 1;
qp.PageSize = 1;
int RecordCount = 0;
DataSet ds = OfficeSystem.GetOfficeList(qp, out RecordCount);
OnStartData(OfficeSystem.PopulateOfficeEntity(ds.Tables));
Int32 BuildingId = 0;
BuildingId = Convert.ToInt32(ds.Tables.Rows["OfficeBuildingId"].ToString());
OnStart2(BuildingId);
}
protected void OnStart2(Int32 id)
{
QueryParam qp = new QueryParam();
qp.Where = "Where Id= " + id + "";
qp.PageIndex = 1;
qp.PageSize = 1;
int RecordCount = 0;
DataSet ds = BuildingSystem.GetBuildingList(qp, out RecordCount);
BuildingData bd = BuildingSystem.BuildingEntity(ds.Tables);
BuildingID.Value = bd.Id.ToString();
BuildingName.Value = bd.BuildingName;
BuildingAddress.Value = bd.BuildingAddress;
BuildingLocation.Value = GetBuildingLocation(bd.BuildingLocation);
BuildingRegional.Value = GetBuildingRegional(bd.BuildingRegional);
OfficeAirConditioning.Value = GetBuildingAir(bd.BuildingAir);
OfficeElevator.Value = bd.BuildingElevator;
BuildingProperty.Value = GetBuildingProperty(bd.BuildingProperty);
BuildingMinProperty.Value = bd.BuildingMinProperty.ToString();
BuildingMaxProperty.Value = bd.BuildingMaxProperty.ToString();
}
protected void OnStartData(OfficeData ut)
{
//OfficeBuildingId= OfficeBuildingId_Disp.Text = ut.OfficeBuildingId.ToString();
OfficeCode.Value =ut.OfficeCode.ToString();
OfficeBuildings.Value = ut.OfficeBuildings.ToString();
OfficeMinFloor.Value =ut.OfficeMinFloor.ToString();
OfficeMaxFloor.Value =ut.OfficeMaxFloor.ToString();
OfficeNumbers.Value = ut.OfficeNumbers.ToString();
OfficeRights.Value = ut.OfficeRights.ToString();
OfficeUseFor.Value = ut.OfficeUseFor.ToString();
OfficeMinArea.Value = ut.OfficeMinArea.ToString();
OfficeMaxArea.Value = ut.OfficeMaxArea.ToString();
OfficeMinRentPrice.Value = ut.OfficeMinRentPrice.ToString();
OfficeMaxRentPrice.Value = ut.OfficeMaxRentPrice.ToString();
OfficePayWay.Value = ut.OfficePayWay.ToString();
OfficeMinSalePrice.Value = ut.OfficeMinSalePrice.ToString();
OfficeMaxSalePrice.Value =ut.OfficeMaxSalePrice.ToString();
OfficeEntrance.Value =ut.OfficeEntrance.ToString();
OfficeEnSaw.Value = ut.OfficeEnSaw.ToString();
OfficeDoors.Value = ut.OfficeDoors.ToString();
OfficeDoors1.Value = ut.OfficeDoors1.ToString();
OfficeLighting.Value = ut.OfficeLighting.ToString();
OfficeDecoration.Value = ut.OfficeDecoration.ToString();
OfficeFace.Value = ut.OfficeFace.ToString();
OfficeWC.Value = ut.OfficeWC.ToString();
OfficeLayout.Value = ut.OfficeLayout.ToString();
OfficeParkingSpaces.Value = ut.OfficeParkingSpaces.ToString();
OfficeVisitWay.Value = ut.OfficeVisitWay.ToString();
OfficeVision.Value = ut.OfficeVision.ToString();
OfficeRentSaleStatus.Value =ut.OfficeRentSaleStatus.ToString();
OfficeInfoSource.Value = ut.OfficeInfoSource.ToString();
OfficeSource.Value = ut.OfficeSource.ToString();
OfficeOwensType.Value = ut.OfficeOwensType.ToString();
OfficeRentPercent.Value = ut.OfficeRentPercent.ToString();
OfficeRentDescription.Value = ut.OfficeRentDescription.ToString();
OfficeContact.Value = ut.OfficeContact.ToString();
OfficePhone.Value = ut.OfficePhone.ToString();
OfficeMobile.Value =ut.OfficeMobile.ToString();
OfficeEmail.Value = ut.OfficeEmail.ToString();
OfficeCustomer.Value =ut.OfficeCustomer.ToString();
OfficeContractBeginDate.Value = ut.OfficeContractBeginDate.ToString();
OfficeContractEndDate.Value = ut.OfficeContractEndDate.ToString();
OfficeRentChannels.Value = ut.OfficeRentChannels.ToString();
OfficeIntermediary.Value =ut.OfficeIntermediary.ToString();
OfficeDescription.Value = ut.OfficeDescription.ToString();
OfficePhotos.Value = ut.OfficePhotos.ToString();
Creator.Value = EmployeeSystem.GetEmployee(ut.CreatorId).EmployeeName;
CreateTime.Value = ut.CreateTime.ToString();
Owner.Value = EmployeeSystem.GetEmployee(ut.OwnerId).EmployeeName;
UpdateTime.Value =ut.UpDateTimeTime.ToString();
OnStart2(ut.OfficeBuildingId);
}
protected OfficeData VisittaskDisp(Int32 id)
{
QueryParam qp = new QueryParam();
qp.Where = "Where a.Id = " + id + "";
qp.PageIndex = 1;
qp.PageSize = 1;
int RecordCount = 0;
DataSet ds = OfficeSystem.GetOfficeList(qp, out RecordCount);
return OfficeSystem.PopulateOfficeEntity(ds.Tables);
}
private string UpPhoto()
{
FileUpLoadCommon fc = new FileUpLoadCommon(Common.UpLoadDir + "Picture/", false);
fc.SaveFile(FileUpload1, true);
return fc.newFileName;
}
protected void btnOK_Click(object sender, EventArgs e)
{
string OfficeCode_Value = (string)Common.sink(OfficeCode.UniqueID, Common.MethodType.Post, 50, 1, Common.DataType.Str);
//string OfficeAirConditioning_Value = (string)Common.sink(OfficeAirConditioning.UniqueID, Common.MethodType.Post, 500, 1, Common.DataType.Str);
//string OfficeElevator_Value = (string)Common.sink(OfficeElevator.UniqueID, Common.MethodType.Post, 500, 1, Common.DataType.Str);
//string OfficeOverFloors_Value = (string)Common.sink(OfficeOverFloors.UniqueID, Common.MethodType.Post, 500, 1, Common.DataType.Str);
//double BuildingMinProperty_Value = (double)Common.sink(BuildingMinProperty.UniqueID, Common.MethodType.Post, 18, 1, Common.DataType.Double);
//double BuildingMaxProperty_Value = (double)Common.sink(BuildingMaxProperty.UniqueID, Common.MethodType.Post, 18, 1, Common.DataType.Double);
int OfficeBuildingId_Value = (int)Common.sink(BuildingID.UniqueID, Common.MethodType.Post, 10, 1, Common.DataType.Int);
string OfficeBuildings_Value = (string)Common.sink(OfficeBuildings.UniqueID, Common.MethodType.Post, 30, 1, Common.DataType.Str);
int OfficeMinFloor_Value = (int)Common.sink(OfficeMinFloor.UniqueID, Common.MethodType.Post, 10, 1, Common.DataType.Int);
int OfficeMaxFloor_Value = (int)Common.sink(OfficeMaxFloor.UniqueID, Common.MethodType.Post, 10, 1, Common.DataType.Int);
string OfficeNumbers_Value = (string)Common.sink(OfficeNumbers.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Str);
int OfficeRights_Value = (int)Common.sink(OfficeRights.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeUseFor_Value = (int)Common.sink(OfficeUseFor.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
double OfficeMinArea_Value = (double)Common.sink(OfficeMinArea.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Double);
double OfficeMaxArea_Value = (double)Common.sink(OfficeMaxArea.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Double);
double OfficeMinRentPrice_Value = (double)Common.sink(OfficeMinRentPrice.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
double OfficeMaxRentPrice_Value = (double)Common.sink(OfficeMaxRentPrice.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
string OfficePayWay_Value = (string)Common.sink(OfficePayWay.UniqueID, Common.MethodType.Post, 200, 0, Common.DataType.Str);
double OfficeMinSalePrice_Value = (double)Common.sink(OfficeMinSalePrice.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
double OfficeMaxSalePrice_Value = (double)Common.sink(OfficeMaxSalePrice.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
string OfficeEntrance_Value = (string)Common.sink(OfficeEntrance.UniqueID, Common.MethodType.Post, 20, 0, Common.DataType.Str);
string OfficeEnSaw_Value = (string)Common.sink(OfficeEnSaw.UniqueID, Common.MethodType.Post, 20, 0, Common.DataType.Str);
string OfficeDoors_Value = (string)Common.sink(OfficeDoors.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Str);
string OfficeDoors1_Value = (string)Common.sink(OfficeDoors1.UniqueID, Common.MethodType.Post, 100, 0, Common.DataType.Str);
int OfficeLighting_Value = (int)Common.sink(OfficeLighting.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeDecoration_Value = (int)Common.sink(OfficeDecoration.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeFace_Value = (int)Common.sink(OfficeFace.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeWC_Value = (int)Common.sink(OfficeWC.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
string OfficeLayout_Value = (string)Common.sink(OfficeLayout.UniqueID, Common.MethodType.Post, 500, 0, Common.DataType.Str);
string OfficeParkingSpaces_Value = (string)Common.sink(OfficeParkingSpaces.UniqueID, Common.MethodType.Post, 200, 0, Common.DataType.Str);
int OfficeVisitWay_Value = (int)Common.sink(OfficeVisitWay.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
string OfficeVision_Value = (string)Common.sink(OfficeVision.UniqueID, Common.MethodType.Post, 5000, 0, Common.DataType.Str);
int OfficeRentSaleStatus_Value = (int)Common.sink(OfficeRentSaleStatus.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeInfoSource_Value = (int)Common.sink(OfficeInfoSource.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
string OfficeSource_Value = (string)Common.sink(OfficeSource.UniqueID, Common.MethodType.Post, 5000, 0, Common.DataType.Str);
int OfficeOwensType_Value = (int)Common.sink(OfficeOwensType.UniqueID, Common.MethodType.Post, 10, 1, Common.DataType.Int);
double OfficeRentPercent_Value = (double)Common.sink(OfficeRentPercent.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
string OfficeRentDescription_Value = (string)Common.sink(OfficeRentDescription.UniqueID, Common.MethodType.Post, 80, 0, Common.DataType.Str);
string OfficeContact_Value = (string)Common.sink(OfficeContact.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Str);
string OfficePhone_Value = (string)Common.sink(OfficePhone.UniqueID, Common.MethodType.Post, 30, 0, Common.DataType.Str);
string OfficeMobile_Value = (string)Common.sink(OfficeMobile.UniqueID, Common.MethodType.Post, 20, 0, Common.DataType.Str);
string OfficeEmail_Value = (string)Common.sink(OfficeEmail.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Str);
string OfficeCustomer_Value = (string)Common.sink(OfficeCustomer.UniqueID, Common.MethodType.Post, 100, 0, Common.DataType.Str);
DateTime? OfficeContractBeginDate_Value = (DateTime?)Common.sink(OfficeContractBeginDate.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Dat);
DateTime? OfficeContractEndDate_Value = (DateTime?)Common.sink(OfficeContractEndDate.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Dat);
int OfficeRentChannels_Value = (int)Common.sink(OfficeRentChannels.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
string OfficeIntermediary_Value = (string)Common.sink(OfficeIntermediary.UniqueID, Common.MethodType.Post, 200, 0, Common.DataType.Str);
string OfficeDescription_Value = (string)Common.sink(OfficeDescription.UniqueID, Common.MethodType.Post, 4000, 0, Common.DataType.Str);
string OfficePhotos_Value = (string)Common.sink(OfficePhotos.UniqueID, Common.MethodType.Post, 100, 0, Common.DataType.Str);
int CreatorId_Value = Common.Get_UserID;
DateTime? CreateTime_Value = DateTime.Now;
int OwnerId_Value = Common.Get_UserID;
DateTime? UpdateTime_Value = DateTime.Now;
OfficeData ut = new OfficeData();
if (CMD == "New")
{
ut.OfficeCode = "FY" + BuildingSystem.MaxCode("dbo.Office");
ut.CreateTime = DateTime.Now;
ut.DataTable_Action_ = "Insert";
ut.OfficePhotos = UpPhoto();
ut.CreatorId = CreatorId_Value;
ut.OwnerId = OwnerId_Value;
}
else if (CMD == "Edit")
{
ut = VisittaskDisp(id);
if (ut.OwnerId == Common.Get_UserID || OfficeLoginSystem.EmpolyeeRole(Common.Get_UserID) == 0)
{
ut.DataTable_Action_ = "Update";
string strPic = UpPhoto();
if (strPic != "" && strPic != null)
{
ut.OfficePhotos = strPic;
}
}
else
{
Common.MsgBox("对不起,你没有编辑该项的权限!", "officelist.aspx");
}
}
ut.Id = id;
ut.OfficeCode = OfficeCode_Value;
//ut.OfficeAirConditioning = OfficeAirConditioning_Value;
//ut.OfficeElevator = OfficeElevator_Value;
//ut.OfficeOverFloors = OfficeOverFloors_Value;
//ut.BuildingMinProperty = (decimal)BuildingMinProperty_Value;
//ut.BuildingMaxProperty = (decimal)BuildingMaxProperty_Value;
ut.OfficeBuildingId = OfficeBuildingId_Value;
ut.OfficeBuildings = OfficeBuildings_Value;
ut.OfficeMinFloor = OfficeMinFloor_Value;
ut.OfficeMaxFloor = OfficeMaxFloor_Value;
ut.OfficeNumbers = OfficeNumbers_Value;
ut.OfficeRights = OfficeRights_Value;
ut.OfficeUseFor = OfficeUseFor_Value;
ut.OfficeMinArea = OfficeMinArea_Value;
ut.OfficeMaxArea = OfficeMaxArea_Value;
ut.OfficeMinRentPrice = OfficeMinRentPrice_Value;
ut.OfficeMaxRentPrice = OfficeMaxRentPrice_Value;
ut.OfficePayWay = OfficePayWay_Value;
ut.OfficeMinSalePrice = OfficeMinSalePrice_Value;
ut.OfficeMaxSalePrice = OfficeMaxSalePrice_Value;
ut.OfficeEntrance = OfficeEntrance_Value;
ut.OfficeEnSaw = OfficeEnSaw_Value;
ut.OfficeDoors = OfficeDoors_Value;
ut.OfficeDoors1 = OfficeDoors1_Value;
ut.OfficeLighting = OfficeLighting_Value;
ut.OfficeDecoration = OfficeDecoration_Value;
ut.OfficeFace = OfficeFace_Value;
ut.OfficeWC = OfficeWC_Value;
ut.OfficeLayout = OfficeLayout_Value;
ut.OfficeParkingSpaces = OfficeParkingSpaces_Value;
ut.OfficeVisitWay = OfficeVisitWay_Value;
ut.OfficeVision = OfficeVision_Value;
ut.OfficeRentSaleStatus = OfficeRentSaleStatus_Value;
ut.OfficeInfoSource = OfficeInfoSource_Value;
ut.OfficeSource = OfficeSource_Value;
ut.OfficeOwensType = OfficeOwensType_Value;
ut.OfficeRentPercent = (decimal)OfficeRentPercent_Value;
ut.OfficeRentDescription = OfficeRentDescription_Value;
ut.OfficeContact = OfficeContact_Value;
ut.OfficePhone = OfficePhone_Value;
ut.OfficeMobile = OfficeMobile_Value;
ut.OfficeEmail = OfficeEmail_Value;
ut.OfficeCustomer = OfficeCustomer_Value;
ut.OfficeContractBeginDate = OfficeContractBeginDate_Value;
ut.OfficeContractEndDate = OfficeContractEndDate_Value;
ut.OfficeRentChannels = OfficeRentChannels_Value;
ut.OfficeIntermediary = OfficeIntermediary_Value;
ut.OfficeDescription = OfficeDescription_Value;
ut.UpDateTimeTime = UpdateTime_Value;
Int32 rResult = OfficeSystem.OfficeInsertUpdateDelete(ut);
if (rResult > 0)
Common.MsgBox("操作成功!");
else if (rResult == -1)
Common.MsgBox("操作失败,存在相同的记录");
else
Common.MsgBox("操作失败,请稍后再试!");
}
protected void OnStartData()
{
CreateTime.Value = UpdateTime.Value = DateTime.Now.ToString();
EmployeeData _EmployeeData = EmployeeSystem.GetEmployee(Common.Get_UserID);
Creator.Value = _EmployeeData.EmployeeName;
Owner.Value = _EmployeeData.EmployeeName;
}
public string GetBuildingLocation(int BuildingLocationId)
{
switch (BuildingLocationId)
{
case 5:
return "内环内 - 西北";
case 6:
return "内环内 - 东北";
case 7:
return "内环内 - 东南";
case 8:
return "内环内 - 西南";
case 9:
return "内一环 - 西北";
case 10:
return "内一环 - 东北";
case 11:
return "内一环 - 东南";
case 12:
return "内一环 - 西南";
case 13:
return "一二环 - 西北";
case 14:
return "一二环 - 东北";
case 15:
return "一二环 - 东南";
case 16:
return "一二环 - 西南";
case 17:
return "二三环 - 西北";
case 18:
return "二三环 - 东北";
case 19:
return "二三环 - 东南";
case 20:
return "二三环 - 西南";
case 22:
return "三环外 - 西北";
case 23:
return "三环外 - 东北";
case 24:
return "三环外 - 东南";
case 25:
return "三环外 - 西南";
default:
return "待定";
}
}
public string GetBuildingProperty(int BuildingPropertyId)
{
switch (BuildingPropertyId)
{
case 1:
return "专业写字楼";
case 2:
return "商住纯写";
case 3:
return "商住混用";
case 4:
return "营业用房";
case 5:
return "厂房";
case 6:
return "酒店";
case 7:
return "待定";
default:
return "待定";
}
}
public string GetBuildingRegional(int BuildingRegionalId)
{
switch (BuildingRegionalId)
{
case 1:
return "锦江区";
case 2:
return "青羊区";
case 3:
return "金牛区";
case 4:
return "武侯区";
case 5:
return "成华区";
case 6:
return "高新区";
case 7:
return "高新(西区)";
case 8:
return "高新(南区)";
default:
return "待定";
}
}
public string GetBuildingAir(int BuildingAirId)
{
switch (BuildingAirId)
{
case 1:
return "中央空调";
case 2:
return "分体中央空调";
case 3:
return "无中央空调";
case 4:
return "待定";
default:
return "待定";
}
}
} ID:seaven
邮箱:seaven@vip.qq.com
申请通过,欢迎光临吾爱破解论坛,期待吾爱破解有你更加精彩,ID和密码自己通过邮件密码找回功能修改,请即时登陆并修改密码!
登陆后请在一周内在此帖报道,否则将删除ID信息 报到,谢谢吾爱论坛,黑米!提供交流的平台!
页:
[1]