protected void gvLogistic_RowUpdating(object sender, GridViewUpdateEventArgs e) { int Id = 0; int.TryParse(this.gvLogistic.DataKeys[e.RowIndex].Value.ToString(), out Id); var row = this.gvLogistic.Rows[e.RowIndex]; HtmlInputText txtLogisticTime = row.FindControl("txtLogisticTime") as HtmlInputText; TextBox txtLogisticNumber = row.FindControl("txtLogisticNumber") as TextBox; TextBox txtLogisticCompany = row.FindControl("txtLogisticCompany") as TextBox; TextBox txtNote = row.FindControl("txtNote") as TextBox; if (txtLogisticTime.Value.ToString() == "") { base.ShowMessage("必须填写物流时间!"); return; } if (txtLogisticNumber.Text.ToString() == "") { base.ShowMessage("必须填写物流单号!"); return; } if (txtLogisticCompany.Text.ToString() == "") { base.ShowMessage("必须填写物流公司!"); return; } var Info = base.XMLogisticsInfoService.GetXMLogisticsInfoById(Id); if (Info != null) //更新数据 { Info.LogisticsDate = Convert.ToDateTime(txtLogisticTime.Value.ToString()); Info.LogisticsNumber = txtLogisticNumber.Text.Trim(); Info.LogisticsCompany = txtLogisticCompany.Text.Trim(); Info.Note = txtNote.Text.Trim(); Info.UpdateTime = DateTime.Now; Info.UpdateID = HozestERPContext.Current.User.CustomerID; base.XMLogisticsInfoService.UpdateXMLogisticsInfo(Info); } else //新增数据 { XMLogisticsInfo logisticInfo = new XMLogisticsInfo(); logisticInfo.OrderInfoID = XMOrderInfoID; logisticInfo.LogisticsDate = Convert.ToDateTime(txtLogisticTime.Value.ToString()); logisticInfo.LogisticsNumber = txtLogisticNumber.Text.Trim(); logisticInfo.LogisticsCompany = txtLogisticCompany.Text.Trim(); logisticInfo.Note = txtNote.Text.Trim(); logisticInfo.CreateDate = DateTime.Now; logisticInfo.CreateID = HozestERPContext.Current.User.CustomerID; logisticInfo.UpdateID = HozestERPContext.Current.User.CustomerID; logisticInfo.UpdateTime = DateTime.Now; logisticInfo.IsEnable = false; base.XMLogisticsInfoService.InsertXMLogisticsInfo(logisticInfo); } this.RowEditIndex = -1; this.BindGrid(this.Master.PageIndex, this.Master.PageSize); }
public void TimingGetLogisticsAging() { int UserID = 0; if (HozestERPContext.Current.User != null) { UserID = HozestERPContext.Current.User.CustomerID; } else { string UserName = "******"; List <Customer> customer = IoC.Resolve <ICustomerService>().GetCustomerByUsernameList(UserName); if (customer.Count > 0) { UserID = customer[0].CustomerID; } } int days = 0; var Days = IoC.Resolve <ISettingManager>().GetSettingByName("Logistics.Aging.NumberOfDays"); if (Days != null) { if (int.TryParse(Days.Value.Trim(), out days) && Days.Value.Trim() != "0") { days = int.Parse(Days.Value.Trim()); DateTime End = DateTime.Now; DateTime Begin = End.AddMonths(-6); var OrderIDList = IoC.Resolve <IXMOrderInfoService>().GetVPHXMOrderInfoListByDateTime(Begin, End); if (OrderIDList != null && OrderIDList.Count > 0) { foreach (int ID in OrderIDList) { var OrderInfo = IoC.Resolve <IXMOrderInfoService>().GetXMOrderInfoByID(ID); var LogisticsInfoList = IoC.Resolve <IXMLogisticsInfoService>().GetXMLogisticsInfoListByOrderInfoID(ID).OrderBy(x => x.CreateDate).ToList(); if (OrderInfo != null) { var LogisticsAgingList = IoC.Resolve <ILogisticsAgingService>().GetLogisticsAgingListByParam("", OrderInfo.City.Replace("市", "").Replace("区", ""), "-1"); if (LogisticsAgingList.Count > 0) { int Total = 0; int TotalDay = 0; LogisticsAging LogisticsAgingInfo = LogisticsAgingList[0]; TimeSpan ts1 = new TimeSpan(((DateTime)OrderInfo.DeliveryTime).Ticks); TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = ts1.Subtract(ts2).Duration();//显示时间 TotalDay += ts.Days; Total = GetDue(TotalDay, LogisticsAgingInfo, days); if (LogisticsInfoList.Count < Total) { List <string> list = GetFictitiousLogisticsInfoList((DateTime)OrderInfo.DeliveryTime, days, LogisticsAgingInfo); if (list.Count >= Total) { for (int i = LogisticsInfoList.Count; i < Total; i++) { XMLogisticsInfo Info = new XMLogisticsInfo(); Info.OrderInfoID = ID; Info.LogisticsDate = DateTime.Now; if (LogisticsInfoList.Count > 0) { Info.LogisticsNumber = LogisticsInfoList[0].LogisticsNumber; Info.LogisticsCompany = LogisticsInfoList[0].LogisticsCompany; } else { Info.LogisticsNumber = ""; Info.LogisticsCompany = ""; } Info.Note = list[i]; Info.IsExport = false; Info.IsEnable = false; Info.CreateID = UserID; Info.CreateDate = DateTime.Now; Info.UpdateID = UserID; Info.UpdateTime = DateTime.Now; IoC.Resolve <IXMLogisticsInfoService>().InsertXMLogisticsInfo(Info); } } } } } } } } } }