using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DSWeb.EntityDA;
using System.IO;
namespace DSWeb.SeanInfo
{
public partial class SeanInTradeList : System.Web.UI.Page
{
public string strUserID;//登录用户GID
public string strCompanyID;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
DSWeb.EntityDA.Opsean opp = new EntityDA.Opsean();
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
//this.hdUserID.Value = strUserID;
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
if (!this.Page.IsPostBack)
{
//this.LoadMessage();
}
}
//protected void LoadDropInfo()
//{
// this.GetVesslInfo();
// this.GetGoodName();
// this.GetPortLoad();
// this.GetDisPortLoad();
//}
///
/// 显示信息
///
public void LoadMessage()
{
DataSet ds = opp.GetOPSEAN(strCompanyID);
PagedDataSource pas = new PagedDataSource();
AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
pas.DataSource = ds.Tables[0].DefaultView;
pas.AllowPaging = true;
pas.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pas.PageSize = AspNetPager1.PageSize;
this.repeaterMess.DataSource = pas;
this.repeaterMess.DataBind();
}
///
/// 转换显示的字符----费用状态
///
///
public string changeShow(object str)
{
if (str!=DBNull.Value)
{
bool strr = Convert.ToBoolean(str);
if (strr)
{
return "已锁定";
}
else
{
return "未锁定";
}
}
else
{
return "";
}
}
///
/// 加载船名
///
//public void GetVesslInfo()
//{
// DataSet ds = opp.GetTCodeVessel();
// if (ds != null)
// {
// this.drop_vessName.DataSource = ds.Tables[0].DefaultView;
// this.drop_vessName.DataTextField = "NEWVESSL";
// this.drop_vessName.DataValueField = "CNAME";
// this.drop_vessName.DataBind();
// }
// ListItem list = new ListItem("---请选择船名---","");
// this.drop_vessName.Items.Insert(0,list);
//}
///
/// 航次
///
//public void GetVoyo()
//{
// DataSet ds = opp.GetOPSEAN(strCompanyID);
// if (ds != null)
// {
// this.drop_voyoNum.DataSource = ds.Tables[0].DefaultView;
// this.drop_voyoNum.DataTextField = "VOYNO";
// this.drop_voyoNum.DataValueField = "VOYNO";
// this.drop_voyoNum.DataBind();
// }
// ListItem list = new ListItem("---请选择航次---","");
// drop_voyoNum.Items.Insert(0,list);
//}
/////
///// 船公司
/////
//public void GetCarrierInfo()
//{
// DataSet ds = opp.GetOPSEAN(strCompanyID);
// if (ds != null)
// {
// this.drop_carrier.DataSource = ds.Tables[0].DefaultView;
// this.drop_carrier.DataTextField = "CARRIER";
// this.drop_carrier.DataValueField = "CARRIER";
// this.drop_carrier.DataBind();
// }
// ListItem newlist = new ListItem("--请选择船公司--", "");
// drop_carrier.Items.Insert(0,newlist);
//}
///
/// 物品名称加载
///
//public void GetGoodName()
//{
// DataSet ds = opp.GetGoodsInfo();
// if (ds != null)
// {
// this.drop_goodsname.DataSource = ds.Tables[0].DefaultView;
// this.drop_goodsname.DataTextField = "CODEANDNAME";
// this.drop_goodsname.DataValueField = "GOODNAME";
// this.drop_goodsname.DataBind();
// }
// ListItem newlist = new ListItem("--请选择物品名称--", "");
// drop_goodsname.Items.Insert(0, newlist);
//}
///
/// 加载装货港
///
//public void GetPortLoad()
//{
// DataSet ds = opp.GetTCodeLoadport();
// if (ds != null)
// {
// this.drop_portload.DataSource = ds.Tables[0].DefaultView;
// this.drop_portload.DataTextField = "NEWPORT";
// this.drop_portload.DataValueField = "CNAME";
// this.drop_portload.DataBind();
// }
// ListItem newlist = new ListItem("--请选择装货港--", "");
// drop_portload.Items.Insert(0, newlist);
//}
///
/// 加载卸货港
///
//public void GetDisPortLoad()
//{
// DataSet ds = opp.GetTCodeDisport();
// if (ds != null)
// {
// this.drop_portdischarge.DataSource = ds.Tables[0].DefaultView;
// this.drop_portdischarge.DataTextField = "NEWPORT";
// this.drop_portdischarge.DataValueField = "CNAME";
// this.drop_portdischarge.DataBind();
// }
// ListItem newlist = new ListItem("--请选择卸货港--", "");
// drop_portdischarge.Items.Insert(0, newlist);
//}
///
/// 搜索
///
protected void GetSearchInfo()
{
//运单号/委托单位/箱号/发货人/收货人/揽货人/装货地址/送货地址/封号/船公司/船名/航次/品名/装货港/卸货港:
string etdtime = txt_endTime.Value.Trim();//启港日期
string etatime = txt_enaTime.Value.Trim();//入港日期
string accdate = this.txt_accdate.Text.Trim();//会计期间
string alllsearch = this.txt_allsearch.Text.Trim();//多条件
DataSet ds = opp.GetDataByConditon(etdtime, etatime,accdate,alllsearch);
if (ds != null)
{
PagedDataSource pas = new PagedDataSource();
AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
pas.DataSource = ds.Tables[0].DefaultView;
pas.AllowPaging = true;
pas.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pas.PageSize = AspNetPager1.PageSize;
this.repeaterMess.DataSource = pas;
this.repeaterMess.DataBind();
}
}
protected void img_search_Click(object sender, ImageClickEventArgs e)
{
this.GetSearchInfo();
}
///
/// 公共消息提示
///
///
public void CommonMessageBox(string strtext)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "", "");
}
protected void img_DeleteInfo_Click(object sender, ImageClickEventArgs e)
{
string[] ctnids = this.hid_saveallinfo.Value.Trim().Split(',');
int ii = opp.DeleteSeanInfo(ctnids);
if (ii == 1)
{
this.CommonMessageBox("删除成功");
this.LoadMessage();
}
else
{
this.CommonMessageBox("删除失败,请重试");
}
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
this.GetSearchInfo();
}
//转换时间显示格式
protected string ShowDateTime(object obt)
{
if (Convert.ToString(obt) != "")
{
DateTime time = Convert.ToDateTime(obt);
if (time != null)
{
return time.ToString("yyyy-MM-dd").Trim();
}
else
{
return "--";
}
}
else
{
return "--";
}
}
protected void img_btnexcel_Click(object sender, ImageClickEventArgs e)
{
string etdtime = txt_endTime.Value.Trim();//启港日期
string etatime = txt_enaTime.Value.Trim();//入港日期
string accdate = this.txt_accdate.Text.Trim();//会计期间
string alllsearch = this.txt_allsearch.Text.Trim();//多条件
DataSet ds = opp.SetOpseanEcxel(etdtime, etatime,accdate,alllsearch);
if (ds != null)
{
string excelHeader = "委托编号\t委托单位\t委托方式\t业务状态\t费用状态\t会计期间\t运单号\t发货人\t收货人\t船公司\t船名\t航次\t开船日期\t到港日期\t装货港\t卸货港\t物品名称\t毛重\t毛重单位\t尺码\t尺码单位\t操作员\t揽货人\t录入人\t录入时间\t修改人\t修改时间\t装货地址\t送货地址";
ExcelDA ExcelDA = new EntityDA.ExcelDA();
MemoryStream ms = ExcelDA.RenderToExcel(ds.Tables[0],excelHeader.ToString().Trim());
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
}
}
}
}