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; namespace CY.WebForm.Pages.business { public partial class DeliverPlanLishiList : BasePage { OA_DeliverPlanBLL _OA_DeliverPlanBLL = null; OA_StaffBLL bll_OA_StaffBLL = null; OA_CarManageBll _OA_CarManageBll = null; //初始化 public DeliverPlanLishiList() { _OA_DeliverPlanBLL = new OA_DeliverPlanBLL(); 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.txtDeliverTimestart.Value = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); this.txtDeliverTimeend.Value = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); } //分页事件 protected void AspNetPager1_PageChanged(object src, EventArgs e) { BindList(); } //查询事件 protected void btn_Search_Click(object sender, EventArgs e) { 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, "", "", "", "", "", "", ""); Pagination pa = new Pagination(); pa.PageSize = UCPager1.AspNetPager.PageSize; pa.PageIndex = UCPager1.AspNetPager.CurrentPageIndex; IEnumerable oA_DeliverPlans = _OA_DeliverPlanBLL.SelectModelPageLishi(pa, CurrentUser.MemberId, this.txtDeliverTimestart.Value, this.txtDeliverTimeend.Value, this.selCarId.Value, this.selDriverId.Value ); 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_DeliverPlanBLL.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_DeliverPlanBLL.InsertModel(oA_DeliverPlan); } else { oA_DeliverPlan.Transferstatus = 2; oA_DeliverPlan.TransfersTime = DateTime.Now; result = _OA_DeliverPlanBLL.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_DeliverPlanBLL.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_DeliverPlanBLL.InsertModel(oA_DeliverPlan); } else { oA_DeliverPlan.CarId = carid; oA_DeliverPlan.DriverId = driverId; result = _OA_DeliverPlanBLL.UpdateModel(oA_DeliverPlan); } if (!result) { // BindList(); Response.Write("-2"); return; } } } //BindList(); Response.Write("1"); } } }