|
|
using System;
|
|
|
using System.Data;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using HcUtility.Comm;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using DSWeb.Areas.MvcShipping.Models.MsOpSeaeTD;
|
|
|
using System.IO;
|
|
|
using DSWeb.MvcShipping.DAL.DsSendmail;
|
|
|
using HcUtility.Core;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsOpSeaeTD
|
|
|
{
|
|
|
public class MsOpSeaeTDDAL
|
|
|
{
|
|
|
#region 查询
|
|
|
static public List<MsOpSeaeTDModel> GetDataList(string strCondition, string userid, int start, int limit, out int totalCount, string sort = null)
|
|
|
{
|
|
|
start -= 1;
|
|
|
var rangstr = "";
|
|
|
if (userid == "0")
|
|
|
{
|
|
|
rangstr = " 1=1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rangstr = GetRangDAStr("index", userid, "");
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select (select showname from [user] where gid = t.huodaiop) HuoDaiOPName,* from Op_Seae_T t where 1=1 ");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" " + strCondition);
|
|
|
}
|
|
|
//
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by inputdate desc");
|
|
|
}
|
|
|
int total = 0;
|
|
|
StringBuilder sb = PagerHelper.PageSQL(strSql.ToString(), start, limit, out total);
|
|
|
totalCount = total;
|
|
|
return SetData(sb);
|
|
|
}
|
|
|
|
|
|
static public MsOpSeaeTDModel GetData(string condition, string userid)
|
|
|
{
|
|
|
int totalCount = 0;
|
|
|
var list = GetDataList(condition, userid, 1, 1, out totalCount);
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
return list[0];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
static public MsOpSeaeTDModel GetData(string condition)
|
|
|
{
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select (select showname from [user] where gid = t.huodaiop) HuoDaiOPName,* from Op_Seae_T t where 1=1 ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
}
|
|
|
|
|
|
int total = 0;
|
|
|
StringBuilder sb = PagerHelper.PageSQL(strSql.ToString(), 0, 1, out total);
|
|
|
|
|
|
return SetData(sb)[0];
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 删除
|
|
|
|
|
|
public static DBResult DeletePiLiang(string bsnos)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
var billList = bsnos.Split(',');
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
try
|
|
|
{
|
|
|
foreach (var bill in billList)
|
|
|
{
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from Cust_Price where GID=" + bill + "");
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
}
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
result.Success = false;
|
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
result.Success = true;
|
|
|
result.Message = "操作成功";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private static List<MsOpSeaeTDModel> SetData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsOpSeaeTDModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpSeaeTDModel data = new MsOpSeaeTDModel();
|
|
|
data.GID = reader["GID"].ToString();
|
|
|
data.GP20 = Convert.ToInt32(reader["GP20"]);
|
|
|
data.GP40 = Convert.ToInt32(reader["GP40"]);
|
|
|
data.HC40 = Convert.ToInt32(reader["HC40"]);
|
|
|
data.OtherCtn = reader["OtherCtn"].ToString();
|
|
|
data.GoodsName = reader["GoodsName"].ToString();
|
|
|
data.Remarks = reader["Remarks"].ToString();
|
|
|
data.DingCangYaoQiu = reader["DingCangYaoQiu"].ToString();
|
|
|
data.HuoWuZhuangTai = reader["HuoWuZhuangTai"].ToString();
|
|
|
data.HuoDai = reader["HuoDai"].ToString();
|
|
|
data.HuoDaiOP = reader["HuoDaiOP"].ToString();
|
|
|
data.HuoDaiTel = reader["HuoDaiTel"].ToString();
|
|
|
data.JieGangShiJian = reader["JieGangShiJian"].ToString();
|
|
|
data.JieDanShiJian = reader["JieDanShiJian"].ToString();
|
|
|
data.QianDanDiDian = reader["QianDanDiDian"].ToString();
|
|
|
data.QianDanRiQi = reader["QianDanRiQi"].ToString();
|
|
|
data.QianDanFangShi = reader["QianDanFangShi"].ToString();
|
|
|
data.TiDanFenShu = reader["TiDanFenShu"].ToString();
|
|
|
data.YunShuTiaoKuan = reader["YunShuTiaoKuan"].ToString();
|
|
|
data.FuFeiFangShi = reader["FuFeiFangShi"].ToString();
|
|
|
data.MBLNO = reader["MBLNO"].ToString();
|
|
|
data.BSNO = reader["BSNO"].ToString();
|
|
|
data.INPUTBY = reader["INPUTBY"].ToString();
|
|
|
try
|
|
|
{
|
|
|
data.INPUTDATE = DateTime.Parse(reader["INPUTDATE"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
data.INPUTDATE = reader["INPUTDATE"].ToString();
|
|
|
}
|
|
|
|
|
|
data.SHIPPERINFO = reader["SHIPPERINFO"].ToString();
|
|
|
data.CONSIGNEEINFO = reader["CONSIGNEEINFO"].ToString();
|
|
|
data.NOTIFYPARTYINFO = reader["NOTIFYPARTYINFO"].ToString();
|
|
|
data.VESSEL = reader["VESSEL"].ToString();
|
|
|
data.VOYNO = reader["VOYNO"].ToString();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
data.ETD = DateTime.Parse(reader["ETD"].ToString()).ToString("yyyy-MM-dd");
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
data.ETD = reader["ETD"].ToString();
|
|
|
}
|
|
|
data.PORTLOAD = reader["PORTLOAD"].ToString();
|
|
|
data.PORTDISCHARGE = reader["PORTDISCHARGE"].ToString();
|
|
|
data.PLACEDELIVERY = reader["PLACEDELIVERY"].ToString();
|
|
|
data.DESTINATION = reader["DESTINATION"].ToString();
|
|
|
data.MARKS = reader["MARKS"].ToString();
|
|
|
data.DESCRIPTION = reader["DESCRIPTION"].ToString();
|
|
|
data.CARRIERID = reader["CARRIERID"].ToString();
|
|
|
data.YARD = reader["YARD"].ToString();
|
|
|
data.PKGS = Convert.ToDecimal(reader["PKGS"]);
|
|
|
data.KINDPKGS = reader["KINDPKGS"].ToString();
|
|
|
data.KGS = Convert.ToDecimal(reader["KGS"]);
|
|
|
data.CBM = Convert.ToDecimal(reader["CBM"]);
|
|
|
data.INPUTBYID = reader["INPUTBYID"].ToString();
|
|
|
data.CreateTime = reader["CreateTime"].ToString();
|
|
|
data.XJNO = reader["XJNO"].ToString();
|
|
|
data.HuoDaiOPName = reader["HuoDaiOPName"].ToString();
|
|
|
data.MBSID = reader["MBSID"].ToString();
|
|
|
data.MBFID = reader["MBFID"].ToString();
|
|
|
data.MBTID = reader["MBTID"].ToString();
|
|
|
data.YOUXIAOQI = reader["YOUXIAOQI"].ToString();
|
|
|
data.BSSTATUS = Convert.ToInt32(reader["BSSTATUS"]);
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
public static List<MsOpSeaeTDXJBJ> GetBJList(string strCondition, string userid, int start, int limit, out int totalCount, string sort = "")
|
|
|
{
|
|
|
start -= 1;
|
|
|
var rangstr = "";
|
|
|
if (userid == "0")
|
|
|
{
|
|
|
rangstr = " 1=1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rangstr = GetRangDAStr("index", userid, "");
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(@" SELECT t.*,
|
|
|
(SELECT SHOWNAME FROM [USER] WHERE GID = t.HDXSID) BAOJIAREN
|
|
|
FROM Op_Seae_HD_BJ_Recive t ");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
//
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" ORDER BY " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" ORDER BY Createtime desc");
|
|
|
}
|
|
|
int total = 0;
|
|
|
StringBuilder sb = PagerHelper.PageSQL(strSql.ToString(), start, limit, out total);
|
|
|
totalCount = total;
|
|
|
return SetBJData(sb);
|
|
|
}
|
|
|
|
|
|
public static List<MsOpSeaeTDFee> GetFeeList(string strCondition, string userid, int start, int limit, out int totalCount, string sort = "")
|
|
|
{
|
|
|
start -= 1;
|
|
|
var rangstr = "";
|
|
|
if (userid == "0")
|
|
|
{
|
|
|
rangstr = " 1=1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rangstr = GetRangDAStr("index", userid, "");
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(@" SELECT t.* from Op_Seae_T_FEE t ");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
//
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" ORDER BY " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" ORDER BY Createtime desc");
|
|
|
}
|
|
|
int total = 0;
|
|
|
StringBuilder sb = PagerHelper.PageSQL(strSql.ToString(), start, limit, out total);
|
|
|
totalCount = total;
|
|
|
return SetTDFeeData(sb);
|
|
|
}
|
|
|
|
|
|
private static List<MsOpSeaeTDFee> SetTDFeeData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsOpSeaeTDFee>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpSeaeTDFee data = new MsOpSeaeTDFee();
|
|
|
data.GID = reader["GID"].ToString();
|
|
|
data.TID = reader["TID"].ToString();
|
|
|
data.FNAME = reader["FNAME"].ToString();
|
|
|
data.FBIAOZHUN = reader["FBIAOZHUN"].ToString();
|
|
|
data.FBIBIE = reader["FBIBIE"].ToString();
|
|
|
data.FDANJIA = reader["FDANJIA"].ToString();
|
|
|
data.FHUILV = reader["FHUILV"].ToString();
|
|
|
data.FSHULIANG = reader["FSHULIANG"].ToString();
|
|
|
data.FJINE = reader["FJINE"].ToString();
|
|
|
data.FBEIZHU = reader["FBEIZHU"].ToString();
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
private static List<MsOpSeaeTDXJBJ> SetBJData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsOpSeaeTDXJBJ>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpSeaeTDXJBJ data = new MsOpSeaeTDXJBJ();
|
|
|
data.GID = reader["GID"].ToString();
|
|
|
data.XJID = reader["XJID"].ToString();
|
|
|
data.HDCOMNAME = reader["HDCOMNAME"].ToString();
|
|
|
data.CARRIERID = reader["CARRIERID"].ToString();
|
|
|
data.HDXSID = reader["HDXSID"].ToString();
|
|
|
data.BJDATE = reader["CreateTime"].ToString();
|
|
|
data.FREEDAYS = reader["FREEDAYS"].ToString();
|
|
|
data.YOUXIAOQI = reader["YOUXIAOQI"].ToString();
|
|
|
data.ZBSTATUS = reader["ZBSTATUS"].ToString();
|
|
|
data.BAOJIAREN = reader["BAOJIAREN"].ToString();
|
|
|
data.feeCZF = Convert.ToDecimal(reader["feeCZF"]);
|
|
|
data.feeHYF = Convert.ToDecimal(reader["feeHYF"]);
|
|
|
data.feeMTF = Convert.ToDecimal(reader["feeMTF"]);
|
|
|
data.feeXSF = Convert.ToDecimal(reader["feeXSF"]);
|
|
|
data.feeBEIZHU = reader["feeBEIZHU"].ToString();
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 权限范围-托单信息
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="tb"></param>
|
|
|
/// <param name="userid"></param>
|
|
|
/// <param name="username"></param>
|
|
|
/// <param name="companyid"></param>
|
|
|
/// <param name="type">0:VGM</param>
|
|
|
/// <returns></returns>
|
|
|
public static string GetRangDAStr(string tb, string userid, string companyid, int type = 0)
|
|
|
{
|
|
|
string str = "";
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
strSql.Append(" where [NAME]='modCustCZJL' 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=2";
|
|
|
}
|
|
|
else if (visiblerange == "3")
|
|
|
{
|
|
|
|
|
|
str = " (lururenid ='" + userid + "')";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
var userstr = new StringBuilder();
|
|
|
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " COMID = '" + companyid + "'";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "1")
|
|
|
{
|
|
|
str = " COMID = '" + companyid + "'";
|
|
|
}
|
|
|
else if (visiblerange == "7")
|
|
|
{
|
|
|
str = " CZCOM = (select comname from [user] where gid = '" + userid + "')";
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
public static string GetComidWithComName(string comname)
|
|
|
{
|
|
|
string sql = "select COMPANYID from user_company where USERID = (select top 1 GID from [user] where COMNAME ='" + comname + "')";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string comid = "";
|
|
|
try
|
|
|
{
|
|
|
var o = db.ExecuteScalar(CommandType.Text, sql);
|
|
|
if (o != null && o != DBNull.Value)
|
|
|
{
|
|
|
comid = o.ToString();
|
|
|
}
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
comid = "";
|
|
|
}
|
|
|
return comid;
|
|
|
}
|
|
|
|
|
|
public static string GetPagerHTML(int total, int currPage, int limit)
|
|
|
{
|
|
|
string html = "";
|
|
|
string prevEnabel = "";
|
|
|
string nextEnabel = "";
|
|
|
|
|
|
|
|
|
int pageCnt = (int)Math.Ceiling((double)total / limit);
|
|
|
|
|
|
if (currPage == 1)
|
|
|
{
|
|
|
prevEnabel = "disabled";
|
|
|
}
|
|
|
if (currPage == pageCnt)
|
|
|
{
|
|
|
nextEnabel = "disabled";
|
|
|
}
|
|
|
|
|
|
html += "<li class=\"page-item " + prevEnabel + "\"><a class=\"page-link\" ac=\"prev\" href=\"#\">上一页</a></li>";
|
|
|
for (int i = 0; i < pageCnt; i++)
|
|
|
{
|
|
|
if (i > 10)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
int shownum = i + 1;
|
|
|
string classname = "page-item";
|
|
|
if (shownum == currPage)
|
|
|
{
|
|
|
classname = "page-item active";
|
|
|
}
|
|
|
html += "<li class=\"" + classname + "\"><a class=\"page-link\" href=\"#\">" + shownum + "</a></li>";
|
|
|
}
|
|
|
html += "<li class=\"page-item " + nextEnabel + "\"><a class=\"page-link\" href=\"#\" ac=\"next\">下一页</a></li>";
|
|
|
|
|
|
return html;
|
|
|
}
|
|
|
|
|
|
public static List<MsSelModel> GetSelDataWithName(string name, string userid, string condition = "")
|
|
|
{
|
|
|
string sql = "";
|
|
|
if (name == "cgs")
|
|
|
{
|
|
|
sql = "select codename value,codename+'-'+shortname text from info_Client where iscarrier= 1";
|
|
|
}
|
|
|
else if (name == "hd")
|
|
|
{
|
|
|
sql = "select comname value,comname text from [user] ";
|
|
|
}
|
|
|
else if (name == "op")
|
|
|
{
|
|
|
sql = "select gid value,showname text from [user] ";
|
|
|
}
|
|
|
else if (name == "port")
|
|
|
{
|
|
|
sql = "select EDICODE value,PORT text from Code_Disport";
|
|
|
}
|
|
|
else if (name == "ystk")//运输条款
|
|
|
{
|
|
|
sql = "select service value,service text from code_service";
|
|
|
}
|
|
|
else if (name == "fffs")//付费方式
|
|
|
{
|
|
|
sql = "select FEID value,frt text from code_frt";
|
|
|
}
|
|
|
else if (name == "sftmb")//收发通模板
|
|
|
{
|
|
|
sql = "select gid value,mbname text from op_seae_t_mb";
|
|
|
}
|
|
|
else if (name =="comname")
|
|
|
{
|
|
|
sql = "select distinct comname text,comname value from [user]";
|
|
|
}
|
|
|
else if (name == "tdcust")
|
|
|
{
|
|
|
sql = "select distinct GroupName text,gid value from [Op_Seae_T_Cust]";
|
|
|
}
|
|
|
if (condition != "")
|
|
|
{
|
|
|
sql = sql + " where 1=1 and " + condition;
|
|
|
}
|
|
|
return SetSelData(sql);
|
|
|
}
|
|
|
|
|
|
private static List<MsSelModel> SetSelData(string strSql)
|
|
|
{
|
|
|
var list = new List<MsSelModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
MsSelModel ma = new MsSelModel();
|
|
|
ma.text = "请选择";
|
|
|
ma.value = "*";
|
|
|
list.Add(ma);
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsSelModel m = new MsSelModel();
|
|
|
m.text = reader["text"].ToString();
|
|
|
m.value = reader["value"].ToString();
|
|
|
list.Add(m);
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
#region 询价
|
|
|
public static List<MsOpSeaeTDXJModel> GetDataList_XJ(string strCondition, string userid, int start, int limit, out int totalCount, string sort = null)
|
|
|
{
|
|
|
start -= 1;
|
|
|
var rangstr = "";
|
|
|
if (userid == "0")
|
|
|
{
|
|
|
rangstr = " 1=1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rangstr = GetRangDAStr("index", userid, "");
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select * from Op_Seae_T_XJ t");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
//
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by Createtime desc");
|
|
|
}
|
|
|
int total = 0;
|
|
|
StringBuilder sb = PagerHelper.PageSQL(strSql.ToString(), start, limit, out total);
|
|
|
totalCount = total;
|
|
|
return SetData_XJ(sb);
|
|
|
}
|
|
|
|
|
|
public static MsOpSeaeTDXJModel GetData_XJ(string condition, string userid)
|
|
|
{
|
|
|
int totalCount = 0;
|
|
|
var list = GetDataList_XJ(condition, userid, 1, 1, out totalCount);
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
return list[0];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private static List<MsOpSeaeTDXJModel> SetData_XJ(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsOpSeaeTDXJModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpSeaeTDXJModel data = new MsOpSeaeTDXJModel();
|
|
|
data.GID = reader["GID"].ToString();
|
|
|
data.GP20 = Convert.ToInt32(reader["GP20"]);
|
|
|
data.GP40 = Convert.ToInt32(reader["GP40"]);
|
|
|
data.HC40 = Convert.ToInt32(reader["HC40"]);
|
|
|
data.OtherCtn = reader["OtherCtn"].ToString();
|
|
|
data.Remarks = reader["Remarks"].ToString();
|
|
|
data.INPUTDATE = reader["INPUTDATE"].ToString();
|
|
|
data.PORTLOAD = reader["PORTLOAD"].ToString();
|
|
|
data.PORTDISCHARGE = reader["PORTDISCHARGE"].ToString();
|
|
|
data.DESTINATION = reader["DESTINATION"].ToString();
|
|
|
data.DESCRIPTION = reader["DESCRIPTION"].ToString();
|
|
|
data.TID = reader["TID"].ToString();
|
|
|
data.XJNO = reader["XJNO"].ToString();
|
|
|
data.HDXSID = reader["HDXSID"].ToString();
|
|
|
data.CreateTime = reader["CreateTime"].ToString();
|
|
|
data.FREEDAYS = Convert.ToInt32(reader["FREEDAYS"]);
|
|
|
data.ETD = reader["ETD"].ToString();
|
|
|
data.YOUXIAOQI = reader["YOUXIAOQI"].ToString();
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<MsOpSeaeTDXJHDModel> GetDataList_XJ_HD(string strCondition, string userid, string sort = null)
|
|
|
{
|
|
|
|
|
|
var rangstr = "";
|
|
|
if (userid == "0")
|
|
|
{
|
|
|
rangstr = " 1=1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rangstr = GetRangDAStr("index", userid, "");
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select CONVERT(varchar(100), ETD, 23) ETD2,CONVERT(varchar(100), YOUXIAOQI, 23) YOUXIAOQI2,* from Op_Seae_T_XJ_HD t");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
//
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by Createtime desc");
|
|
|
}
|
|
|
return SetData_XJ_HD(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsOpSeaeTDXJHDModel> SetData_XJ_HD(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsOpSeaeTDXJHDModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpSeaeTDXJHDModel data = new MsOpSeaeTDXJHDModel();
|
|
|
data.GID = reader["GID"].ToString();
|
|
|
data.XJID = reader["XJID"].ToString();
|
|
|
data.HDCOMNAME = reader["HDCOMNAME"].ToString();
|
|
|
data.HDXSID = reader["HDXSID"].ToString();
|
|
|
data.CARRIERID = reader["CARRIERID"].ToString();
|
|
|
data.ETD = reader["ETD2"].ToString();
|
|
|
data.YOUXIAOQI = reader["YOUXIAOQI2"].ToString();
|
|
|
data.CreateTime = reader["CreateTime"].ToString();
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
public static DBResult SaveTDXJDetail(MsOpSeaeTDXJModel headData, List<MsOpSeaeTDXJHDModel> bodyList)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
try
|
|
|
{
|
|
|
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
var cmdDel = db.GetSqlStringCommand(@"delete from Op_Seae_T_XJ_HD where xjid = '" + headData.GID + "'");
|
|
|
db.ExecuteNonQuery(cmdDel, tran);
|
|
|
foreach (var body in bodyList)
|
|
|
{
|
|
|
string ETDStr = body.ETD == "" ? "null" : "'" + body.ETD + "'";
|
|
|
string YOUXIAOQIStr = body.YOUXIAOQI == "" ? "null" : "'" + body.YOUXIAOQI + "'";
|
|
|
if (true)
|
|
|
{
|
|
|
body.GID = Guid.NewGuid().ToString();
|
|
|
body.XJID = headData.GID;
|
|
|
body.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
var cmdInsert = db.GetSqlStringCommand(@"insert into Op_Seae_T_XJ_HD (GID,XJID,HDCOMNAME,HDXSID,CARRIERID,ETD,YOUXIAOQI,CreateTime) values ('" +
|
|
|
body.GID + "','" +
|
|
|
body.XJID + "','" +
|
|
|
body.HDCOMNAME + "','" +
|
|
|
body.HDXSID + "','" +
|
|
|
body.CARRIERID + "'," +
|
|
|
ETDStr + "," +
|
|
|
YOUXIAOQIStr + ",'" +
|
|
|
body.CreateTime + "')");
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
}
|
|
|
//else
|
|
|
//{
|
|
|
|
|
|
// var cmdUpdate = db.GetSqlStringCommand(@"update Op_Seae_T_XJ_HD
|
|
|
// set HDCOMNAME ='"+ body.HDCOMNAME+
|
|
|
// "',HDXSID='"+ body.HDXSID+
|
|
|
// "',CARRIERID ='"+body.CARRIERID +
|
|
|
// "',ETD = "+ ETDStr +
|
|
|
// ",YOUXIAOQI = "+ YOUXIAOQIStr +
|
|
|
// " where GID='" + body.GID + "'");
|
|
|
// db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
//}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
result.Success = false;
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员。0012";
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
result.Success = true;
|
|
|
result.Message = "保存成功" + result.Message;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static string CreateXJNO(string userid)
|
|
|
{
|
|
|
string timeTemp = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + "01";
|
|
|
string sqlno = "select COUNT(*) from op_seae_t where INPUTBYID in (select gid from [user] where comname = (select comname from [user] where gid ='"+userid+"')) INPUTDATE >= '" + timeTemp + "' and ";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
int no = 0;
|
|
|
try
|
|
|
{
|
|
|
no = (int)db.ExecuteScalar(CommandType.Text, sqlno);
|
|
|
String fnum = String.Format("{0:0000}", Convert.ToInt16(no));
|
|
|
return "QDFL" + DateTime.Now.Year.ToString() + String.Format("{0:00}", Convert.ToInt16(DateTime.Now.Month)) + fnum;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return Guid.NewGuid().ToString();
|
|
|
throw;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public static string GetComnameWithUserid(string userid)
|
|
|
{
|
|
|
string sql = "select ISNULL(comname,'') from [user] where gid = '" + userid + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string comname = db.ExecuteScalar(CommandType.Text, sql).ToString();
|
|
|
return comname;
|
|
|
}
|
|
|
#endregion
|
|
|
public static DBResult InsertHDBJ(MsOpSeaeTDXJModel headData, List<MsOpSeaeTDXJHDModel> bodyList)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
try
|
|
|
{
|
|
|
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
var cmdDel = db.GetSqlStringCommand(@"delete from Op_Seae_HD_BJ where xjid = '" + headData.GID + "'");
|
|
|
db.ExecuteNonQuery(cmdDel, tran);
|
|
|
foreach (var body in bodyList)
|
|
|
{
|
|
|
string ETDStr = body.ETD == "" ? "null" : "'" + body.ETD + "'";
|
|
|
string YOUXIAOQIStr = body.YOUXIAOQI == "" ? "null" : "'" + body.YOUXIAOQI + "'";
|
|
|
if (true)
|
|
|
{
|
|
|
body.GID = Guid.NewGuid().ToString();
|
|
|
body.XJID = headData.GID;
|
|
|
body.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
var cmdInsert = db.GetSqlStringCommand(@"insert into Op_Seae_HD_BJ (GID,XJID,HDCOMNAME,HDXSID,CARRIERID,CreateTime) values ('" +
|
|
|
body.GID + "','" +
|
|
|
body.XJID + "','" +
|
|
|
body.HDCOMNAME + "','" +
|
|
|
body.HDXSID + "','" +
|
|
|
body.CARRIERID + "','" +
|
|
|
body.CreateTime + "')");
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
}
|
|
|
//else
|
|
|
//{
|
|
|
|
|
|
// var cmdUpdate = db.GetSqlStringCommand(@"update Op_Seae_T_XJ_HD
|
|
|
// set HDCOMNAME ='"+ body.HDCOMNAME+
|
|
|
// "',HDXSID='"+ body.HDXSID+
|
|
|
// "',CARRIERID ='"+body.CARRIERID +
|
|
|
// "',ETD = "+ ETDStr +
|
|
|
// ",YOUXIAOQI = "+ YOUXIAOQIStr +
|
|
|
// " where GID='" + body.GID + "'");
|
|
|
// db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
//}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
result.Success = false;
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员。0012";
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
result.Success = true;
|
|
|
result.Message = "保存成功" + result.Message;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//费用中标
|
|
|
public static bool ApplyFee(string gid, string userid, string tid,string op, out string msg)
|
|
|
{
|
|
|
int cnt = 0;
|
|
|
MsOpSeaeTDXJBJ bj;
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var o = GetBJList(" gid = '" + gid + "'", userid, 0, 100, out cnt);
|
|
|
|
|
|
if (o.Count > 0)
|
|
|
{
|
|
|
bj = o[0];
|
|
|
var feeList = GetFeeList(bj.GID);
|
|
|
string sqlUpd = "";
|
|
|
if (op=="0")
|
|
|
{
|
|
|
sqlUpd = @"update Op_Seae_T
|
|
|
set HuoDai = '' ,HuoDaiOP = '',CARRIERID = '' where gid = '" + tid + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlUpd = @"update Op_Seae_T
|
|
|
set HuoDai = '" + bj.HDCOMNAME + "' ,HuoDaiOP = '" + bj.HDXSID + "',CARRIERID = '" + bj.CARRIERID
|
|
|
+ "' where gid = '" + tid + "'";
|
|
|
}
|
|
|
|
|
|
int updRst = db.ExecuteNonQuery(CommandType.Text, sqlUpd);
|
|
|
if (updRst > 0)
|
|
|
{
|
|
|
DBResult rst2 = SaveApplyFeeDetail(feeList, tid,op);
|
|
|
msg = rst2.Message;
|
|
|
if (rst2.Success)
|
|
|
{
|
|
|
UpdateFeeStatus(gid,op);
|
|
|
}
|
|
|
|
|
|
return rst2.Success;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg = "更新提单失败";
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg = "不存在报价数据";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//获取接收到的费用明细
|
|
|
private static List<MsOpSeaeBJFeeRecive> GetFeeList(string gid)
|
|
|
{
|
|
|
string sql = "select * from Op_Seae_HD_BJ_FEE_Recive where HDBJID = '" + gid + "'";
|
|
|
return SetData_XJ_HD_Fee(sql);
|
|
|
|
|
|
}
|
|
|
private static List<MsOpSeaeBJFeeRecive> SetData_XJ_HD_Fee(string strSql)
|
|
|
{
|
|
|
var headList = new List<MsOpSeaeBJFeeRecive>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpSeaeBJFeeRecive data = new MsOpSeaeBJFeeRecive();
|
|
|
data.GID = reader["GID"].ToString();
|
|
|
data.HDBJID = reader["HDBJID"].ToString();
|
|
|
data.FNAME = reader["FNAME"].ToString();
|
|
|
data.FBIAOZHUN = reader["FBIAOZHUN"].ToString();
|
|
|
data.FBIBIE = reader["FBIBIE"].ToString();
|
|
|
data.FDANJIA = reader["FDANJIA"].ToString();
|
|
|
data.FHUILV = reader["FHUILV"].ToString();
|
|
|
data.FSHULIANG = reader["FSHULIANG"].ToString();
|
|
|
data.FJINE = reader["FJINE"].ToString();
|
|
|
data.FBEIZHU = reader["FBEIZHU"].ToString();
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static DBResult SaveApplyFeeDetail(List<MsOpSeaeBJFeeRecive> feeList, string tid,string op)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
try
|
|
|
{
|
|
|
|
|
|
if (feeList != null)
|
|
|
{
|
|
|
//删除费用明细
|
|
|
var cmdDel = db.GetSqlStringCommand(@"delete from Op_Seae_T_FEE where tid = '" + tid + "'");
|
|
|
int rst = db.ExecuteNonQuery(cmdDel, tran);
|
|
|
if (op=="0")
|
|
|
{
|
|
|
result.Success = true;
|
|
|
result.Message = "操作成功";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
foreach (var body in feeList)
|
|
|
{
|
|
|
|
|
|
body.GID = Guid.NewGuid().ToString();
|
|
|
|
|
|
//插入到费用表
|
|
|
var cmdInsert = db.GetSqlStringCommand(@"insert into Op_Seae_T_FEE (GID,TID,FNAME,FBIAOZHUN,FBIBIE,FDANJIA,FHUILV,FSHULIANG,FJINE,FBEIZHU) values ('" +
|
|
|
body.GID + "','" +
|
|
|
tid + "','" +
|
|
|
body.FNAME + "','" +
|
|
|
body.FBIAOZHUN + "','" +
|
|
|
body.FBIBIE + "',0,0,0," +
|
|
|
body.FJINE + ",'" +
|
|
|
body.FBEIZHU + "')");
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
result.Success = false;
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员。0342";
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
result.Success = true;
|
|
|
result.Message = "操作成功!" + result.Message;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static DBResult DelFee(string userid, string gid)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
string sql = "delete from Op_Seae_T_FEE where gid = '" + gid + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
try
|
|
|
{
|
|
|
int rst = db.ExecuteNonQuery(CommandType.Text, sql);
|
|
|
if (rst > 0)
|
|
|
{
|
|
|
result.Success = true;
|
|
|
result.Message = "删除成功";
|
|
|
return result;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "删除成功" + result.Message;
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "删除成功" + ex.Message;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//
|
|
|
|
|
|
}
|
|
|
|
|
|
public static DBResult DelTD(string userid, string gid)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
string sql = "delete from Op_Seae_T where gid in (" + gid + ")";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
try
|
|
|
{
|
|
|
int rst = db.ExecuteNonQuery(CommandType.Text, sql);
|
|
|
if (rst > 0)
|
|
|
{
|
|
|
result.Success = true;
|
|
|
result.Message = "删除成功";
|
|
|
return result;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "删除成功" + result.Message;
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "删除成功" + ex.Message;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//
|
|
|
|
|
|
}
|
|
|
|
|
|
public static string GetShowNameWithUserid(string userid)
|
|
|
{
|
|
|
string sql = "select showname from [user] where gid = '" + userid + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
try
|
|
|
{
|
|
|
return (string)db.ExecuteScalar(CommandType.Text, sql);
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return "";
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static DBResult SaveSFT(string name, string text, string type, string userid)
|
|
|
{
|
|
|
string gid = Guid.NewGuid().ToString();
|
|
|
string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.Append("insert into op_seae_t_mb (gid,mbname,mbtext,mbtype,createtime,userid) values (");
|
|
|
sb.Append("'" + gid + "',");
|
|
|
sb.Append("'" + name + "',");
|
|
|
sb.Append("'" + text + "',");
|
|
|
sb.Append("'" + type + "',");
|
|
|
sb.Append("'" + time + "',");
|
|
|
sb.Append("'" + userid + "'");
|
|
|
sb.Append(")");
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
DBResult result = new DBResult();
|
|
|
try
|
|
|
{
|
|
|
int rst = db.ExecuteNonQuery(CommandType.Text, sb.ToString());
|
|
|
if (rst > 0)
|
|
|
{
|
|
|
result.Success = true;
|
|
|
result.Message = "保存成功";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "保存失败";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
result.Message = e.Message;
|
|
|
result.Success = false;
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static MsOpSeaeTMB GetMBWithGID(string gid, string userid)
|
|
|
{
|
|
|
string sql = "select * from op_seae_t_mb where gid = '" + gid + "' and userid = '" + userid + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
MsOpSeaeTMB mb = new MsOpSeaeTMB();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
mb.GID = reader["GID"].ToString();
|
|
|
mb.USERID = reader["USERID"].ToString();
|
|
|
mb.MBNAME = reader["MBNAME"].ToString();
|
|
|
mb.MBTEXT = reader["MBTEXT"].ToString();
|
|
|
mb.MBTYPE = reader["MBTYPE"].ToString();
|
|
|
mb.CREATETIME = reader["CREATETIME"].ToString();
|
|
|
}
|
|
|
}
|
|
|
return mb;
|
|
|
}
|
|
|
|
|
|
public static bool SendXJMail(MsOpSeaeTDXJModel head, List<MsOpSeaeTDXJHDModel> hdlist)
|
|
|
{
|
|
|
MsOpSeaeTXJMailBody mb = GetMailContent(head.GID);
|
|
|
string hdUsers = "";
|
|
|
string ctnall = "";
|
|
|
if (head.GP20 != 0)
|
|
|
{
|
|
|
ctnall += "20GP*" + head.GP20 + ";";
|
|
|
}
|
|
|
if (head.GP40 != 0)
|
|
|
{
|
|
|
ctnall += "40GP*" + head.GP40 + ";";
|
|
|
}
|
|
|
if (head.HC40 != 0)
|
|
|
{
|
|
|
ctnall += "40HC*" + head.HC40 + ";";
|
|
|
}
|
|
|
if (head.OtherCtn != "")
|
|
|
{
|
|
|
ctnall += head.OtherCtn;
|
|
|
}
|
|
|
foreach (var item in hdlist)
|
|
|
{
|
|
|
hdUsers += "'" + item.HDXSID + "',";
|
|
|
|
|
|
}
|
|
|
|
|
|
hdUsers = hdUsers.Substring(0, hdUsers.Length - 1);
|
|
|
mb.DESCRIPTION = mb.DESCRIPTION.Replace("\r\n", "<br>");
|
|
|
var mailtopic = "MyShipping询价:" + mb.COMNAME + "" + mb.XJNO + "" + mb.USERNAME;
|
|
|
var mailbody = "起运港:" + mb.PORTLOAD + "<br>" + "目的港:" + GetPortNameWithCode(mb.DESTINATION) + "<br>" + "箱型箱量:" + ctnall
|
|
|
+ "<br>" + "船期:" + covertDatetimeToYMD(mb.ETD) + "<br>" + "品名:" + mb.DESCRIPTION + "<br>" + "要求免箱使天数:" + mb.FREEDAYS + "<br>" + "询价有效期:" + covertDatetimeToYMD(mb.YOUXIAOQI) + "<br> 询价人电话:" + mb.MOBILE
|
|
|
+ "<br>" + "询价人邮箱:" + mb.EMAIL;
|
|
|
mailbody += "<br>" + "<br><b style=\"color:blue\">该询价通过MyShipping发送,请您及时回复。</b><br><a target=\"_blank\" rel=\"noopener\" href=\"http:\\\\www.myshipping.net\">www.myshipping.net</a>";
|
|
|
var userlist = MsBaseInfoDAL.MsBaseInfoDAL.GetUserBaseList("USERID in (" + hdUsers + ")");
|
|
|
foreach (var user in userlist)
|
|
|
{
|
|
|
var email = user.EMAIL1;
|
|
|
SendEmail se = new SendEmail(email, "dongshengcangdan@h8j.top", "", "MYSHIPPING", mailtopic, mailbody, true);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
//se.SetSmtp("admin@dongshengsoft.com", "ds!@#)(*", "211.150.65.66", 465, false, System.Net.Mail.MailPriority.Normal, 8000); //必须在所有参数设置完后调用此方法
|
|
|
se.SetSmtp("dongshengcangdan@h8j.top", "A1B2C3ds040201", "smtpdm.aliyun.com", 80, false, System.Net.Mail.MailPriority.Normal, 8000); //必须在所有参数设置完后调用此方法
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
//se.SetSmtp("admin@dongshengsoft.com", "ds!@#)(*", "211.150.65.66", 465, false, System.Net.Mail.MailPriority.Normal, 8000); //必须在所有参数设置完后调用此方法
|
|
|
se.SetSmtp("dongshengcangdan@h8j.top", "A1B2C3ds040201", "smtpdm.aliyun.com", 80, false, System.Net.Mail.MailPriority.Normal, 8000); //必须在所有参数设置完后调用此方法
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private static MsOpSeaeTXJMailBody GetMailContent(string tgid)
|
|
|
{
|
|
|
MsOpSeaeTXJMailBody mb = new MsOpSeaeTXJMailBody();
|
|
|
string sql = @"select t1.COMNAME,
|
|
|
t.XJNO,
|
|
|
t1.SHOWNAME USERNAME,
|
|
|
t3.PORTLOAD,
|
|
|
t3.DESTINATION,
|
|
|
t3.GP20,
|
|
|
t3.GP40,
|
|
|
t3.HC40,
|
|
|
t3.OtherCtn,
|
|
|
t3.ETD,
|
|
|
t3.DESCRIPTION,
|
|
|
t3.FREEDAYS,
|
|
|
t2.MOBILE,
|
|
|
t2.EMAIL1 ,
|
|
|
t3.YOUXIAOQI
|
|
|
from op_seae_t t
|
|
|
left join [user] t1 on t.INPUTBYID = t1.GID
|
|
|
left join [user_baseinfo] t2 on t1.gid = t2.USERID
|
|
|
left join Op_Seae_T_XJ t3 on t.GID = t3.TID
|
|
|
where t3.GID = '" + tgid + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
mb.COMNAME = reader["COMNAME"].ToString();
|
|
|
mb.XJNO = reader["XJNO"].ToString();
|
|
|
mb.USERNAME = reader["USERNAME"].ToString();
|
|
|
mb.PORTLOAD = reader["PORTLOAD"].ToString();
|
|
|
mb.DESTINATION = reader["DESTINATION"].ToString();
|
|
|
mb.ETD = reader["ETD"].ToString();
|
|
|
mb.DESCRIPTION = reader["DESCRIPTION"].ToString();
|
|
|
mb.FREEDAYS = Convert.ToInt32(reader["FREEDAYS"].ToString());
|
|
|
mb.MOBILE = reader["MOBILE"].ToString();
|
|
|
mb.EMAIL = reader["EMAIL1"].ToString();
|
|
|
mb.YOUXIAOQI = reader["YOUXIAOQI"].ToString();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
return mb;
|
|
|
}
|
|
|
|
|
|
public static string GetPortNameWithCode(string code)
|
|
|
{
|
|
|
string sql = "select PORT from Code_Disport where EDICODE ='" + code + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
try
|
|
|
{
|
|
|
string name = db.ExecuteScalar(CommandType.Text, sql).ToString();
|
|
|
return name;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public static string covertDatetimeToYMD(string datetime)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string dt = DateTime.Parse(datetime).ToString("yyyy-MM-dd");
|
|
|
return dt;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return datetime;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static DBResult UpdateFeeStatus(string gid,string status)
|
|
|
{
|
|
|
string sql = "update Op_Seae_HD_BJ_Recive set ZBSTATUS = "+status+" where gid = '"+gid+"'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
DBResult dbr = new DBResult();
|
|
|
try
|
|
|
{
|
|
|
int rst = db.ExecuteNonQuery(CommandType.Text, sql);
|
|
|
if (rst > 0)
|
|
|
{
|
|
|
dbr.Success = true;
|
|
|
dbr.Message = "操作成功";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dbr.Success = false;
|
|
|
dbr.Message = "操作失败,没有相关数据0013";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
dbr.Success = false;
|
|
|
dbr.Message = e.Message;
|
|
|
}
|
|
|
return dbr;
|
|
|
}
|
|
|
|
|
|
public static List<MsOpSeaeHDBJFFee> GetBJDetailsList(string gid, string userid)
|
|
|
{
|
|
|
string sql = "select * from Op_Seae_HD_BJ_FEE_Recive where hdbgid = '" + gid + "' ";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
List< MsOpSeaeHDBJFFee> list = new List<MsOpSeaeHDBJFFee>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpSeaeHDBJFFee f = new MsOpSeaeHDBJFFee();
|
|
|
f.GID = reader["GID"].ToString();
|
|
|
f.HDBJID = reader["HDBJID"].ToString();
|
|
|
f.FNAME = reader["FNAME"].ToString();
|
|
|
f.FBIAOZHUN = reader["FBIAOZHUN"].ToString();
|
|
|
f.FBIBIE = reader["FBIBIE"].ToString();
|
|
|
f.FDANJIA = reader["FDANJIA"].ToString();
|
|
|
f.FHUILV = reader["FHUILV"].ToString();
|
|
|
f.FSHULIANG = reader["FSHULIANG"].ToString();
|
|
|
f.FJINE = reader["FJINE"].ToString();
|
|
|
f.FBEIZHU = reader["FBEIZHU"].ToString();
|
|
|
list.Add(f);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="tid"></param>
|
|
|
/// <param name="status">0:已录入 1:已提交2:已询价3:已报价4:已确认</param>
|
|
|
/// <returns></returns>
|
|
|
public static bool UpdateBSStatus(string tid,int status)
|
|
|
{
|
|
|
string sql = "update op_seae_t set bsstatus = "+status+" where gid = '" + tid + "' ";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
int rst = db.ExecuteNonQuery(CommandType.Text,sql);
|
|
|
return rst>0;
|
|
|
}
|
|
|
|
|
|
public static List<MsOpSeaeTDXJHDModel> GetHDListWithTCustID(string cid)
|
|
|
{
|
|
|
|
|
|
string sql = @"select t0.COMNAME,t1.ChuanGongSi,t0.LianXiRen from Op_Seae_T_CustDetails t0
|
|
|
left join Op_Seae_T_Cust t1 on t0.CID = t1.GID where t0.cid = '" + cid+"'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
List<MsOpSeaeTDXJHDModel> list = new List<MsOpSeaeTDXJHDModel>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpSeaeTDXJHDModel h = new MsOpSeaeTDXJHDModel();
|
|
|
h.GID = "*";
|
|
|
h.CARRIERID = reader["ChuanGongSi"].ToString();
|
|
|
h.HDCOMNAME = reader["COMNAME"].ToString();
|
|
|
h.HDXSID = reader["LianXiRen"].ToString();
|
|
|
list.Add(h);
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
}
|
|
|
} |