/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, ZZT_PDDLogEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
/// <summary> /// 批量(新增) /// </summary> /// <param name="dtSource">实体对象</param> /// <returns></returns> public string BatchAddPDD(DataTable dtSource) { IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); try { for (int i = 0; i < dtSource.Rows.Count; i++) { string mobile = dtSource.Rows[i][4].ToString(); string telphone = dtSource.Rows[i][5].ToString(); if (!string.IsNullOrWhiteSpace(mobile)) { string CustNo = ""; DateTime? NullTime = null; string orderTimeStr = dtSource.Rows[i][16].ToString(); string payTimeStr = dtSource.Rows[i][17].ToString(); string deliveryTimeStr = dtSource.Rows[i][18].ToString(); string printingTimeStr = dtSource.Rows[i][19].ToString(); DateTime? orderTime=string.IsNullOrEmpty(orderTimeStr)? NullTime : DateTime.ParseExact(orderTimeStr, "yyyy/M/d H:m:s", System.Globalization.CultureInfo.CurrentCulture); DateTime? payTime = string.IsNullOrEmpty(payTimeStr) ? NullTime : DateTime.ParseExact(payTimeStr, "yyyy/M/d H:m:s", System.Globalization.CultureInfo.CurrentCulture); DateTime? deliveryTime = string.IsNullOrEmpty(deliveryTimeStr) ? NullTime : DateTime.ParseExact(deliveryTimeStr, "yyyy/M/d H:m:s", System.Globalization.CultureInfo.CurrentCulture); DateTime? printingTime = string.IsNullOrEmpty(printingTimeStr) ? NullTime : DateTime.ParseExact(printingTimeStr, "yyyy/M/d H:m:s", System.Globalization.CultureInfo.CurrentCulture); var old_Data = db.FindEntity<ZZT_PDDCustomerEntity>(t => t.Mobile == mobile); //是否此前购买过 if (old_Data != null) { CustNo = old_Data.CustNo; old_Data.OrderNo = dtSource.Rows[i][1].ToString(); old_Data.OrderTime = orderTime; old_Data.Province = dtSource.Rows[i][6].ToString(); old_Data.City = dtSource.Rows[i][7].ToString(); old_Data.County = dtSource.Rows[i][8].ToString(); old_Data.Address = dtSource.Rows[i][9].ToString(); old_Data.GoodsName = dtSource.Rows[i][15].ToString(); old_Data.Modify(old_Data.Id); db.Update(old_Data); } else { //新建PDD客户表 CustNo = coderuleService.SetBillCode(OperatorProvider.Provider.Current().UserId, SystemInfo.CurrentModuleId, "", db);//获得指定模块或者编号的单据号 ZZT_PDDCustomerEntity entity = new ZZT_PDDCustomerEntity() { CustNo = CustNo, OrderNo = dtSource.Rows[i][1].ToString(), OrderTime = orderTime, Mobile = mobile, Telphone = telphone, Province = dtSource.Rows[i][6].ToString(), City = dtSource.Rows[i][7].ToString(), County = dtSource.Rows[i][8].ToString(), Address = dtSource.Rows[i][9].ToString(), GoodsName = dtSource.Rows[i][15].ToString(), }; entity.Create(); db.Insert(entity); } //插入PDD日志 string parceNo = ChangeDataToD(dtSource.Rows[i][0].ToString()).ToString(); ZZT_PDDLogEntity logEntity = new ZZT_PDDLogEntity { CustNo = CustNo, ParcelNo = parceNo, OrderNo = dtSource.Rows[i][1].ToString(), NickName = dtSource.Rows[i][2].ToString(), FullName = dtSource.Rows[i][3].ToString(), Mobile = mobile, Telphone = telphone, Province = dtSource.Rows[i][6].ToString(), City = dtSource.Rows[i][7].ToString(), County = dtSource.Rows[i][8].ToString(), Address = dtSource.Rows[i][9].ToString(), ZipCode = dtSource.Rows[i][10].ToString(), Express = dtSource.Rows[i][11].ToString(), ExpressNo = dtSource.Rows[i][12].ToString(), Weight = dtSource.Rows[i][13].ToString(), Freight = dtSource.Rows[i][14].ToString(), GoodsName = dtSource.Rows[i][15].ToString(), OrderTime = orderTime, PayTime = payTime, DeliveryTime = deliveryTime, PrintingTime = printingTime, BuyerMessage = dtSource.Rows[i][20].ToString(), SellerMessage = dtSource.Rows[i][21].ToString(), MakeNote = dtSource.Rows[i][22].ToString(), MergeOrder = dtSource.Rows[i][23].ToString(), SendPerson = dtSource.Rows[i][24].ToString(), SendTelphone = dtSource.Rows[i][25].ToString(), SendProvince = dtSource.Rows[i][26].ToString(), SendCity = dtSource.Rows[i][27].ToString(), SendCounty = dtSource.Rows[i][28].ToString(), SendAddress = dtSource.Rows[i][29].ToString(), }; logEntity.Create(); db.Insert(logEntity); } } db.Commit(); return "导入成功"; } catch (Exception ex) { return ex.Message; } }
public ActionResult SaveForm(string keyValue, ZZT_PDDLogEntity entity) { zzt_pddlogbll.SaveForm(keyValue, entity); return(Success("操作成功。")); }