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.Sys; using CY.BLL.OA; using CY.BLL.EC; using CY.BLL.Inquiry; using CY.Model.Inquiry; using System.Drawing; using CY.Infrastructure.Logging; using CY.SQLDAL; using CY.Model.OA; using System.Data.SqlClient; namespace CY.WebForm.Pages.business { public partial class DeliverPlanPaicheList : BasePage { OA_DeliverPlanPaicheBLL _OA_DeliverPlanPaicheBLL = null; OA_StaffBLL bll_OA_StaffBLL = null; OA_CarManageBll _OA_CarManageBll = null; //初始化 public DeliverPlanPaicheList() { _OA_DeliverPlanPaicheBLL = new OA_DeliverPlanPaicheBLL(); bll_OA_StaffBLL = new OA_StaffBLL(); _OA_CarManageBll = new OA_CarManageBll(); } protected void Page_Load(object sender, EventArgs e) { UCPager1.AspNetPager.PageChanged += AspNetPager1_PageChanged; if (!IsPostBack) { switch (Request["Target"]) { case "AcceptOrderAll": AcceptAll(); break; case "AcceptOrderAll2": AcceptAll2(); break; default: InitialSelectData(); BindList(); return; } Response.End(); } } //加载查询条件 protected void InitialSelectData() { //this.selDriverId.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, null, null).Where(x => x.BF_IsDriver == true);//.Where(x => x.SM_Post.Equals("驾驶员")) ; //this.selDriverId.DataTextField = "Name"; //this.selDriverId.DataValueField = "Keyid"; //this.selDriverId.DataBind(); //this.selDriverId.Items.Insert(0, new ListItem("全部", "")); this.selCarId.DataSource = _OA_CarManageBll.SelectListByFirmId(CurrentUser.MemberId); this.selCarId.DataTextField = "CarNumber"; this.selCarId.DataValueField = "Keyid"; this.selCarId.DataBind(); this.selCarId.Items.Insert(0, new ListItem("全部", "")); this.selBusinessManager.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, true, false); this.selBusinessManager.DataTextField = "Name"; this.selBusinessManager.DataValueField = "Keyid"; this.selBusinessManager.DataBind(); this.selBusinessManager.Items.Insert(0, new ListItem("全部", "")); //this.selDriverIddo.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, null, null).Where(x => x.BF_IsDriver == true);//.Where(x => x.SM_Post.Equals("驾驶员")); //this.selDriverIddo.DataTextField = "Name"; //this.selDriverIddo.DataValueField = "Keyid"; //this.selDriverIddo.DataBind(); //this.selDriverIddo.Items.Insert(0, new ListItem("全部", "")); //this.selCarIddo.DataSource = _OA_CarManageBll.SelectListByFirmId(CurrentUser.MemberId); //this.selCarIddo.DataTextField = "CarNumber"; //this.selCarIddo.DataValueField = "Keyid"; //this.selCarIddo.DataBind(); //this.selCarIddo.Items.Insert(0, new ListItem("全部", "")); //this.Button0.Text = "逾期"; this.Button1.Text = DateTime.Now.ToString("yyyy-MM-dd"); this.Button2.Text = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"); this.Button3.Text = DateTime.Now.AddDays(2).ToString("yyyy-MM-dd"); this.Button4.Text = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd"); this.Button5.Text = DateTime.Now.AddDays(4).ToString("yyyy-MM-dd"); this.Button6.Text = DateTime.Now.AddDays(5).ToString("yyyy-MM-dd"); this.Button7.Text = "一周后";/*DateTime.Now.AddDays(6).ToString("yyyy-MM-dd");*/ this.selSonghuo.Value = "2"; //this.DriverId.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, null, null).Where(x => x.SM_Post.Equals("驾驶员")); //this.DriverId.DataTextField = "Name"; //this.DriverId.DataValueField = "Keyid"; //this.DriverId.DataBind(); //this.DriverId.Items.Insert(0, new ListItem("请选择", "")); //this.CarId.DataSource = _OA_CarManageBll.SelectListByFirmId(CurrentUser.MemberId); //this.CarId.DataTextField = "CarNumber"; //this.CarId.DataValueField = "Keyid"; //this.CarId.DataBind(); //this.CarId.Items.Insert(0, new ListItem("请选择", "")); } //分页事件 protected void AspNetPager1_PageChanged(object src, EventArgs e) { BindList(); } //查询事件 protected void btn_Search_Click(object sender, EventArgs e) { BindList(); } protected void btn_Search_Click0(object sender, EventArgs e) { //this.txtDeliveryTime.Value = this.Button0.Text; BindList(); } protected void btn_Search_Click1(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button1.Text; BindList(); } protected void btn_Search_Click2(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button2.Text; BindList(); } protected void btn_Search_Click3(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button3.Text; BindList(); } protected void btn_Search_Click4(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button4.Text; BindList(); } protected void btn_Search_Click5(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button5.Text; BindList(); } protected void btn_Search_Click6(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button6.Text; BindList(); } protected void btn_Search_Click7(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button7.Text; BindList(); } //绑定列表 private void BindList() { //EC_OrderBLL eC_OrderBLL = new EC_OrderBLL(); //Pagination pa1 = new Pagination(); //pa1.PageSize = 1000; //pa1.PageIndex = 1; //IEnumerable oA_DeliverPlans1 = eC_OrderBLL.GetshoukuantixingList(pa1,CurrentUser.MemberId, "", "", "", "", "", "", ""); if (this.txtDeliveryTime.Value == "") { this.txtDeliveryTime.Value = this.Button1.Text; } if(this.txtDeliveryTime.Value == this.Button1.Text) { this.Button1.BorderColor = Color.Black; this.Button2.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; this.Button6.BorderColor = Color.LightBlue; this.Button7.BorderColor = Color.LightBlue; //this.Button0.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button2.Text) { this.Button2.BorderColor = Color.Black; this.Button1.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; this.Button6.BorderColor = Color.LightBlue; this.Button7.BorderColor = Color.LightBlue; //this.Button0.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button3.Text) { this.Button3.BorderColor = Color.Black; this.Button2.BorderColor = Color.LightBlue; this.Button1.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; this.Button6.BorderColor = Color.LightBlue; this.Button7.BorderColor = Color.LightBlue; //this.Button0.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button4.Text) { this.Button4.BorderColor = Color.Black; this.Button2.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; this.Button1.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; this.Button6.BorderColor = Color.LightBlue; this.Button7.BorderColor = Color.LightBlue; //this.Button0.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button5.Text) { this.Button5.BorderColor = Color.Black; this.Button2.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; this.Button1.BorderColor = Color.LightBlue; this.Button6.BorderColor = Color.LightBlue; this.Button7.BorderColor = Color.LightBlue; //this.Button0.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button6.Text) { this.Button6.BorderColor = Color.Black; this.Button2.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; this.Button1.BorderColor = Color.LightBlue; this.Button7.BorderColor = Color.LightBlue; //this.Button0.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button7.Text) { this.Button7.BorderColor = Color.Black; this.Button2.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; this.Button6.BorderColor = Color.LightBlue; this.Button1.BorderColor = Color.LightBlue; //this.Button0.BorderColor = Color.LightBlue; } //else if (this.txtDeliveryTime.Value == this.Button0.Text) //{ // this.Button0.BorderColor = Color.Black; // this.Button2.BorderColor = Color.LightBlue; // this.Button3.BorderColor = Color.LightBlue; // this.Button4.BorderColor = Color.LightBlue; // this.Button5.BorderColor = Color.LightBlue; // this.Button6.BorderColor = Color.LightBlue; // this.Button1.BorderColor = Color.LightBlue; // this.Button7.BorderColor = Color.LightBlue; //} Pagination pa = new Pagination(); pa.PageSize = UCPager1.AspNetPager.PageSize; pa.PageIndex = UCPager1.AspNetPager.CurrentPageIndex; IEnumerable oA_DeliverPlans = _OA_DeliverPlanPaicheBLL.SelectModelPage(pa, CurrentUser.MemberId, this.txtDeliveryTime.Value, this.selCarId.Value, "", this.txtBeginDate.Value, this.txtEndDate.Value, "", this.txtCustormerName.Value.Trim(), this.selBusinessManager.Value, this.selSonghuo.Value ); Database DC = new Database(); try { List fileDataList = null; foreach (var oA_DeliverPlan in oA_DeliverPlans) { oA_DeliverPlan.SonghuodanTupian = "暂无"; string sqlStr = string.Format(@" select * from [dbo].[OA_attachment] where [OA_Id]='{0}' and [AttachmentType]=3 order by [CreateTime] ", oA_DeliverPlan.Keyid); SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection); //SqlDataAdapter myDa = new SqlDataAdapter(myCmd); var a = myCmd.ExecuteReader(); //myDa.Dispose(); fileDataList = new List(); OA_CorporateClientsContract Contract; var i = 1; while (a.Read()) { //注意如何将每次读取到的记录添加到listbox1中(因为第一次做时出错了,嘿嘿) Contract = new OA_CorporateClientsContract(); // Contract.Keyid = a.GetInt32(0); //Contract.CorporateClientsid = a.GetGuid(1); //Contract.CorporateClientsName = a.GetString(4); Contract.FileName = a[4].ToString(); Contract.PageCode = i; Contract.FilePath = a.GetString(2); // Contract.Remark = a.GetString(6); i += 1; fileDataList.Add(Contract); } a.Close(); //关闭sqldatareader if (fileDataList.Count > 0) { oA_DeliverPlan.SonghuodanTupian = ""; } } } catch (Exception ee) { new Log4NetAdapter().Log("查找送货单图片出错:" + ee.Message); } finally { if (DC.Connection.State != System.Data.ConnectionState.Closed) DC.Connection.Close(); } this.RepClientList.DataSource = oA_DeliverPlans; this.RepClientList.DataBind(); UCPager1.AspNetPager.RecordCount = pa.RecordCount; } /// /// 批量受理订单 /// public void AcceptAll() { Response.Clear(); string ids = string.Empty; string DeliverTimes = string.Empty; string BuyerIds = string.Empty; if (Request["ids"] != null) { ids = Request["ids"].ToString(); } if (Request["DeliverTimes"] != null) { DeliverTimes = Request["DeliverTimes"].ToString(); } if (Request["BuyerIds"] != null) { BuyerIds = Request["BuyerIds"].ToString(); } string[] idsArray = ids.Split(','); string[] DeliverTimesArray = DeliverTimes.Split(','); string[] BuyerIdsArray = BuyerIds.Split(','); if(idsArray!=null&& idsArray.Length > 0) { for(int i = 0; i < idsArray.Length; i++) { bool result = true; OA_DeliverPlan oA_DeliverPlan = _OA_DeliverPlanPaicheBLL.GetModelByKeyid(idsArray[i].ToGuid2(), BuyerIdsArray[i].ToGuid2(), DeliverTimesArray[i].ToDateTime2()); if (oA_DeliverPlan == null) { oA_DeliverPlan = new OA_DeliverPlan(); oA_DeliverPlan.Keyid = Guid.NewGuid(); oA_DeliverPlan.FirmId = CurrentUser.MemberId; oA_DeliverPlan.DeliverTime = DeliverTimesArray[i].ToDateTime2(); oA_DeliverPlan.BuyerId = BuyerIdsArray[i].ToGuid2(); oA_DeliverPlan.DeliveredTime = null; oA_DeliverPlan.Zhuyishixiang = ""; oA_DeliverPlan.Gongzuokaoping = ""; oA_DeliverPlan.CarId = 0; oA_DeliverPlan.DriverId = 0; oA_DeliverPlan.Transferstatus = 2; oA_DeliverPlan.TransfersTime = DateTime.Now; oA_DeliverPlan.Sort = 1; oA_DeliverPlan.Creater = CurrentUser.TrueMemberId; oA_DeliverPlan.CreateTime = DateTime.Now; oA_DeliverPlan.Updater = CurrentUser.TrueMemberId; oA_DeliverPlan.LastUpdateTime = DateTime.Now; oA_DeliverPlan.wentifankui = ""; result = _OA_DeliverPlanPaicheBLL.InsertModel(oA_DeliverPlan); } else { oA_DeliverPlan.Transferstatus = 2; oA_DeliverPlan.TransfersTime = DateTime.Now; result = _OA_DeliverPlanPaicheBLL.UpdateModel(oA_DeliverPlan); } if (!result) { //BindList(); Response.Write("-2"); return; } } } // BindList(); Response.Write("1"); } /// /// 批量派车 /// public void AcceptAll2() { Response.Clear(); int? carid = Request["CarId"].ToInt32(); //this.CarId.Value.ToGuid2(); int? driverId = Request["DriverId"].ToInt32(); //this.DriverId.Value.ToGuid2(); string ids = string.Empty; string DeliverTimes = string.Empty; string BuyerIds = string.Empty; if (Request["ids"] != null) { ids = Request["ids"].ToString(); } if (Request["DeliverTimes"] != null) { DeliverTimes = Request["DeliverTimes"].ToString(); } if (Request["BuyerIds"] != null) { BuyerIds = Request["BuyerIds"].ToString(); } string[] idsArray = ids.Split(','); string[] DeliverTimesArray = DeliverTimes.Split(','); string[] BuyerIdsArray = BuyerIds.Split(','); if (idsArray != null && idsArray.Length > 0) { for (int i = 0; i < idsArray.Length; i++) { bool result = true; OA_DeliverPlan oA_DeliverPlan = _OA_DeliverPlanPaicheBLL.GetModelByKeyid(idsArray[i].ToGuid2(), BuyerIdsArray[i].ToGuid2(), DeliverTimesArray[i].ToDateTime2()); if (oA_DeliverPlan == null) { oA_DeliverPlan = new OA_DeliverPlan(); oA_DeliverPlan.Keyid = Guid.NewGuid(); oA_DeliverPlan.FirmId = CurrentUser.MemberId; oA_DeliverPlan.DeliverTime = DeliverTimesArray[i].ToDateTime2(); oA_DeliverPlan.BuyerId = BuyerIdsArray[i].ToGuid2(); oA_DeliverPlan.DeliveredTime = null; oA_DeliverPlan.Zhuyishixiang = ""; oA_DeliverPlan.Gongzuokaoping = ""; oA_DeliverPlan.CarId = carid; oA_DeliverPlan.DriverId = driverId; oA_DeliverPlan.Transferstatus = 1; oA_DeliverPlan.TransfersTime = null; oA_DeliverPlan.Sort = 1; oA_DeliverPlan.Creater = CurrentUser.TrueMemberId; oA_DeliverPlan.CreateTime = DateTime.Now; oA_DeliverPlan.Updater = CurrentUser.TrueMemberId; oA_DeliverPlan.LastUpdateTime = DateTime.Now; oA_DeliverPlan.wentifankui = ""; result = _OA_DeliverPlanPaicheBLL.InsertModel(oA_DeliverPlan); } else { oA_DeliverPlan.CarId = carid; oA_DeliverPlan.DriverId = driverId; result = _OA_DeliverPlanPaicheBLL.UpdateModel(oA_DeliverPlan); } if (!result) { // BindList(); Response.Write("-2"); return; } } } //BindList(); Response.Write("1"); } } }