|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsExchangesUnit;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using DSWeb.DataAccess;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsExchangesUnitDAL
|
|
|
|
|
{
|
|
|
|
|
public class MsExchangesUnitDAL
|
|
|
|
|
{
|
|
|
|
|
#region 查询
|
|
|
|
|
static public List<MsExchangesUnitEntity> GetDataList(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=[info_client].MODIFIEDUSER) FROM [info_client] where 1=1";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " and " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by [TAXNO],MODIFIEDTIME desc,[SHORTNAME]";
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=[info_client].MODIFIEDUSER) FROM [info_client] where 1=1";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " and " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by [TAXNO],MODIFIEDTIME desc,[SHORTNAME]";
|
|
|
|
|
}
|
|
|
|
|
return strSql.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsExchangesUnitEntity GetData(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
String strSql = "SELECT *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=[info_client].MODIFIEDUSER) FROM [info_client] where 1=1";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " and " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var list = SetData(strSql);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return list[0];
|
|
|
|
|
}
|
|
|
|
|
return new MsExchangesUnitEntity();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<MsExchangesUnitEntity> SetData(String strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsExchangesUnitEntity>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsExchangesUnitEntity data = new MsExchangesUnitEntity();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));
|
|
|
|
|
data.CODENAME = (reader["CODENAME"] == null ? "" : Convert.ToString(reader["CODENAME"]));//客户代码
|
|
|
|
|
data.SHORTNAME = (reader["SHORTNAME"] == null ? "" : Convert.ToString(reader["SHORTNAME"]));//客户简称
|
|
|
|
|
data.DESCRIPTION = (reader["DESCRIPTION"] == null ? "" : Convert.ToString(reader["DESCRIPTION"]));//客户中文名称或描述信息
|
|
|
|
|
data.NAME = (reader["NAME"] == null ? "" : Convert.ToString(reader["NAME"]));//客户英文简称
|
|
|
|
|
data.EnFullName = (reader["EnFullName"] == null ? "" : Convert.ToString(reader["EnFullName"]));//客户英文全称
|
|
|
|
|
data.STATUS = (reader["STATUS"] == null ? 0 : Convert.ToInt32(reader["STATUS"]));//客户状态
|
|
|
|
|
data.ADDR = (reader["ADDR"] == null ? "" : Convert.ToString(reader["ADDR"]));//通讯地址
|
|
|
|
|
data.EMAIL = (reader["EMAIL"] == null ? "" : Convert.ToString(reader["EMAIL"]));//邮箱
|
|
|
|
|
data.WEB = (reader["WEB"] == null ? "" : Convert.ToString(reader["WEB"]));//网页
|
|
|
|
|
data.TEL = (reader["TEL"] == null ? "" : Convert.ToString(reader["TEL"]));//电话
|
|
|
|
|
data.FAX = (reader["FAX"] == null ? "" : Convert.ToString(reader["FAX"]));//传真
|
|
|
|
|
data.CHIEF = (reader["CHIEF"] == null ? "" : Convert.ToString(reader["CHIEF"]));//负责人
|
|
|
|
|
data.SALE = (reader["SALE"] == null ? "" : Convert.ToString(reader["SALE"]));//所属揽货人
|
|
|
|
|
data.OP = (reader["OP"] == null ? "" : Convert.ToString(reader["OP"]));//所属揽货人
|
|
|
|
|
data.DOC = (reader["DOC"] == null ? "" : Convert.ToString(reader["DOC"]));//所属单证
|
|
|
|
|
data.ISCARRIER = (reader["ISCARRIER"] == null ? false : Convert.ToBoolean(reader["ISCARRIER"]));//是否船公司
|
|
|
|
|
data.ISBOOKING = (reader["ISBOOKING"] == null ? false : Convert.ToBoolean(reader["ISBOOKING"]));//是否订舱公司
|
|
|
|
|
data.ISYARD = (reader["ISYARD"] == null ? false : Convert.ToBoolean(reader["ISYARD"]));//是否场站
|
|
|
|
|
data.ISTRUCK = (reader["ISTRUCK"] == null ? false : Convert.ToBoolean(reader["ISTRUCK"]));//是否车队
|
|
|
|
|
data.ISCONTROLLER = (reader["ISCONTROLLER"] == null ? false : Convert.ToBoolean(reader["ISCONTROLLER"]));//是否委托单位
|
|
|
|
|
data.ISCUSTOM = (reader["ISCUSTOM"] == null ? false : Convert.ToBoolean(reader["ISCUSTOM"]));//是否报关行
|
|
|
|
|
data.ISAGENT = (reader["ISAGENT"] == null ? false : Convert.ToBoolean(reader["ISAGENT"]));//是否代理(国外)
|
|
|
|
|
data.ISAGENTCN = (reader["ISAGENTCN"] == null ? false : Convert.ToBoolean(reader["ISAGENTCN"]));//是否代理(国内)
|
|
|
|
|
data.ISEXPRESS = (reader["ISEXPRESS"] == null ? false : Convert.ToBoolean(reader["ISEXPRESS"]));//是否快递公司
|
|
|
|
|
data.ISAIRLINES = (reader["ISAIRLINES"] == null ? false : Convert.ToBoolean(reader["ISAIRLINES"]));//是否航空公司
|
|
|
|
|
data.ISSHIPPER = (reader["ISSHIPPER"] == null ? false : Convert.ToBoolean(reader["ISSHIPPER"]));//是否发货人
|
|
|
|
|
data.ISCONSIGNEE = (reader["ISCONSIGNEE"] == null ? false : Convert.ToBoolean(reader["ISCONSIGNEE"]));//是否收货人
|
|
|
|
|
data.ISNOTIFYPARTY = (reader["ISNOTIFYPARTY"] == null ? false : Convert.ToBoolean(reader["ISNOTIFYPARTY"]));//是否通知人
|
|
|
|
|
data.ISWAREHOUSE = (reader["ISWAREHOUSE"] == null ? false : Convert.ToBoolean(reader["ISWAREHOUSE"]));//是否仓库
|
|
|
|
|
data.COUNTRY = (reader["COUNTRY"] == null ? "" : Convert.ToString(reader["COUNTRY"]));//国家
|
|
|
|
|
data.PROVINCE = (reader["PROVINCE"] == null ? "" : Convert.ToString(reader["PROVINCE"]));//省或州
|
|
|
|
|
data.CITY = (reader["CITY"] == null ? "" : Convert.ToString(reader["CITY"]));//城市
|
|
|
|
|
data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//CORPID
|
|
|
|
|
data.BLCONTENT = (reader["BLCONTENT"] == null ? "" : Convert.ToString(reader["BLCONTENT"]));//BLCONTENT
|
|
|
|
|
data.ISSTOP = (reader["ISSTOP"] == null ? false : Convert.ToBoolean(reader["ISSTOP"]));//是否停用该客户信息
|
|
|
|
|
data.BillRises1 = (reader["BillRises1"] == null ? "" : Convert.ToString(reader["BillRises1"]));//发票抬头1
|
|
|
|
|
data.BillRises2 = (reader["BillRises2"] == null ? "" : Convert.ToString(reader["BillRises2"]));//发票抬头2
|
|
|
|
|
data.USDBillRises = (reader["USDBillRises"] == null ? "" : Convert.ToString(reader["USDBillRises"]));//美元支票抬头
|
|
|
|
|
data.RMBBillRises = (reader["RMBBillRises"] == null ? "" : Convert.ToString(reader["RMBBillRises"]));//人民币支票抬头
|
|
|
|
|
data.RMBBank = (reader["RMBBank"] == null ? "" : Convert.ToString(reader["RMBBank"]));//人民币开户银行
|
|
|
|
|
data.RMBAccount = (reader["RMBAccount"] == null ? "" : Convert.ToString(reader["RMBAccount"]));//人民币账号
|
|
|
|
|
data.RMBOnlineNO = (reader["RMBOnlineNO"] == null ? "" : Convert.ToString(reader["RMBOnlineNO"]));//人民币联机行号
|
|
|
|
|
data.USDBank = (reader["USDBank"] == null ? "" : Convert.ToString(reader["USDBank"]));//美元开户银行
|
|
|
|
|
data.USDAccount = (reader["USDAccount"] == null ? "" : Convert.ToString(reader["USDAccount"]));//美元账号
|
|
|
|
|
data.USDOnlineNO = (reader["USDOnlineNO"] == null ? "" : Convert.ToString(reader["USDOnlineNO"]));//美元联机行号
|
|
|
|
|
data.CustomAttributes1 = (reader["CustomAttributes1"] == null ? "" : Convert.ToString(reader["CustomAttributes1"]));//自定义属性1
|
|
|
|
|
data.CustomAttributes2 = (reader["CustomAttributes2"] == null ? "" : Convert.ToString(reader["CustomAttributes2"]));//自定义属性2
|
|
|
|
|
data.USDMaxAmountCredit = (reader["USDMaxAmountCredit"] == null ? 0 : Convert.ToDecimal(reader["USDMaxAmountCredit"]));//美元信用最大金额
|
|
|
|
|
data.RMBMaxAmountCredit = (reader["RMBMaxAmountCredit"] == null ? 0 : Convert.ToDecimal(reader["RMBMaxAmountCredit"]));//人民币信用最大金额
|
|
|
|
|
data.MaxAmountCredit = (reader["MaxAmountCredit"] == null ? 0 : Convert.ToDecimal(reader["MaxAmountCredit"]));//信用最大金额(RMB+USD)
|
|
|
|
|
data.STLNAME = (reader["STLNAME"] == null ? "" : Convert.ToString(reader["STLNAME"]));//结算方式编码
|
|
|
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
|
|
|
|
|
data.USDExchangeRate = (reader["USDExchangeRate"] == null ? 0 : Convert.ToDecimal(reader["USDExchangeRate"]));//美金汇率
|
|
|
|
|
data.STLDATE = (reader["STLDATE"] == null ? "" : Convert.ToString(reader["STLDATE"]));//月结算时间
|
|
|
|
|
data.STLFIRSTHALFDATE = (reader["STLFIRSTHALFDATE"] == null ? "" : Convert.ToString(reader["STLFIRSTHALFDATE"]));//上半月结算时间
|
|
|
|
|
data.STLMIDDLEDATE = (reader["STLMIDDLEDATE"] == null ? "" : Convert.ToString(reader["STLMIDDLEDATE"]));//下半月结算时间
|
|
|
|
|
data.STLDATEPJ = (reader["STLDATEPJ"] == null ? "" : Convert.ToString(reader["STLDATEPJ"]));//STLDATEPJ
|
|
|
|
|
data.LEVEL = (reader["LEVEL"] == null ? "" : Convert.ToString(reader["LEVEL"]));//LEVEL
|
|
|
|
|
data.LOGINNAME = (reader["LOGINNAME"] == null ? "" : Convert.ToString(reader["LOGINNAME"]));//LOGINNAME
|
|
|
|
|
data.LOGINPASSWORD = (reader["LOGINPASSWORD"] == null ? "" : Convert.ToString(reader["LOGINPASSWORD"]));//LOGINPASSWORD
|
|
|
|
|
data.QQ = (reader["QQ"] == null ? "" : Convert.ToString(reader["QQ"]));//QQ
|
|
|
|
|
data.MSN = (reader["MSN"] == null ? "" : Convert.ToString(reader["MSN"]));//MSN
|
|
|
|
|
data.ISWHARF = (reader["ISWHARF"] == null ? false : Convert.ToBoolean(reader["ISWHARF"]));//ISWHARF
|
|
|
|
|
data.ISSHIPPINGAGENT = (reader["ISSHIPPINGAGENT"] == null ? false : Convert.ToBoolean(reader["ISSHIPPINGAGENT"]));//ISSHIPPINGAGENT
|
|
|
|
|
data.FARCODE = (reader["FARCODE"] == null ? "" : Convert.ToString(reader["FARCODE"]));//FARCODE
|
|
|
|
|
data.FAPCODE = (reader["FAPCODE"] == null ? "" : Convert.ToString(reader["FAPCODE"]));//FAPCODE
|
|
|
|
|
data.ISINSURE = (reader["ISINSURE"] == null ? false : Convert.ToBoolean(reader["ISINSURE"]));//ISINSURE
|
|
|
|
|
data.ISLEASING = (reader["ISLEASING"] == null ? false : Convert.ToBoolean(reader["ISLEASING"]));//ISLEASING
|
|
|
|
|
data.ISTRADINGAGENCY = (reader["ISTRADINGAGENCY"] == null ? false : Convert.ToBoolean(reader["ISTRADINGAGENCY"]));//ISTRADINGAGENCY
|
|
|
|
|
data.ISOTHER = (reader["ISOTHER"] == null ? false : Convert.ToBoolean(reader["ISOTHER"]));//ISOTHER
|
|
|
|
|
data.OTHERS = (reader["OTHERS"] == null ? "" : Convert.ToString(reader["OTHERS"]));//OTHERS
|
|
|
|
|
data.UNITPRICE = (reader["UNITPRICE"] == null ? "" : Convert.ToString(reader["UNITPRICE"]));//UNITPRICE
|
|
|
|
|
data.REGISTRATIONNO = (reader["REGISTRATIONNO"] == null ? "" : Convert.ToString(reader["REGISTRATIONNO"]));//REGISTRATIONNO
|
|
|
|
|
data.ORDERNO = (reader["ORDERNO"] == null ? "" : Convert.ToString(reader["ORDERNO"]));//ORDERNO
|
|
|
|
|
data.ISENTERP = (reader["ISENTERP"] == null ? false : Convert.ToBoolean(reader["ISENTERP"]));//ISENTERP
|
|
|
|
|
data.TAXNO = (reader["TAXNO"] == null ? "" : Convert.ToString(reader["TAXNO"]));//TAXNO
|
|
|
|
|
data.EDICODE = (reader["EDICODE"] == null ? "" : Convert.ToString(reader["EDICODE"]));//EDICODE
|
|
|
|
|
data.EDICODE2 = (reader["EDICODE2"] == null ? "" : Convert.ToString(reader["EDICODE2"]));//EDICODE2
|
|
|
|
|
data.EDICODE3 = (reader["EDICODE3"] == null ? "" : Convert.ToString(reader["EDICODE3"]));//EDICODE3
|
|
|
|
|
data.ORGANIZATIONCODE = (reader["ORGANIZATIONCODE"] == null ? "" : Convert.ToString(reader["ORGANIZATIONCODE"]));
|
|
|
|
|
data.RMBBankAddress = (reader["RMBBankAddress"] == null ? "" : Convert.ToString(reader["RMBBankAddress"]));
|
|
|
|
|
data.USDBankAddress = (reader["USDBankAddress"] == null ? "" : Convert.ToString(reader["USDBankAddress"]));
|
|
|
|
|
data.OPNAME = (reader["OPNAME"] == null ? "" : Convert.ToString(reader["OPNAME"]));//处理人
|
|
|
|
|
if (reader["OPTIME"] != DBNull.Value)
|
|
|
|
|
data.OPTIME = Convert.ToDateTime(reader["OPTIME"]);//处理时间
|
|
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更新人gid
|
|
|
|
|
if (reader["MODIFIEDTIME"] != DBNull.Value)
|
|
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);
|
|
|
|
|
data.MODIFIEDUSERNAME = (reader["MODIFIEDUSERNAME"] == null ? "" : Convert.ToString(reader["MODIFIEDUSERNAME"]));//更改人
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Rang权限范围
|
|
|
|
|
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
|
|
|
|
|
{
|
|
|
|
|
string str = "";
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT");
|
|
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE");
|
|
|
|
|
strSql.Append(" from VW_User_Authority");
|
|
|
|
|
strSql.Append(" where [NAME]='modExchangesUnit' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
|
|
string operaterange = "4";
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
|
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (visiblerange == "4")//无
|
|
|
|
|
{
|
|
|
|
|
str = " 1<0";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "3")//个人
|
|
|
|
|
{
|
|
|
|
|
str = " CORPID='" + companyid + "' and (SALE like '%" + username + "%' or OP like '%" + username + "%' or DOC like '%" + username + "%' or [OPNAME] like '%" + username + "%' or MODIFIEDUSER in(select gid from [user] where SHOWNAME like '%" + username + "%'))";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "2")//部门
|
|
|
|
|
{
|
|
|
|
|
str = " 1<0";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "1")//公司
|
|
|
|
|
{
|
|
|
|
|
str = " CORPID='" + companyid + "'";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "0")//全部
|
|
|
|
|
{
|
|
|
|
|
str = " 1=1 ";
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 添加日志
|
|
|
|
|
public static DBResult setLog(string GID, string SHORTNAME, string strUserID, string SHOWNAME)
|
|
|
|
|
{
|
|
|
|
|
DBResult result = new DBResult();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string strSql = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('删除往来单位信息','删除操作','" + SHOWNAME + "将“" + SHORTNAME + "”数据删除','" + strUserID + "')";
|
|
|
|
|
int existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), null);
|
|
|
|
|
sqlTran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "操作出现错误,请重试或联系系统管理员";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
SqlHelper.CloseConnection();
|
|
|
|
|
sqlTran.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "操作数据成功";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 删除
|
|
|
|
|
public static DBResult Delete(string GID, string SHORTNAME)
|
|
|
|
|
{
|
|
|
|
|
DBResult result = new DBResult();
|
|
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
|
|
|
|
|
string strSql = "SELECT top 1 CUSTOMERNAME from VW_Settlement where CUSTOMERNAME in ('" + SHORTNAME + "') group by CUSTOMERNAME";
|
|
|
|
|
string strCUSTOMERNAME = T_ALL_DA.GetStrSQL("CUSTOMERNAME", strSql);
|
|
|
|
|
if (strCUSTOMERNAME.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "业务信息中已启用往来单位,不允许删除!";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from [info_client] where GID='" + GID + "'");
|
|
|
|
|
//var cmdDelete = db.GetSqlStringCommand("update [company] set ISDELETED=1 where GID='" + headData.GID + "'");
|
|
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "删除出现错误,请重试";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "操作成功";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 联系人
|
|
|
|
|
static public List<MsExchangesUnitContactEntity> GetDataListContact(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
String strSql = "select *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=[info_client_contact].MODIFIEDUSER) from info_client_contact where LINKID in (SELECT GID FROM [info_client] where 1=1";
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
strSql += " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
strSql += ")";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " and " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by MODIFIEDTIME desc,[SHOWNAME]";
|
|
|
|
|
}
|
|
|
|
|
return SetDataContact(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<MsExchangesUnitContactEntity> SetDataContact(String strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsExchangesUnitContactEntity>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsExchangesUnitContactEntity data = new MsExchangesUnitContactEntity();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一编号
|
|
|
|
|
data.LINKID = (reader["LINKID"] == null ? "" : Convert.ToString(reader["LINKID"]));//客户关联id
|
|
|
|
|
data.CODENAME = (reader["CODENAME"] == null ? "" : Convert.ToString(reader["CODENAME"]));//客户代码
|
|
|
|
|
data.SHOWNAME = (reader["SHOWNAME"] == null ? "" : Convert.ToString(reader["SHOWNAME"]));//客户名称
|
|
|
|
|
data.ADDR = (reader["ADDR"] == null ? "" : Convert.ToString(reader["ADDR"]));//通讯地址
|
|
|
|
|
data.EMAIL = (reader["EMAIL"] == null ? "" : Convert.ToString(reader["EMAIL"]));//电子邮箱
|
|
|
|
|
data.TEL = (reader["TEL"] == null ? "" : Convert.ToString(reader["TEL"]));//电话
|
|
|
|
|
data.FAX = (reader["FAX"] == null ? "" : Convert.ToString(reader["FAX"]));//传真
|
|
|
|
|
data.MOBILE = (reader["MOBILE"] == null ? "" : Convert.ToString(reader["MOBILE"]));//传真
|
|
|
|
|
data.ISFINANCIALSTAFF = (reader["ISFINANCIALSTAFF"] == null ? false : Convert.ToBoolean(reader["ISFINANCIALSTAFF"]));//是否为财务
|
|
|
|
|
data.ISOPERATOR = (reader["ISOPERATOR"] == null ? false : Convert.ToBoolean(reader["ISOPERATOR"]));//是否为操作
|
|
|
|
|
data.ISSALEMAN = (reader["ISSALEMAN"] == null ? false : Convert.ToBoolean(reader["ISSALEMAN"]));//是否为销售
|
|
|
|
|
data.ISOTHER = (reader["ISOTHER"] == null ? false : Convert.ToBoolean(reader["ISOTHER"]));//是否为其他
|
|
|
|
|
data.CONTACTTYPE1 = (reader["CONTACTTYPE1"] == null ? false : Convert.ToBoolean(reader["CONTACTTYPE1"]));//联系人类别1
|
|
|
|
|
data.CONTACTTYPE2 = (reader["CONTACTTYPE2"] == null ? false : Convert.ToBoolean(reader["CONTACTTYPE2"]));//联系人类别2
|
|
|
|
|
data.CONTACTTYPE3 = (reader["CONTACTTYPE3"] == null ? false : Convert.ToBoolean(reader["CONTACTTYPE3"]));//联系人类别3
|
|
|
|
|
data.CONTACTTYPE4 = (reader["CONTACTTYPE4"] == null ? false : Convert.ToBoolean(reader["CONTACTTYPE4"]));//联系人类别4
|
|
|
|
|
data.CONTACTTYPE5 = (reader["CONTACTTYPE5"] == null ? false : Convert.ToBoolean(reader["CONTACTTYPE5"]));//联系人类别5
|
|
|
|
|
data.CONTACTTYPE6 = (reader["CONTACTTYPE6"] == null ? false : Convert.ToBoolean(reader["CONTACTTYPE6"]));//联系人类别6
|
|
|
|
|
data.CONTACTTYPE7 = (reader["CONTACTTYPE7"] == null ? false : Convert.ToBoolean(reader["CONTACTTYPE7"]));//联系人类别7
|
|
|
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人GID
|
|
|
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
|
|
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//最后一次更新操作人GID
|
|
|
|
|
if (reader["MODIFIEDTIME"] != DBNull.Value)
|
|
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//最后一次更新操作时间
|
|
|
|
|
data.ISSTOP = (reader["ISSTOP"] == null ? false : Convert.ToBoolean(reader["ISSTOP"]));//是否停用该联系人信息
|
|
|
|
|
data.ISDELETED = (reader["ISDELETED"] == null ? false : Convert.ToBoolean(reader["ISDELETED"]));//联系人删除状态标志
|
|
|
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
|
|
|
|
|
if (reader["ANNIVERSARY2"] != DBNull.Value)
|
|
|
|
|
data.ANNIVERSARY2 = Convert.ToDateTime(reader["ANNIVERSARY2"]);//ANNIVERSARY2
|
|
|
|
|
data.AREMARK2 = (reader["AREMARK2"] == null ? "" : Convert.ToString(reader["AREMARK2"]));//AREMARK2
|
|
|
|
|
if (reader["BIRTHDAY"] != DBNull.Value)
|
|
|
|
|
data.BIRTHDAY = Convert.ToDateTime(reader["BIRTHDAY"]);//BIRTHDAY
|
|
|
|
|
if (reader["ANNIVERSARY1"] != DBNull.Value)
|
|
|
|
|
data.ANNIVERSARY1 = Convert.ToDateTime(reader["ANNIVERSARY1"]);//ANNIVERSARY1
|
|
|
|
|
data.AREMARK1 = (reader["AREMARK1"] == null ? "" : Convert.ToString(reader["AREMARK1"]));//AREMARK1
|
|
|
|
|
data.ISBIRTHDAY = (reader["ISBIRTHDAY"] == null ? false : Convert.ToBoolean(reader["ISBIRTHDAY"]));//ISBIRTHDAY
|
|
|
|
|
data.ISANNIVERSARY1 = (reader["ISANNIVERSARY1"] == null ? false : Convert.ToBoolean(reader["ISANNIVERSARY1"]));//ISANNIVERSARY1
|
|
|
|
|
data.ISANNIVERSARY2 = (reader["ISANNIVERSARY2"] == null ? false : Convert.ToBoolean(reader["ISANNIVERSARY2"]));//ISANNIVERSARY2
|
|
|
|
|
data.BIRTHDAYDAY = (reader["BIRTHDAYDAY"] == null ? 0 : Convert.ToInt32(reader["BIRTHDAYDAY"]));//BIRTHDAYDAY
|
|
|
|
|
data.ANNIVERSARYDAY1 = (reader["ANNIVERSARYDAY1"] == null ? 0 : Convert.ToInt32(reader["ANNIVERSARYDAY1"]));//ANNIVERSARYDAY1
|
|
|
|
|
data.ANNIVERSARYDAY2 = (reader["ANNIVERSARYDAY2"] == null ? 0 : Convert.ToInt32(reader["ANNIVERSARYDAY2"]));//ANNIVERSARYDAY2
|
|
|
|
|
data.JOB = (reader["JOB"] == null ? "" : Convert.ToString(reader["JOB"]));//JOB
|
|
|
|
|
data.SEX = (reader["SEX"] == null ? "" : Convert.ToString(reader["SEX"]));//SEX
|
|
|
|
|
data.AGE = (reader["AGE"] == null ? "" : Convert.ToString(reader["AGE"]));//AGE
|
|
|
|
|
data.MARRY = (reader["MARRY"] == null ? "" : Convert.ToString(reader["MARRY"]));//MARRY
|
|
|
|
|
data.CHILDREN = (reader["CHILDREN"] == null ? "" : Convert.ToString(reader["CHILDREN"]));//CHILDREN
|
|
|
|
|
data.HOBBIES = (reader["HOBBIES"] == null ? "" : Convert.ToString(reader["HOBBIES"]));//HOBBIES
|
|
|
|
|
data.MODIFIEDUSERNAME = (reader["MODIFIEDUSERNAME"] == null ? "" : Convert.ToString(reader["MODIFIEDUSERNAME"]));//更改人
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsExchangesUnitContactEntity GetDataContact(string condition, string companyid)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=[info_client_contact].MODIFIEDUSER) from info_client_contact where 1=1");
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
var list = SetDataContact(strSql.ToString());
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
return list[0];
|
|
|
|
|
return new MsExchangesUnitContactEntity();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult DeleteContact(MsExchangesUnitContactEntity headData, string LINKID)
|
|
|
|
|
{
|
|
|
|
|
DBResult result = new DBResult();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from [info_client_contact] where GID='" + headData.GID + "' and LINKID='" + LINKID + "'");
|
|
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "删除出现错误,请重试";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "操作成功";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|