//保存表单数据 public ActionResult SaveData(GiveBill givebill) { //参数对象可以对应接受数据 givebill.MakePerson = Session["UserName"].ToString(); //保存制单人 string result = GiveBillService.SaveData(givebill); //保存数据 return(Content(result.ToString())); }
private string AddGiveBill(DataTable dt) { GiveBill bill = DataTableToEntites.GetEntity <GiveBill>(dt.Rows[0]); bill.Record = HandleRecords(dt); GiveBillService Service = new GiveBillService(); Service.SaveData(bill); return(bill.BillCode); }
/// <summary> /// 根据立邦交货单号获取数据 /// </summary> /// <returns></returns> public ActionResult GetDataByBillCode(string BillCode) { GiveBill bill = GiveBillService.LoadEntities(t => t.BillCode == BillCode).FirstOrDefault();//获取表单 if (bill == null) { return(Content("no")); } else { return(Json(bill)); } }
/// <summary> /// 导出交货单 /// </summary> /// <param name="billId"></param> /// <returns></returns> private MemoryStream ExportGiveBill(Guid billId, string TemplateUrl) { GiveBill bill = CurrentDBSession.GiveBillDal.LoadEntities(a => a.Id == billId).FirstOrDefault(); if (bill == null) { return(null); } //根据模板创建Datatable DataTable dt = ExcelHelp.ExcelToDT(TemplateUrl); foreach (var record in bill.Record) { DataRow dr = dt.NewRow(); dr["LBBillCode"] = bill.LBBillCode; dr["LBBillDate"] = bill.LBBillDate; dr["LBTaskBillCode"] = bill.LBTaskBillCode; dr["LBLine"] = bill.LBLine; dr["LBContacts"] = bill.LBContacts; dr["LBPhone"] = bill.LBPhone; dr["LBMailCode"] = bill.LBMailCode; dr["LBCustomerCode"] = bill.LBCustomerCode; dr["LBCustomerName"] = bill.LBCustomerName; dr["LBSendAddress"] = bill.LBSendAddress; dr["LBRemark"] = bill.LBRemark; dr["CreateDate"] = bill.CreateDate; dr["ChargePerson"] = bill.ChargePerson; dr["MakePerson"] = bill.MakePerson; dr["Warehouse"] = bill.Warehouse; dr["WarehouseId"] = bill.WarehouseId; dr["LoadGoodsType"] = bill.LoadGoodsType; dr["OutputType"] = bill.OutputType; dr["OutputTypeId"] = bill.OutputTypeId; dr["BusinessType"] = bill.BusinessType; dr["LineWay"] = bill.LineWay; dr["Remark"] = bill.Remark; dr["Department"] = bill.Department; dr["DepartmentId"] = bill.DepartmentId; dr["Company"] = bill.Company; dr["CompanyId"] = bill.CompanyId; //子表 dr["ItemCode"] = record.ItemCode; dr["ItemLocationId"] = record.ItemLocationId; dr["ItemBatch"] = record.ItemBatch; dr["Count"] = record.Count; dt.Rows.Add(dr); } return(NPIOHelper.RenderToMemory(dt, "sheet1")); }
//获取表单数据[根据id] public ActionResult GetData() { string str = Request.Params["GiveBillId"];//单号 //如果新单据 没有数据 if (string.IsNullOrEmpty(str)) { return(null); } //如果有数据 Guid GiveBillId = new Guid(Request["GiveBillId"]); //单据编号 GiveBill bill = GiveBillService.LoadEntities(t => t.Id == GiveBillId).FirstOrDefault(); //获取表单 return(Json(bill)); }
/// <summary> /// 批量导入交货单 /// </summary> /// <param name="dt"></param> /// <returns></returns> private string AddManyGiveBills(DataTable dt) { string res = ""; GiveBillService Service = new GiveBillService(); //转成集合 List <ManyGiveBillsModel> list = new List <ManyGiveBillsModel>(); foreach (DataRow row in dt.Rows) { ManyGiveBillsModel model = new ManyGiveBillsModel() { LBBillCode = row[0].ToString(), LBCustomerCode = row[1].ToString(), LBCustomerName = row[2].ToString(), ItemCode = row[4].ToString(), ItemName = row[5].ToString(), ItemBatch = row[7].ToString(), Count = Convert.ToDouble(row[8]), Weight = Convert.ToDouble(row[9]), ItemLocationId = row[10].ToString(), ItemLocation = row[11].ToString(), LBContacts = row[12].ToString(), LBPhone = row[13].ToString(), LBSendAddress = row[14].ToString(), LBMailCode = row[15].ToString(), LBBillDate = Convert.ToDateTime(row[16]), WarehouseId = Convert.ToInt32(row[17]), Warehouse = row[18].ToString(), ChargePerson = row[19].ToString() }; list.Add(model); } //按立邦单号排序 list.Sort((x, y) => { int value = x.LBBillCode.CompareTo(y.LBBillCode); if (value == 0) { value = x.ItemCode.CompareTo(y.ItemCode); } return(value); }); string CurrentLBBillCode = ""; //当前立邦单号 GiveBill bill = null; //当前交货单 foreach (var item in list) { //新的一条单据 if (item.LBBillCode != CurrentLBBillCode) { //保存上一张单据 if (CurrentLBBillCode != "") { res += Service.SaveImport(bill); } //新建下一张单据 bill = new GiveBill() { LBBillCode = item.LBBillCode, LBCustomerCode = item.LBCustomerCode, LBCustomerName = item.LBCustomerName, LBContacts = item.LBContacts, LBPhone = item.LBPhone, LBSendAddress = item.LBSendAddress, LBMailCode = item.LBMailCode, LBBillDate = item.LBBillDate, WarehouseId = item.WarehouseId, Warehouse = item.Warehouse, ChargePerson = item.ChargePerson }; } Record record = new Record() { ItemCode = item.ItemCode, ItemName = item.ItemName, ItemBatch = item.ItemBatch, Count = item.Count, Weight = item.Weight, ItemLocation = item.ItemLocation, ItemLocationId = item.ItemLocationId }; bill.Record.Add(record); CurrentLBBillCode = item.LBBillCode; } //循环结束 保存最后一条 if (bill != null) { res += Service.SaveImport(bill); } return(res); }