using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL;
using CY.Model;
using CY.Infrastructure.Query;
using CY.Infrastructure.Common;
using CY.BLL.OA;
using CY.BLL.Sys;
namespace CY.WebForm.Pages.business
{
//吴辉
//商业信函打印格式选择
public partial class SendAllLettersChange : BasePage
{
Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
OA_StaffBLL bll_OA_StaffBLL = null;
//初始化
public SendAllLettersChange()
{
bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
bll_OA_StaffBLL = new OA_StaffBLL();
}
//页面加载
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindType();
}
}
//绑定快递单类型
public void BindType()
{
string Keyid = Request["Keyid"].ToString2();
string[] Keyids = Keyid.Trim(',').Split(',');
this.spanCustormsCount.InnerText = Keyids.Length.ToString2();
this.spanAllChangeCount.InnerText = Keyids.Length.ToString2();
this.txtStartNum.Value = "1";
this.txtStartNum.Attributes.Add("max", Keyids.Length.ToString2());
this.txtEndNum.Value = Keyids.Length.ToString2();
this.txtEndNum.Attributes.Add("max", Keyids.Length.ToString2());
this.selEMSType.DataSource = bll_Sys_DictionaryBLL.GetDataByType("快递单模版");
this.selEMSType.DataValueField = "Name";
this.selEMSType.DataTextField = "Name";
this.selEMSType.DataBind();
this.Sender.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, true, true);
this.Sender.DataTextField = "Name";
this.Sender.DataValueField = "Name";
this.Sender.DataBind();
if (CurrentUser.StaffId > 0)
{
this.Sender.SelectedValue = CurrentUser.TrueName;
}
}
//提交打印
protected void btn_submit_print(object sender, EventArgs e)
{
try
{
string Keyid = Request["Keyid"].ToString2().Trim(',');
string[] Keyids = Keyid.Split(',');
int StartNum = this.txtStartNum.Value.ToInt32() ?? 0;
int EndNum = this.txtEndNum.Value.ToInt32() ?? Keyids.Length;
int ChangeLength = EndNum - StartNum+1;
if (ChangeLength <= 0)
{
JavaScript.MessageBox("请选择正确的打印范围", this);
}
else
{
string[] newKeyids = new string[EndNum - StartNum + 1];
for (int i = 0; i <= EndNum - StartNum; i++)
newKeyids[i] = Keyids[i +StartNum-1];
string newKeyid = string.Join(",", newKeyids);
string PrintType = this.selEMSType.SelectedValue.ToString2();
string OutScript = "OpenByFramDialog('/Pages/business/SendAllLetters.aspx?i=" + newKeyid + "&p=" + PrintType + "&d=" + this.Sender.SelectedValue + "&s=" + Request["sendfrom"].ToString2() + "&h=" + this.txtInfoName.Value+ "','商业信函', 930, 580);";
//Response.Write("");
this.ClientScript.RegisterStartupScript(this.GetType(), "key", string.Format("", OutScript));
}
}
catch (Exception ex)
{
PAGEHandleException(ex);
JavaScript.MessageBox("请选择正确的打印范围", this);
}
}
}
}