using System; using System.Data; using System.Collections.Generic; using System.Text; using DSWeb.MvcShipping.Models.CodeAll; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.Areas.CommMng.Models; using HcUtility.Comm; using DSWeb.Common.DB; using System.Linq; namespace DSWeb.MvcShipping.DAL.MsCodeAll { public class MsCodeAllDAL { #region 航线信息 /// /// /// /// /// /// /// static public List GetLanesList ( string strCondition, string companyid, string sort = null ) { var strSql = new StringBuilder(); strSql.Append(" SELECT "); strSql.Append(" GID,LANEID,LANE,LANEEN,EDICODE,OP,DOC,CUSTSERVICE,CUSTOMERNAME"); strSql.Append(" from code_lanes "); 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 LANEID"); } return SetLanesData(strSql); } static public Code_lanesmb GetLanesData ( string condition, string companyid ) { Code_lanesmb data = null; var list = GetLanesList(condition, companyid); if (list.Count > 0) data = list[0]; if (data == null) { data = new Code_lanesmb(); } return data; } private static List SetLanesData ( StringBuilder strSql ) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { Code_lanesmb data = new Code_lanesmb(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.LANEID = Convert.ToString(reader["LANEID"]); data.LANE = Convert.ToString(reader["LANE"]); data.LANEEN = Convert.ToString(reader["LANEEN"]); data.EDICODE = Convert.ToString(reader["EDICODE"]); data.OP = Convert.ToString(reader["OP"]); data.DOC = Convert.ToString(reader["DOC"]); data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]); data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 航线港口信息 static public List GetLanesPortList(string LANEID) { var cdc = new CommonDataContext(); var list = new List(); list = cdc.vw_code_lanes_port.Where(x => x.LANEID == LANEID).OrderBy(o=>o.ORDERNO).ToList(); return list; } #endregion } }