public bool UpdateOutStockHeader(OutStockHeaderViewModel model) { var instanceToUpdate = _outStockHeaderRepository.FindBy(x => x.OutStockHeaderNumber == model.OutStockNumber).FirstOrDefault(); if (instanceToUpdate == null) { return(false); } //instanceToUpdate.ApplicationPerson = model.ApplicationPerson; instanceToUpdate.CreatePerson = model.CreatePerson; //instanceToUpdate.FollowupPerson = model.FollowupPerson; instanceToUpdate.AuditDepart = model.AuditDepart; instanceToUpdate.Auditor = model.Auditor; instanceToUpdate.UpdateDate = DateTime.Now; try { _outStockHeaderRepository.Edit(instanceToUpdate); _outStockHeaderRepository.Save(); return(true); } catch (Exception) { return(false); } }
private void gridView1_RowUpdated(object sender, RowObjectEventArgs e) { SplashScreenManager.ShowDefaultWaitForm(); OutStockHeaderViewModel row = (OutStockHeaderViewModel)this.gridView1.GetFocusedRow(); _stockService.UpdateOutStockHeader(row); SplashScreenManager.CloseDefaultWaitForm(); }
private void GenerateOutStockWorkSheet(OutStockHeaderViewModel outStockHeaderViewModel, ExcelWorksheet template) { if (outStockHeaderViewModel == null) { return; } decimal subTotal = 0; var row = 8; template.Name = outStockHeaderViewModel.OutStockNumber; template.InsertRow(row, outStockHeaderViewModel.OutStockViewModels.Count); //Header var requestHeader = _requestHeaderRepository.FindBy(x => x.RequestHeaderNumber == outStockHeaderViewModel.RequestNumber).Include(c => c.Contract).FirstOrDefault(); template.Cells["B3"].Value = DateTime.Now.ToString("yyyy-MM-dd"); //出单日期 template.Cells["D3"].Value = outStockHeaderViewModel.ApplicationDept; //制表科室 template.Cells["F3"].Value = outStockHeaderViewModel.CreatePerson; //制表人 template.Cells["H3"].Value = outStockHeaderViewModel.AuditDepart; //审核部门 template.Cells["J3"].Value = outStockHeaderViewModel.AuditDepart; //审核人 template.Cells["D4"].Value = outStockHeaderViewModel.AuditDepart; //领料人 template.Cells["B4"].Value = outStockHeaderViewModel.OutStockNumber; //出库单号 template.Cells["F4"].Value = outStockHeaderViewModel.CreatePerson; //领料小组 if (requestHeader != null) { template.Cells["H4"].Value = requestHeader.Contract.Address; //出货地址 template.Cells["J4"].Value = requestHeader.Contract.ContractNumber; //合同编号 template.Cells["B5"].Value = requestHeader.RequestCategory.ToString(); //出库类型 } //Body foreach (var m in outStockHeaderViewModel.OutStockViewModels) { var serialNo = "A" + row; var name = "B" + row; var code = "C" + row; var model = "D" + row; var specification = "E" + row; var dimension = "F" + row; var position = "G" + row; //库位 var total = "H" + row; var unit = "I" + row; var currentPrice = "J" + row; var totalPrice = "K" + row; var note = "L" + row; template.Cells[serialNo].Value = serialNo; template.Cells[name].Value = m.Name; template.Cells[code].Value = m.Code; template.Cells[model].Value = m.Model; template.Cells[specification].Value = m.Specification; template.Cells[dimension].Value = m.Dimension; template.Cells[position].Value = m.PositionName; template.Cells[total].Value = m.Total; template.Cells[unit].Value = m.Unit; template.Cells[currentPrice].Value = $"{m.Price:C}"; template.Cells[totalPrice].Value = $"{m.Price * m.Total:C}"; template.Cells[note].Value = m.Note; template.Row(row).Height = 35; template.Cells[serialNo + ":" + note].Style.Font.Size = 12; template.Cells[serialNo + ":" + note].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; template.Cells[serialNo + ":" + note].Style.VerticalAlignment = ExcelVerticalAlignment.Center; template.Cells[serialNo + ":" + note].Style.Border.Top.Style = ExcelBorderStyle.Thin; template.Cells[serialNo + ":" + note].Style.Border.Left.Style = ExcelBorderStyle.Thin; template.Cells[serialNo + ":" + note].Style.Border.Right.Style = ExcelBorderStyle.Thin; template.Cells[serialNo + ":" + note].Style.Border.Bottom.Style = ExcelBorderStyle.Thin; subTotal = subTotal + (decimal)m.Price * m.Total; row++; } template.Cells["K" + row++].Value = $"{subTotal:C}"; //总计 template.Cells["K" + row++].Value = $"{subTotal * (decimal)0.13:C}"; //HST template.Cells["K" + row].Value = $"{subTotal * (decimal)1.13:C}"; //总合计 }