You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
486 lines
20 KiB
C#
486 lines
20 KiB
C#
|
|
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.MvcShipping.Models.MsOpLetter;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.EntityDA;
|
|
using HcUtility.Comm;
|
|
|
|
namespace DSWeb.Areas.MvcShipping.DAL
|
|
{
|
|
public class MsOpLetterDAL
|
|
{
|
|
#region Inquery DataList
|
|
|
|
static public List<MsOpLetter> GetDataList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("LE_ID,BSNO,HEAD_TO,HEAD_ATTN,LETTERNAME,INPUTBY,INPUTTIME,UpdateTime,");
|
|
strSql.Append("HEAD_ATTNTEL,HEAD_ATTNFAX,HEAD_FMTEL,HEAD_FMFAX,HEAD_FMEMAIL");
|
|
strSql.Append(" from op_letter ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public MsOpLetter GetData(string condition)
|
|
{
|
|
var list = GetDataList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetter();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetter> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetter>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsOpLetter data = new MsOpLetter();
|
|
#region Set DB data to Object
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
data.HEAD_TO = Convert.ToString(reader["HEAD_TO"]);
|
|
data.HEAD_ATTN = Convert.ToString(reader["HEAD_ATTN"]);
|
|
data.LETTERNAME = Convert.ToString(reader["LETTERNAME"]);
|
|
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
|
|
data.INPUTTIME = Convert.ToString(reader["INPUTTIME"]);
|
|
data.UpdateTime = Convert.ToString(reader["UpdateTime"]);
|
|
data.HEAD_ATTNTEL = Convert.ToString(reader["HEAD_ATTNTEL"]);
|
|
data.HEAD_ATTNFAX = Convert.ToString(reader["HEAD_ATTNFAX"]);
|
|
data.HEAD_FMTEL = Convert.ToString(reader["HEAD_FMTEL"]);
|
|
data.HEAD_FMFAX = Convert.ToString(reader["HEAD_FMFAX"]);
|
|
data.HEAD_FMEMAIL = Convert.ToString(reader["HEAD_FMEMAIL"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 入货通知
|
|
|
|
static public List<MsOpLetterYard> GetYardList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("LE_ID,MBLNO,PORTDISCHARGE,VESSELVOYNO,ETD,PKC,CNTR,[DESCRIPTION],YARD,[Address],Tel,YARD2,Address2,Tel2,TiXiangTime,RuHuoTime,");
|
|
strSql.Append("DRQ,CLOSEDOCDATE,ExportCustoms,CustomsCode,DeclarationCode,REMARK,CLOSINGDATE,DOC,CHIEF,CHIEF2,DOCTEL,DOCFAX,DOCEMAIL,CLOSEVGMDATE");
|
|
strSql.Append(" from op_letter_yard ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetYardData(strSql);
|
|
}
|
|
|
|
static public MsOpLetterYard GetYardData(string condition)
|
|
{
|
|
var list = GetYardList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetterYard();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetterYard> SetYardData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetterYard>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsOpLetterYard data = new MsOpLetterYard();
|
|
#region Set DB data to Object
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
data.VESSELVOYNO = Convert.ToString(reader["VESSELVOYNO"]);
|
|
if (reader["ETD"] != DBNull.Value)
|
|
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");//截港日期
|
|
// data.ETD = Convert.ToString(reader["ETD"]);
|
|
data.PKC = Convert.ToString(reader["PKC"]);
|
|
data.CNTR = Convert.ToString(reader["CNTR"]);
|
|
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.Address = Convert.ToString(reader["Address"]);
|
|
data.Tel = Convert.ToString(reader["Tel"]);
|
|
data.YARD2 = Convert.ToString(reader["YARD2"]);
|
|
data.Address2 = Convert.ToString(reader["Address2"]);
|
|
data.Tel2 = Convert.ToString(reader["Tel2"]);
|
|
data.DRQ = Convert.ToString(reader["DRQ"]);
|
|
data.CLOSEDOCDATE = Convert.ToString(reader["CLOSEDOCDATE"]);
|
|
if (reader["CLOSEDOCDATE"] != DBNull.Value)
|
|
data.CLOSEDOCDATE = Convert.ToDateTime(reader["CLOSEDOCDATE"]).ToString("yyyy-MM-dd HH:mm:ss");//截港日期 if (reader["CLOSINGDATE"] != DBNull.Value)
|
|
if (reader["CLOSINGDATE"] != DBNull.Value)
|
|
data.CLOSINGDATE = Convert.ToDateTime(reader["CLOSINGDATE"]).ToString("yyyy-MM-dd HH:mm:ss");//截港日期 if (reader["CLOSINGDATE"] != DBNull.Value)
|
|
data.ExportCustoms = Convert.ToString(reader["ExportCustoms"]);
|
|
data.CustomsCode = Convert.ToString(reader["CustomsCode"]);
|
|
data.DeclarationCode = Convert.ToString(reader["DeclarationCode"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.DOC = Convert.ToString(reader["DOC"]);
|
|
data.CHIEF = Convert.ToString(reader["CHIEF"]);
|
|
data.CHIEF2 = Convert.ToString(reader["CHIEF2"]);
|
|
data.DOCTEL = Convert.ToString(reader["DOCTEL"]);
|
|
data.DOCFAX = Convert.ToString(reader["DOCFAX"]);
|
|
data.DOCEMAIL = Convert.ToString(reader["DOCEMAIL"]);
|
|
data.CLOSEVGMDATE = Convert.ToString(reader["CLOSEVGMDATE"]);
|
|
if (reader["TiXiangTime"] != DBNull.Value)
|
|
data.TiXiangTime = Convert.ToDateTime(reader["TiXiangTime"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (reader["RuHuoTime"] != DBNull.Value)
|
|
data.RuHuoTime = Convert.ToDateTime(reader["RuHuoTime"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (reader["CLOSEVGMDATE"] != DBNull.Value)
|
|
data.CLOSEVGMDATE = Convert.ToDateTime(reader["CLOSEVGMDATE"]).ToString("yyyy-MM-dd HH:mm:ss");//截VGM日期
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
#region 派车通知
|
|
|
|
static public List<MsOpLetterTruck> GetTruckList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("LE_ID,BSNO,TRUCK,CTNS,YARD,YARDATTN,YARDTEL,INPUTTIME,FACTRYNAME,FACTRYTIME,FACTRYATTN,FACTRYTEL,");
|
|
strSql.Append("FACTRYADDR,RETURNYARD,RETURNATTN,RETURNTEL,TRUCKDATE,TRUCKFEE,PAYTYPE,REMARK,TRUCKDETAIL,");
|
|
strSql.Append("CLOSINGDATE,TEAMTYPE,ISTEAMSTATUS,INPUTBY,TRUCKSTATUS,CARGODATE");
|
|
strSql.Append(" from op_letter_truck ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
strSql.Append(" ORDER BY INPUTTIME DESC ");
|
|
|
|
return SetTruckData(strSql);
|
|
}
|
|
|
|
static public MsOpLetterTruck GetTruckData(string condition)
|
|
{
|
|
var list = GetTruckList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetterTruck();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetterTruck> SetTruckData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetterTruck>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsOpLetterTruck data = new MsOpLetterTruck();
|
|
#region Set DB data to Object
|
|
|
|
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.TRUCK = Convert.ToString(reader["TRUCK"]);
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
data.CTNS = Convert.ToString(reader["CTNS"]);
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.YARDATTN = Convert.ToString(reader["YARDATTN"]);
|
|
data.YARDTEL = Convert.ToString(reader["YARDTEL"]);
|
|
data.YARDTEL = Convert.ToString(reader["YARDTEL"]);
|
|
data.INPUTTIME = Convert.ToString(reader["INPUTTIME"]);
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.FACTRYNAME = Convert.ToString(reader["FACTRYNAME"]);
|
|
data.FACTRYTIME = Convert.ToString(reader["FACTRYTIME"]);
|
|
data.FACTRYATTN = Convert.ToString(reader["FACTRYATTN"]);
|
|
data.FACTRYTEL = Convert.ToString(reader["FACTRYTEL"]);
|
|
data.FACTRYADDR = Convert.ToString(reader["FACTRYADDR"]);
|
|
data.RETURNYARD = Convert.ToString(reader["RETURNYARD"]);
|
|
data.RETURNATTN = Convert.ToString(reader["RETURNATTN"]);
|
|
data.RETURNTEL = Convert.ToString(reader["RETURNTEL"]);
|
|
data.TRUCKDATE = Convert.ToString(reader["TRUCKDATE"]);
|
|
data.TRUCKFEE = Convert.ToString(reader["TRUCKFEE"]);
|
|
data.PAYTYPE = Convert.ToString(reader["PAYTYPE"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.TRUCKDETAIL = Convert.ToString(reader["TRUCKDETAIL"]);
|
|
data.CLOSINGDATE = Convert.ToString(reader["CLOSINGDATE"]);
|
|
data.TEAMTYPE = Convert.ToString(reader["TEAMTYPE"]);
|
|
data.ISTEAMSTATUS = Convert.ToString(reader["ISTEAMSTATUS"]);
|
|
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
|
|
data.TRUCKSTATUS = Convert.ToString(reader["TRUCKSTATUS"]);
|
|
data.CARGODATE = Convert.ToString(reader["CARGODATE"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
|
|
public static DBResult UpdateTruckStauts(string bsno,string status)
|
|
{
|
|
var result = new DBResult();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
var cmdDelete = db.GetSqlStringCommand("update op_letter_truck set TRUCKSTATUS='"+status+"' where LE_ID='" + bsno + "'");
|
|
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<MsOpLetterSur> GetSurList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("LE_ID,MBLNO,PORTLOAD,PORTDISCHARGE,VESSELVOYNO,CONSIGNEE,REMARK");
|
|
strSql.Append(" from op_letter_sur ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetSurData(strSql);
|
|
}
|
|
|
|
static public MsOpLetterSur GetSurData(string condition)
|
|
{
|
|
var list = GetSurList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetterSur();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetterSur> SetSurData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetterSur>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsOpLetterSur data = new MsOpLetterSur();
|
|
#region Set DB data to Object
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
data.VESSELVOYNO = Convert.ToString(reader["VESSELVOYNO"]);
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 更改通知
|
|
|
|
static public List<MsOpLetterChange> GetChangeList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("LE_ID,MBLNO,PORTDISCHARGE,VESSELVOYNO,ETD,PKC,CNTR,ProName,ProOld,ProNew,REMARK");
|
|
strSql.Append(" from op_letter_change ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetChangeData(strSql);
|
|
}
|
|
|
|
static public MsOpLetterChange GetChangeData(string condition)
|
|
{
|
|
var list = GetChangeList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetterChange();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetterChange> SetChangeData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetterChange>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
|
|
MsOpLetterChange data = new MsOpLetterChange();
|
|
#region Set DB data to Object
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
data.VESSELVOYNO = Convert.ToString(reader["VESSELVOYNO"]);
|
|
data.ETD = Convert.ToString(reader["ETD"]);
|
|
data.PKC = Convert.ToString(reader["PKC"]);
|
|
data.CNTR = Convert.ToString(reader["CNTR"]);
|
|
data.ProName = Convert.ToString(reader["ProName"]);
|
|
data.ProOld = Convert.ToString(reader["ProOld"]);
|
|
data.ProNew = Convert.ToString(reader["ProNew"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
public static DBResult DeleteDetail(MsOpLetter headData)
|
|
{
|
|
var 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 op_letter_yard where LE_ID='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
cmdDelete = db.GetSqlStringCommand("delete from op_letter_truck where LE_ID='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
cmdDelete = db.GetSqlStringCommand("delete from op_letter_sur where LE_ID='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
cmdDelete = db.GetSqlStringCommand("delete from op_letter_change where LE_ID='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
result.Success = true;
|
|
result.Message = "操作成功";
|
|
return result;
|
|
}
|
|
|
|
public static DBResult DeletePc(string LE_ID)
|
|
{
|
|
var 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 op_letter where LE_ID='" + LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
result.Success = true;
|
|
result.Message = "操作成功";
|
|
return result;
|
|
}
|
|
|
|
public static bool GetFeeCount(string BSNO)
|
|
{
|
|
var isfee = false;
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select count(*) as count ");
|
|
strSql.Append(" from ch_fee ");
|
|
strSql.Append(" where BSNO='" + BSNO + "'");
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var evData = Convert.ToInt32(reader["count"]);
|
|
if (evData > 0) { isfee = true; };
|
|
}
|
|
reader.Close();
|
|
}
|
|
return isfee;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 参照部分
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|