protected override object GetEditObject() { MaterialBusiness materialBusiness = this.WarehouseFacade.CreateNewMaterialBusiness(); materialBusiness.BusinessCode = txtMaterialBusinessCodeEdit.Text.Trim().ToUpper(); materialBusiness.BusinessDesc = txtMaterialBusinessDescEdit.Text.Trim(); if (this.rblBussinessType.SelectedIndex == 0) { //入库 materialBusiness.BusinessType = BussinessType.type_in; if (chbFIFO.Checked == true) { materialBusiness.ISFIFO = "Y"; } else { materialBusiness.ISFIFO = "N"; } } else { materialBusiness.ISFIFO = ""; materialBusiness.BusinessType = BussinessType.type_out; } materialBusiness.OrgID = int.Parse(drpOrgEdit.SelectedValue); materialBusiness.SAPCODE = this.drpSAPCode.SelectedValue; materialBusiness.MaintainDate = FormatHelper.TODateInt(DateTime.Now.ToShortDateString()); materialBusiness.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); materialBusiness.MaintainUser = this.GetUserCode(); return(materialBusiness); }
private void GetMaterials() { MaterialBusiness MB = new MaterialBusiness(); List <WorkShopMaterial> Ls = MB.GetMaterials(); grdMaterial.DataSource = Ls; grdMaterial.DataBind(); }
//To Delete //public ActionResult Importool() //{ // var result = new ResultInfoModel() // { // IsSuccess = false // }; // StringBuilder strbuild = new StringBuilder(); // string FileName; // string savePath; // HttpPostedFileBase file = Request.Files["file"]; // if (file == null || file.ContentLength <= 0) // { // result.Message = "please choose file"; // return Content(JsonHelper.JsonSerializer(result)); // } // else // { // string fileName = Path.GetFileName(file.FileName); // int filesize = file.ContentLength;//获取上传文件的大小单位为字节byte // string fileEx = Path.GetExtension(fileName);//获取上传文件的扩展名 // string NoFileName = Path.GetFileNameWithoutExtension(fileName);//获取无扩展名的文件名 // int Maxsize = 4000 * 1024;//定义上传文件的最大空间大小为4M // string FileType = ".xls,.xlsx";//定义上传文件的类型字符串 // FileName = NoFileName + fileEx; // if (!FileType.Contains(fileEx)) // { // result.Message = "please upload .xls and .xlsx"; // return Content(JsonHelper.JsonSerializer(result)); // } // if (filesize >= Maxsize) // { // result.Message = string.Format("file size can't big than {0}", Maxsize); // return Content(JsonHelper.JsonSerializer(result)); // } // string path = Server.MapPath("~/App_Data/uploads"); // savePath = Path.Combine(path, FileName); // file.SaveAs(savePath); // } // string strConn; // strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;"; // using (OleDbConnection conn = new OleDbConnection(strConn)) // { // conn.Open(); // OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn); // DataSet myDataSet = new DataSet(); // try // { // myCommand.Fill(myDataSet, "ExcelInfo"); // } // catch (Exception ex) // { // result.Message = ex.Message; // return Content(JsonHelper.JsonSerializer(result)); // } // DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable(); // var importResult = new Importresult(); // importResult.FalseInfo = new List<FalseInfo>(); // try // { // for (int i = 0; i < table.Rows.Count; i++) // { // var model = new MaToolModel // { // //BMCode = table.Rows[i]["Code"].ToString() ?? "", // //BMCodeDesc = table.Rows[i]["CodeDesc"].ToString() ?? "", // //BMType = MTTypeEnum.Tool.GetHashCode(), // //BMIsValid = EnabledEnum.Enabled.GetHashCode(), // }; // var inserResult = MaterialBusiness.SaveMaTool(model, LoginUser); // } // result.IsSuccess = true; // } // catch (Exception ex) // { // result.Message = ex.Message; // return Content(JsonHelper.JsonSerializer(result)); // } // conn.Close(); // } // return Content(JsonHelper.JsonSerializer(result)); //} #endregion #region 导出 public FileResult MaterialExcel(MaterialSearchModel searchModel) { searchModel.PageSize = 1000; var totalCount = 0; var result = MaterialBusiness.SearchMaterialPageList(searchModel, out totalCount).ToList(); NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1"); //给sheet1添加第一行的头部标题 NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue("Process Type"); row1.CreateCell(1).SetCellValue("Customer"); row1.CreateCell(2).SetCellValue("RASP P/N"); row1.CreateCell(3).SetCellValue("Part Name"); row1.CreateCell(4).SetCellValue("Production Unit"); row1.CreateCell(5).SetCellValue("Customer P/N "); row1.CreateCell(6).SetCellValue("Cavity"); row1.CreateCell(7).SetCellValue("Cycletime"); row1.CreateCell(8).SetCellValue("cycletime/cav"); row1.CreateCell(9).SetCellValue("Standard Headcount"); row1.CreateCell(10).SetCellValue("Standard scrap"); row1.CreateCell(11).SetCellValue("Materials P/N"); row1.CreateCell(12).SetCellValue("g/cav(SAP)"); row1.CreateCell(13).SetCellValue("Mold No."); row1.CreateCell(14).SetCellValue("ASS AC"); row1.CreateCell(15).SetCellValue("Work Order"); for (int i = 0; i < result.Count(); i++) { NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1); rowtemp.CreateCell(0).SetCellValue(result[i].MIProcessType); rowtemp.CreateCell(1).SetCellValue(result[i].MICustomer); rowtemp.CreateCell(2).SetCellValue(result[i].MISapPN); rowtemp.CreateCell(3).SetCellValue(result[i].MIProductName); rowtemp.CreateCell(4).SetCellValue(result[i].MIInjectionMC); rowtemp.CreateCell(5).SetCellValue(result[i].MICustomerPN); rowtemp.CreateCell(6).SetCellValue(Convert.ToDouble(result[i].MICavity)); rowtemp.CreateCell(7).SetCellValue(Convert.ToDouble(result[i].MICycletime)); rowtemp.CreateCell(8).SetCellValue(Convert.ToDouble(result[i].MICycletimeCav)); rowtemp.CreateCell(9).SetCellValue(Convert.ToDouble(result[i].MIStandardHeadcount)); rowtemp.CreateCell(10).SetCellValue(result[i].MTStandardScrap); rowtemp.CreateCell(11).SetCellValue(result[i].MIMaterialPN); rowtemp.CreateCell(12).SetCellValue(Convert.ToDouble(result[i].MICavityG)); rowtemp.CreateCell(13).SetCellValue(result[i].MIMoldNo); rowtemp.CreateCell(14).SetCellValue(result[i].MIAssAC); rowtemp.CreateCell(15).SetCellValue(result[i].MIWorkOrder); } // 写入到客户端 System.IO.MemoryStream ms = new System.IO.MemoryStream(); book.Write(ms); ms.Seek(0, SeekOrigin.Begin); var exportFileName = string.Format("{0}{1}.xls", "MaterialInfo", DateTime.Now.ToString("yyyyMMddHHmmss")); return(File(ms, "application/vnd.ms-excel", exportFileName)); }
public ActionResult WorkOrderExport(MaterialOtherSearchModel model) { model.PageSize = 1000; var totalCount = 0; var result = MaterialBusiness.MaterialOtherSearch(model, out totalCount).ToList(); NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1"); //给sheet1添加第一行的头部标题 NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue("Order No"); row1.CreateCell(1).SetCellValue("Sap No"); row1.CreateCell(2).SetCellValue("Product "); row1.CreateCell(3).SetCellValue("Receipt Time"); row1.CreateCell(4).SetCellValue("Receipt By"); row1.CreateCell(5).SetCellValue("Close Date/Shift"); row1.CreateCell(6).SetCellValue("Order Archived"); row1.CreateCell(7).SetCellValue("Parameter Record"); row1.CreateCell(8).SetCellValue("Maintenance Record"); row1.CreateCell(9).SetCellValue("Tool Machine Setup Check List "); row1.CreateCell(10).SetCellValue("Quantity Confirm"); row1.CreateCell(11).SetCellValue("Archived By"); row1.CreateCell(12).SetCellValue("Weekly Check"); row1.CreateCell(13).SetCellValue("Remarks"); row1.CreateCell(14).SetCellValue("GetBy"); row1.CreateCell(15).SetCellValue("GetTime"); for (int i = 0; i < result.Count(); i++) { NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1); rowtemp.CreateCell(0).SetCellValue(result[i].WIWorkOrder); rowtemp.CreateCell(1).SetCellValue(result[i].WISapPN); rowtemp.CreateCell(2).SetCellValue(result[i].WIProductName); rowtemp.CreateCell(3).SetCellValue(result[i].WIReceiptTime); rowtemp.CreateCell(4).SetCellValue(result[i].WIReceiptBy); rowtemp.CreateCell(5).SetCellValue(result[i].WICloseDateShift); rowtemp.CreateCell(6).SetCellValue(result[i].WIOrderArchived); rowtemp.CreateCell(7).SetCellValue(result[i].WIParameterRecord); rowtemp.CreateCell(8).SetCellValue(result[i].WIToolMaintenanceRecord); rowtemp.CreateCell(9).SetCellValue(result[i].WIToolMachineCheck); rowtemp.CreateCell(10).SetCellValue(result[i].WIQuantityConfirm); rowtemp.CreateCell(11).SetCellValue(result[i].WIArchivedBy); rowtemp.CreateCell(12).SetCellValue(result[i].WIWeeklyCheck); rowtemp.CreateCell(13).SetCellValue(result[i].WIRemarks); rowtemp.CreateCell(14).SetCellValue(result[i].WIGetBy); rowtemp.CreateCell(15).SetCellValue(result[i].WIGetTime); } // 写入到客户端 System.IO.MemoryStream ms = new System.IO.MemoryStream(); book.Write(ms); ms.Seek(0, SeekOrigin.Begin); var exportFileName = string.Format("{0}{1}.xls", "WorkOrderInfo", DateTime.Now.ToString("yyyyMMddHHmmss")); return(File(ms, "application/vnd.ms-excel", exportFileName)); }
protected override void SetEditObject(object obj) { if (obj == null) { txtMaterialBusinessCodeEdit.Text = ""; txtMaterialBusinessDescEdit.Text = ""; drpOrgEdit.SelectedIndex = 0; this.rblBussinessType.SelectedIndex = 0; chbFIFO.Enabled = true; drpSAPCode.SelectedIndex = 0; chbFIFO.Checked = false; return; } MaterialBusiness materialBusiness = (MaterialBusiness)obj; txtMaterialBusinessCodeEdit.Text = materialBusiness.BusinessCode; txtMaterialBusinessDescEdit.Text = materialBusiness.BusinessDesc; try { this.drpOrgEdit.SelectedValue = materialBusiness.OrgID.ToString(); } catch { this.drpOrgEdit.SelectedIndex = 0; } if (materialBusiness.BusinessType == BussinessType.type_in) { this.rblBussinessType.SelectedIndex = 0; chbFIFO.Enabled = true; } else { chbFIFO.Enabled = false; this.rblBussinessType.SelectedIndex = 1; } try { this.drpSAPCode.SelectedValue = materialBusiness.SAPCODE; } catch { this.drpSAPCode.SelectedIndex = 0; } if (materialBusiness.ISFIFO == "Y") { chbFIFO.Checked = true; } else { chbFIFO.Checked = false; } }
public ActionResult MachineToolExcel(MaToolSearchModel model) { model.PageSize = 1000; var totalCount = 0; var result = MaterialBusiness.SearchMaToolPageList(model, out totalCount).ToList(); NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1"); //给sheet1添加第一行的头部标题 NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue("Equipment/Fixture Name"); row1.CreateCell(1).SetCellValue("Equipment No"); row1.CreateCell(2).SetCellValue("Fixture No"); row1.CreateCell(3).SetCellValue("Type"); row1.CreateCell(4).SetCellValue("Serial Number"); row1.CreateCell(5).SetCellValue("Quantity"); row1.CreateCell(6).SetCellValue("Manufactured Date"); row1.CreateCell(7).SetCellValue("power"); row1.CreateCell(8).SetCellValue("Outline Dimension"); row1.CreateCell(9).SetCellValue("Ability"); row1.CreateCell(10).SetCellValue("Pressure air"); row1.CreateCell(11).SetCellValue("Cooling water"); row1.CreateCell(12).SetCellValue("Incoming Date"); row1.CreateCell(13).SetCellValue("Remark"); for (int i = 0; i < result.Count(); i++) { NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1); rowtemp.CreateCell(0).SetCellValue(result[i].BMEquipmentName); rowtemp.CreateCell(1).SetCellValue(result[i].BMEquipmentNo); rowtemp.CreateCell(2).SetCellValue(result[i].BMFixtureNo); rowtemp.CreateCell(3).SetCellValue(result[i].BMType); rowtemp.CreateCell(4).SetCellValue(result[i].BMSerialNumber); rowtemp.CreateCell(5).SetCellValue(Convert.ToInt32(result[i].BMQuantity)); rowtemp.CreateCell(6).SetCellValue(result[i].BMManufacturedDate); rowtemp.CreateCell(7).SetCellValue(result[i].BMPower); rowtemp.CreateCell(8).SetCellValue(result[i].BMOutlineDimension); rowtemp.CreateCell(9).SetCellValue(result[i].BMAbility); rowtemp.CreateCell(10).SetCellValue(Convert.ToDouble(result[i].BMNeedPressureAir)); rowtemp.CreateCell(11).SetCellValue(Convert.ToDouble(result[i].BMNeedCoolingWater)); rowtemp.CreateCell(12).SetCellValue(result[i].BMIncomingDate); rowtemp.CreateCell(12).SetCellValue(result[i].BMRemarks); } // 写入到客户端 System.IO.MemoryStream ms = new System.IO.MemoryStream(); book.Write(ms); ms.Seek(0, SeekOrigin.Begin); var exportFileName = string.Format("{0}{1}.xls", "MaterialToolInfo", DateTime.Now.ToString("yyyyMMddHHmmss")); return(File(ms, "application/vnd.ms-excel", exportFileName)); }
public ActionResult MaterialOtherSearchResult(MaterialOtherSearchModel model) { var totalCount = 0; var result = MaterialBusiness.MaterialOtherSearch(model, out totalCount); var page = new Page(totalCount, model.CurrentPage); var resultModel = new MaterialOtherSearchResultModel { Models = result, Page = page }; return(View(resultModel)); }
/// <summary> /// 查询设备和工具 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult MachineToolSearch(MaToolSearchModel model) { var totalCount = 0; var result = MaterialBusiness.SearchMaToolPageList(model, out totalCount); var page = new Page(totalCount, model.CurrentPage); var resultModel = new MaToolSearchResultModel { Models = result, Page = page }; return(View("MachineSearch", resultModel)); }
protected void btnSave_Click(object sender, EventArgs e) { if (fuldMaterial.HasFile) { string path = Server.MapPath("~//Material//"); fuldMaterial.SaveAs(path + fuldMaterial.FileName); tbl_Material M = new tbl_Material(); M.WorkShopId = int.Parse(ddlWorkshop.SelectedValue); M.MaterialPath = "~//Material//" + fuldMaterial.FileName; MaterialBusiness MB = new MaterialBusiness(); MB.CreateMaterial(M); GetMaterials(); } }
private void BindBusinessCode() { ucLabelComboxBusinessCode.ComboBoxData.Items.Clear(); object[] objs = this.WHFacade.QueryMaterialBusiness(BussinessType.type_out); if (objs != null) { foreach (object obj in objs) { MaterialBusiness materialBusiness = (MaterialBusiness)obj; if (materialBusiness != null) { ucLabelComboxBusinessCode.AddItem(materialBusiness.BusinessDesc, materialBusiness.BusinessCode); } } } }
protected void btnSave_Click(object sender, EventArgs e) { if (fuldMaterial.HasFile) { string path = Server.MapPath("~//Material//"); fuldMaterial.SaveAs(path + fuldMaterial.FileName); tbl_Material M = new tbl_Material(); M.WorkShopId = int.Parse(ddlWorkShop.SelectedValue); M.MaterialPath = "~//Material//" + fuldMaterial.FileName; M.MaterialDescription = txtDescription.Text; MaterialBusiness MB = new MaterialBusiness(); MB.CreateMaterial(M); lblMessage.Text = "Uploaded Successfully"; // ClearData(); GetMaterials(); } }
protected override string[] FormatExportRecord(object obj) { MaterialBusiness materialBusiness = (MaterialBusiness)obj; object org = new BaseModelFacade(base.DataProvider).GetOrg(materialBusiness.OrgID); string orgDesc = string.Empty; if (org != null) { orgDesc = ((Organization)org).OrganizationDescription; } return(new string[] { materialBusiness.BusinessCode, materialBusiness.BusinessDesc, languageComponent1.GetString(materialBusiness.BusinessType), orgDesc, materialBusiness.SAPCODE, materialBusiness.ISFIFO }); }
/// <summary> /// 查询物料 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult Search(MaterialSearchModel model) { //return IEnumerable<MaterialInfoModel> var totalCount = 0; var result = MaterialBusiness.SearchMaterialPageList(model, out totalCount); var page = new Page(totalCount, model.CurrentPage); //var resultModel = new MaterialSearchResultModel //{ // Models = result.Skip((page.CurrentPage - 1) * page.PageSize).Take(page.PageSize), // Page = page //}; var resultModel = new MaterialSearchResultModel { Models = result, Page = page }; return(View(resultModel)); }
protected override Infragistics.WebUI.UltraWebGrid.UltraGridRow GetGridRow(object obj) { MaterialBusiness materialBusiness = (MaterialBusiness)obj; object org = new BaseModelFacade(base.DataProvider).GetOrg(materialBusiness.OrgID); string orgDesc = string.Empty; if (org != null) { orgDesc = ((Organization)org).OrganizationDescription; } return(new Infragistics.WebUI.UltraWebGrid.UltraGridRow( new object[] { "false", materialBusiness.BusinessCode, materialBusiness.BusinessDesc, languageComponent1.GetString(materialBusiness.BusinessType), orgDesc, materialBusiness.SAPCODE, materialBusiness.ISFIFO })); }
public ActionResult MaterialOperate(MaterialInfoModel model) { var result = MaterialBusiness.SaveMaterial(model, this.LoginUser); return(Json(result)); }
private void bntStockIn_Click(object sender, EventArgs e) { try { DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); string itemDesc = string.Empty; string vendorDesc = string.Empty; bool result = ValidateInput(out itemDesc, out vendorDesc); if (result == false) { return; } string businesscode = FormatString(ucLabelComboxBusinessCode.SelectedItemValue); int qty = int.Parse(ucLabelEditQty.Value); //入库库别 string fromSAPStorageID = string.Empty; string toSAPStorageID = string.Empty; int orgId = 0; object storageStockIn = this.InvFacade.GetStorageByStorageCode(FormatString(ucLabelComboxStorageIn.SelectedItemValue)); if (storageStockIn != null) { orgId = ((Storage)storageStockIn).OrgID; toSAPStorageID = ((Storage)storageStockIn).SAPStorage; } object storageStockOut = this.InvFacade.GetStorageByStorageCode(FormatString(ucLabelComboxStorageOut.SelectedItemValue)); if (storageStockOut != null) { fromSAPStorageID = ((Storage)storageStockOut).SAPStorage; } //获取当前业务代码信息 MaterialBusiness materialBusiness = (MaterialBusiness)this.WHFacade.GetMaterialBusiness(businesscode); string iqcno = FormatString(this.ucLabelEditDoc.Value).ToUpper(); if (iqcno == "") { iqcno = " "; } //Config MaterialLot MaterialLot materialLot = this.InvFacade.CreateNewMaterialLot(); materialLot.IQCNo = iqcno; materialLot.STLine = FormatInt(this.ucLabelEditDocLine.Value); materialLot.ItemCode = FormatString(this.ucLEItemCode.Value); materialLot.VendorCode = FormatString(this.ucLabelEditVendor.Value); materialLot.OrganizationID = orgId; materialLot.StorageID = FormatString(ucLabelComboxStorageIn.SelectedItemValue); materialLot.Unit = FormatString(this.ucLabelEditUnit.Value); materialLot.CreateDate = FormatHelper.TODateInt(ucDateStockIn.Value); materialLot.LotInQty = qty; materialLot.LotQty = qty; materialLot.FIFOFlag = materialBusiness.ISFIFO; materialLot.MaintainUser = ApplicationService.Current().UserCode; materialLot.MaintainDate = dbDateTime.DBDate; materialLot.MaintainTime = dbDateTime.DBTime; //Set MaterialLotNo string dateCode = this.InvFacade.GetMaterialLotDateCode(materialLot.CreateDate); string runningNumber = this.InvFacade.GetNewMaterialLotRunningNumber(materialLot.VendorCode, materialLot.ItemCode, materialLot.CreateDate); materialLot.MaterialLotNo = materialLot.VendorCode + "-" + materialLot.ItemCode + "-" + dateCode + "-" + runningNumber; //Config MaterialTrans MaterialTrans materialTrans = this.InvFacade.CreateNewMaterialTrans(); materialTrans.Serial = 0; materialTrans.FRMaterialLot = " "; materialTrans.FRMITEMCODE = " "; materialTrans.FRMStorageID = " "; materialTrans.TOMaterialLot = materialLot.MaterialLotNo; materialTrans.TOITEMCODE = materialLot.ItemCode; materialTrans.TOStorageID = materialLot.StorageID; materialTrans.TransQTY = materialLot.LotInQty; materialTrans.Memo = FormatString(this.ucLabelEditMemo.Value); materialTrans.UNIT = materialLot.Unit; materialTrans.VendorCode = materialLot.VendorCode; materialTrans.IssueType = IssueType.IssueType_Receive; materialTrans.TRANSACTIONCODE = materialLot.IQCNo; materialTrans.BusinessCode = materialBusiness.BusinessCode; materialTrans.OrganizationID = materialLot.OrganizationID; materialTrans.MaintainUser = ApplicationService.Current().UserCode; materialTrans.MaintainDate = dbDateTime.DBDate; materialTrans.MaintainTime = dbDateTime.DBTime; //Config Sapmaterialtrans //分别获取入库库别和发货库别对应的SAP库别,在TBLsAPMaterialTrans中的StorageId存放的是SAP库别 SAPMaterialTrans sAPMaterialTrans = null; if (materialBusiness.SAPCODE.Trim().Length > 0) { sAPMaterialTrans = this.InvFacade.CreateNewSAPMaterialTrans(); sAPMaterialTrans.MaterialLotNo = materialLot.MaterialLotNo; sAPMaterialTrans.PostSeq = this.InvFacade.GetSAPMaterialTransMaxSeq(materialLot.MaterialLotNo); sAPMaterialTrans.OrganizationID = materialLot.OrganizationID; sAPMaterialTrans.ItemCode = materialLot.ItemCode; sAPMaterialTrans.AccountDate = FormatHelper.TODateInt(ucDateAccount.Value); sAPMaterialTrans.VoucherDate = FormatHelper.TODateInt(ucDateVoucher.Value); if (fromSAPStorageID == "" || fromSAPStorageID == null) { sAPMaterialTrans.FRMStorageID = " "; } else { sAPMaterialTrans.FRMStorageID = fromSAPStorageID; } if (toSAPStorageID == "" || toSAPStorageID == null) { sAPMaterialTrans.TOStorageID = " "; } else { sAPMaterialTrans.TOStorageID = toSAPStorageID; } sAPMaterialTrans.TransQTY = materialLot.LotInQty; sAPMaterialTrans.ReceiveMemo = FormatString(this.ucLabelEditMemo.Value); sAPMaterialTrans.Unit = materialLot.Unit; //当非即售时Vendor为空 if (radioButtonSaleDelay.Checked == true) { sAPMaterialTrans.VendorCode = " "; } else { sAPMaterialTrans.VendorCode = materialLot.VendorCode; } sAPMaterialTrans.MoCode = materialLot.IQCNo; sAPMaterialTrans.Flag = FlagStatus.FlagStatus_MES; sAPMaterialTrans.TransactionCode = " "; sAPMaterialTrans.ToItemCode = materialLot.ItemCode; if (materialBusiness.SAPCODE == null || materialBusiness.SAPCODE == "") { sAPMaterialTrans.SAPCode = " "; } else { sAPMaterialTrans.SAPCode = materialBusiness.SAPCODE; } sAPMaterialTrans.MaintainUser = ApplicationService.Current().UserCode; sAPMaterialTrans.MaintainDate = dbDateTime.DBDate; sAPMaterialTrans.MaintainTime = dbDateTime.DBTime; } bool saveData = this.InvFacade.MaterialStockIn(materialLot, materialBusiness, materialTrans, sAPMaterialTrans); if (saveData) { //向Grid上增加记录 DataRow dr = this._DataTable.NewRow(); dr["Check"] = false; dr["MaterialLot"] = materialLot.MaterialLotNo; dr["IQCNO"] = materialLot.IQCNo; dr["IQCLine"] = materialLot.STLine; dr["VendorCode"] = materialLot.VendorCode; dr["VendorDesc"] = vendorDesc; dr["ItemCode"] = materialLot.ItemCode; dr["ItemCodeDesc"] = itemDesc; dr["ReceiveDate"] = materialLot.CreateDate; dr["StockInQty"] = materialLot.LotInQty; dr["StockInStorage"] = materialLot.StorageID; dr["FifoChcek"] = materialBusiness.ISFIFO; dr["FrmMemo"] = FormatString(this.ucLabelEditMemo.Value).Replace("\n", " "); this._DataTable.Rows.Add(dr); ClearInputData(); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_StockIn_Success")); } } catch (Exception ex) { Messages msg = new Messages(); msg.Add(new UserControl.Message(ex)); ApplicationRun.GetInfoForm().Add(msg); } }
/// <summary> /// 获取物料 /// </summary> /// <param name="materialId"></param> /// <returns></returns> public ActionResult GetOneMaterial(int materialId) { var result = MaterialBusiness.GetMaterialById(materialId); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult AddOrUpdate(MaterialInfoModel model) { var result = MaterialBusiness.SaveNewMaterial(model, this.LoginUser); return(Json(result)); }
public ActionResult WorkOrderSubmmit(WorkOrderInfo model) { var result = MaterialBusiness.SaveWorkOrder(model, this.LoginUser); return(Json(result)); }
public ActionResult GetWorkOrderById(int workOrderId) { var result = MaterialBusiness.GetWorkOrderById(workOrderId); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult ImportMachine(int type) { var result = new ImportUploadResult() { IsSuccess = false }; var invalidlist = new List <InvalidData>(); StringBuilder strbuild = new StringBuilder(); string FileName; string savePath; HttpPostedFileBase file = Request.Files["file"]; if (file == null || file.ContentLength <= 0) { result.Message = "please choose file"; return(Content(JsonHelper.JsonSerializer(result))); } else { string fileName = Path.GetFileName(file.FileName); int filesize = file.ContentLength; //获取上传文件的大小单位为字节byte string fileEx = Path.GetExtension(fileName); //获取上传文件的扩展名 string NoFileName = Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名 int Maxsize = 4000 * 1024; //定义上传文件的最大空间大小为4M string FileType = ".xls,.xlsx"; //定义上传文件的类型字符串 FileName = NoFileName + fileEx; if (!FileType.Contains(fileEx)) { result.Message = "please upload .xls and .xlsx"; return(Content(JsonHelper.JsonSerializer(result))); } if (filesize >= Maxsize) { result.Message = string.Format("file size can't big than {0}", Maxsize); return(Content(JsonHelper.JsonSerializer(result))); } string path = Server.MapPath("~/App_Data/uploads"); savePath = Path.Combine(path, FileName); file.SaveAs(savePath); } string strConn; strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;"; using (OleDbConnection conn = new OleDbConnection(strConn)) { conn.Open(); OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn); DataSet myDataSet = new DataSet(); try { myCommand.Fill(myDataSet, "ExcelInfo"); } catch (Exception ex) { result.Message = ex.Message; return(Content(JsonHelper.JsonSerializer(result))); } DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable(); try { for (int i = 0; i < table.Rows.Count; i++) { var datevalid1 = false; var datevalid2 = false; var invalid = new InvalidData(); if (!string.IsNullOrEmpty(table.Rows[i][6].ToString())) { datevalid1 = DataConvertHelper.IsDateTime(table.Rows[i][6].ToString()); if (!datevalid1) { invalid.Key = table.Rows[i][2].ToString(); invalid.Value1 = table.Rows[i][6].ToString(); } } if (!string.IsNullOrEmpty(table.Rows[i][12].ToString())) { datevalid2 = DataConvertHelper.IsDateTime(table.Rows[i][12].ToString()); if (!datevalid2) { invalid.Key = table.Rows[i][2].ToString(); invalid.Value2 = table.Rows[i][12].ToString(); } } if (!datevalid1 && !datevalid2) { invalidlist.Add(invalid); continue; } var model = new MaToolModel(); model.BMClassification = type; model.BMEquipmentName = table.Rows[i][0].ToString(); model.BMEquipmentNo = table.Rows[i][1].ToString(); model.BMFixtureNo = table.Rows[i][2].ToString(); model.BMType = table.Rows[i][3].ToString(); model.BMSerialNumber = table.Rows[i][4].ToString(); model.BMQuantity = DataConvertHelper.ToInt(table.Rows[i][5].ToString(), 0); model.BMManufacturedDate = table.Rows[i][6].ToString(); model.BMPower = table.Rows[i][7].ToString(); model.BMOutlineDimension = table.Rows[i][8].ToString(); model.BMAbility = table.Rows[i][9].ToString(); model.BMNeedPressureAir = DataConvertHelper.GetYesOrNoValue(table.Rows[i][10].ToString()); model.BMNeedCoolingWater = DataConvertHelper.GetYesOrNoValue(table.Rows[i][11].ToString()); model.BMIncomingDate = table.Rows[i][12].ToString(); model.BMRemarks = table.Rows[i][13].ToString(); var inserResult = MaterialBusiness.SaveMaTool(model, LoginUser); //if (type != 4) //{ // MachineTool(type, table, i); //} //else { // MaterialTool(type, table, i); //} } result.invalidData = invalidlist; result.IsSuccess = true; } catch (Exception ex) { result.Message = ex.Message; return(Content(JsonHelper.JsonSerializer(result))); } conn.Close(); } return(Content(JsonHelper.JsonSerializer(result))); }
/// <summary> /// 导入 /// 创建人:wq /// </summary> /// <param name="type"></param> /// <returns></returns> public ActionResult ImportMaterialTool(int type) { var result = new ImportUploadResult() { IsSuccess = false }; var invalidlist = new List <InvalidData>(); StringBuilder strbuild = new StringBuilder(); string FileName; string savePath; HttpPostedFileBase file = Request.Files["file"]; if (file == null || file.ContentLength <= 0) { result.Message = "please choose file"; return(Content(JsonHelper.JsonSerializer(result))); } else { string fileName = Path.GetFileName(file.FileName); int filesize = file.ContentLength; //获取上传文件的大小单位为字节byte string fileEx = Path.GetExtension(fileName); //获取上传文件的扩展名 string NoFileName = Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名 int Maxsize = 4000 * 1024; //定义上传文件的最大空间大小为4M string FileType = ".xls,.xlsx"; //定义上传文件的类型字符串 FileName = NoFileName + fileEx; if (!FileType.Contains(fileEx)) { result.Message = "please upload .xls and .xlsx"; return(Content(JsonHelper.JsonSerializer(result))); } if (filesize >= Maxsize) { result.Message = string.Format("file size can't big than {0}", Maxsize); return(Content(JsonHelper.JsonSerializer(result))); } string path = Server.MapPath("~/App_Data/uploads"); savePath = Path.Combine(path, FileName); file.SaveAs(savePath); } string strConn; strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;"; using (OleDbConnection conn = new OleDbConnection(strConn)) { conn.Open(); OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn); DataSet myDataSet = new DataSet(); try { myCommand.Fill(myDataSet, "ExcelInfo"); } catch (Exception ex) { result.Message = ex.Message; return(Content(JsonHelper.JsonSerializer(result))); } DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable(); try { for (int i = 0; i < table.Rows.Count; i++) { var model = new MaterialToolModel(); model.MTSapPN = table.Rows[i][0].ToString(); model.MTSapQuantity = table.Rows[i][1].ToString(); model.MTSapLibrary = table.Rows[i][2].ToString(); model.MTToolNo = table.Rows[i][3].ToString(); model.MTProductName = table.Rows[i][4].ToString(); model.MTStatus = table.Rows[i][5].ToString(); model.MTToolLibrary = table.Rows[i][6].ToString(); model.MTOutlineDimension = table.Rows[i][7].ToString(); model.MTQuality = table.Rows[i][8].ToString(); model.MTCustomerPN = table.Rows[i][9].ToString(); model.MTSapProductName = table.Rows[i][10].ToString(); model.MTBelong = table.Rows[i][11].ToString(); model.MTCustomerNo = table.Rows[i][12].ToString(); model.MTToolSupplier = table.Rows[i][13].ToString(); model.MTToolSupplierNo = table.Rows[i][14].ToString(); model.MTProductDate = table.Rows[i][15].ToString(); model.MTCavity = table.Rows[i][16].ToString(); var inserResult = MaterialBusiness.SaveMaterialTool(model, LoginUser); } result.invalidData = invalidlist; result.IsSuccess = true; } catch (Exception ex) { result.Message = ex.Message; return(Content(JsonHelper.JsonSerializer(result))); } conn.Close(); } return(Content(JsonHelper.JsonSerializer(result))); }
public ActionResult DeleteWorkOrder(int Id) { var result = MaterialBusiness.DeleteWorkOrder(Id, this.LoginUser); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult ImportWorkOrder(int type) { var result = new ResultInfoModel() { IsSuccess = false }; StringBuilder strbuild = new StringBuilder(); string FileName; string savePath; HttpPostedFileBase file = Request.Files["file"]; if (file == null || file.ContentLength <= 0) { result.Message = "please choose file"; return(Content(JsonHelper.JsonSerializer(result))); } else { string fileName = Path.GetFileName(file.FileName); int filesize = file.ContentLength; //获取上传文件的大小单位为字节byte string fileEx = Path.GetExtension(fileName); //获取上传文件的扩展名 string NoFileName = Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名 int Maxsize = 4000 * 1024; //定义上传文件的最大空间大小为4M string FileType = ".xls,.xlsx"; //定义上传文件的类型字符串 FileName = NoFileName + fileEx; if (!FileType.Contains(fileEx)) { result.Message = "please upload .xls and .xlsx"; return(Content(JsonHelper.JsonSerializer(result))); } if (filesize >= Maxsize) { result.Message = string.Format("file size can't big than {0}", Maxsize); return(Content(JsonHelper.JsonSerializer(result))); } string path = Server.MapPath("~/App_Data/uploads"); savePath = Path.Combine(path, FileName); file.SaveAs(savePath); string strConn; strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;"; using (OleDbConnection conn = new OleDbConnection(strConn)) { conn.Open(); OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn); DataSet myDataSet = new DataSet(); try { myCommand.Fill(myDataSet, "ExcelInfo"); } catch (Exception ex) { result.Message = ex.Message; return(Content(JsonHelper.JsonSerializer(result))); } DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable(); try { for (int i = 0; i < table.Rows.Count; i++) { WorkOrderInfo model = new WorkOrderInfo(); model.WIWorkOrder = table.Rows[i][0].ToString(); model.WISapPN = table.Rows[i][1].ToString(); model.WIProductName = table.Rows[i][2].ToString(); model.WIReceiptTime = table.Rows[i][3].ToString(); model.WIReceiptBy = table.Rows[i][4].ToString(); model.WICloseDateShift = table.Rows[i][5].ToString(); model.WIOrderArchived = table.Rows[i][6].ToString(); model.WIParameterRecord = table.Rows[i][7].ToString(); model.WIToolMaintenanceRecord = table.Rows[i][8].ToString(); model.WIToolMachineCheck = table.Rows[i][9].ToString(); model.WIQuantityConfirm = table.Rows[i][10].ToString(); model.WIArchivedBy = table.Rows[i][11].ToString(); model.WIWeeklyCheck = table.Rows[i][12].ToString(); model.WIRemarks = table.Rows[i][7].ToString(); model.WIGetBy = table.Rows[i][8].ToString(); model.WIGetTime = table.Rows[i][9].ToString(); model.WIType = type; MaterialBusiness.SaveWorkOrder(model, this.LoginUser); } result.IsSuccess = true; } catch (Exception ex) { result.Message = ex.Message; return(Content(JsonHelper.JsonSerializer(result))); } conn.Close(); } return(Content(JsonHelper.JsonSerializer(result))); } }
private void btnSendMetrial_Click(object sender, EventArgs e) { //UI Check ultraGridMetrialDetial.Rows.Band.SortedColumns.Add("ReceiveDate", false); if (!ValidateInput()) { return; } string stockInStorage = FormatString(ucLabelComboxStorageIn.SelectedItemValue); string uiToItem = FormatString(ucLabelEditToItem.Value).Trim().ToUpper(); string moCode = FormatString(this.ucLabelEditIssueNo.Value); if (moCode == "") { moCode = " "; } //获取业务类型 string businesscode = FormatString(ucLabelComboxBusinessCode.SelectedItemValue); MaterialBusiness materialBusiness = (MaterialBusiness)this.WHFacade.GetMaterialBusiness(businesscode); //判断入库库别是否被管理 //tblsysparam.PARAMCODE维护的是需要管理的库别对应tblstorage.STORAGECODE //对应的tblsysparamgroup.PARAMGROUPCODE="DESTSTORAGEMANAGE" SystemSettingFacade systemFacade = new SystemSettingFacade(this.DataProvider); object para = systemFacade.GetParameter(stockInStorage, "DESTSTORAGEMANAGE"); bool isManageToStorage = false; if (para != null) { isManageToStorage = true; } List <string> lotNoList = new List <string>(); DBDateTime dBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); bool saveData = true; try { this.DataProvider.BeginTransaction(); for (int i = 0; i < ultraGridMetrialDetial.Rows.Count; i++) { int lotSendNumber = ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim() == string.Empty ? 0 : Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim()); if (ultraGridMetrialDetial.Rows[i].Cells["Check"].Value.ToString().ToLower() == "true" && lotSendNumber > 0) { MaterialLot materialLot = (MaterialLot)this.InvFacade.GetMaterialLot(ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString().Trim().ToUpper()); //只有当目标库房没有被管理时,才需要做FIFO检查,就如同工单发料的库房没有被管理,在发料的时候是需要FIFO检查的 if (materialLot != null && materialLot.FIFOFlag == "Y" && isManageToStorage == false) { if (!CheckFiFo(lotNoList, ultraGridMetrialDetial.Rows[i].Cells["ItemCode"].Value.ToString(), ultraGridMetrialDetial.Rows[i].Cells["VendorCode"].Value.ToString(), Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["ReceiveDate"].Value), materialLot.StorageID.Trim().ToUpper())) { this.DataProvider.RollbackTransaction(); saveData = false; break; } } if (materialLot != null) { int orgIdStockOut = 0; int orgIdStockIn = 0; string fromSAPStorageID = " "; string toSAPStorageID = " "; string materialLotNoStockIn = " "; object storageStockIn = this.InvFacade.GetStorageByStorageCode(FormatString(ucLabelComboxStorageIn.SelectedItemValue)); if (storageStockIn != null) { orgIdStockIn = ((Storage)storageStockIn).OrgID; toSAPStorageID = ((Storage)storageStockIn).SAPStorage; } object storageStockOut = this.InvFacade.GetStorageByStorageCode(materialLot.StorageID); if (storageStockOut != null) { orgIdStockOut = ((Storage)storageStockOut).OrgID; fromSAPStorageID = ((Storage)storageStockOut).SAPStorage; } string toItemCode = uiToItem.Trim().Length == 0 ? materialLot.ItemCode : uiToItem.Trim().ToUpper(); //判断是否超发 int sendQty = Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value); if ((materialLot.LotQty - sendQty) < 0) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SendMaterialLot_Not_Enough")); this.DataProvider.RollbackTransaction(); saveData = false; break; } if (isManageToStorage == true) { //当目标库管理时 if (materialLot.LotQty == sendQty && materialLot.ItemCode == toItemCode) { materialLotNoStockIn = materialLot.MaterialLotNo; //当发料数量等于库存数量,直接修改TBLMaterialLot中的库别和ToItemCode MaterialLot materialLotStockIn = this.InvFacade.CreateNewMaterialLot(); materialLotStockIn.MaterialLotNo = materialLot.MaterialLotNo; materialLotStockIn.IQCNo = materialLot.IQCNo; materialLotStockIn.STLine = materialLot.STLine; materialLotStockIn.ItemCode = materialLot.ItemCode; materialLotStockIn.VendorCode = materialLot.VendorCode; materialLotStockIn.OrganizationID = orgIdStockIn; materialLotStockIn.StorageID = stockInStorage; materialLotStockIn.Unit = materialLot.Unit; //Modified By Nettie Chen 2009/09/24 //materialLotStockIn.CreateDate = dBDateTime.DBDate; materialLotStockIn.CreateDate = materialLot.CreateDate; //End Modified materialLotStockIn.LotInQty = materialLot.LotInQty; materialLotStockIn.LotQty = materialLot.LotQty; materialLotStockIn.FIFOFlag = materialLot.FIFOFlag; materialLotStockIn.MaintainUser = ApplicationService.Current().UserCode; materialLotStockIn.MaintainDate = dBDateTime.DBDate; materialLotStockIn.MaintainTime = dBDateTime.DBTime; this.InvFacade.UpdateMaterialLot(materialLotStockIn); } else { //当发料数量不等于库存数量,或Item有变化时,产生新的Lot string dateCode = this.InvFacade.GetMaterialLotDateCode(materialLot.CreateDate); string runningNumber = this.InvFacade.GetNewMaterialLotRunningNumber(materialLot.VendorCode, toItemCode, materialLot.CreateDate); materialLotNoStockIn = materialLot.VendorCode + "-" + toItemCode + "-" + dateCode + "-" + runningNumber; //修改出库的TBLMaterialLot materialLot.LotQty = materialLot.LotQty - sendQty; materialLot.MaintainDate = dBDateTime.DBDate; materialLot.MaintainTime = dBDateTime.DBTime; this.InvFacade.UpdateMaterialLot(materialLot); //新增入库的TBLMaterialLot MaterialLot materialLotStockIn = this.InvFacade.CreateNewMaterialLot(); materialLotStockIn.MaterialLotNo = materialLotNoStockIn; materialLotStockIn.IQCNo = materialLot.IQCNo; materialLotStockIn.STLine = materialLot.STLine; materialLotStockIn.ItemCode = toItemCode; materialLotStockIn.VendorCode = materialLot.VendorCode; materialLotStockIn.OrganizationID = orgIdStockIn; materialLotStockIn.StorageID = stockInStorage; materialLotStockIn.Unit = materialLot.Unit; materialLotStockIn.CreateDate = materialLot.CreateDate; materialLotStockIn.LotInQty = sendQty; materialLotStockIn.LotQty = sendQty; materialLotStockIn.FIFOFlag = materialLot.FIFOFlag; materialLotStockIn.MaintainUser = ApplicationService.Current().UserCode; materialLotStockIn.MaintainDate = dBDateTime.DBDate; materialLotStockIn.MaintainTime = dBDateTime.DBTime; this.InvFacade.AddMaterialLot(materialLotStockIn); } //入库的TBLMaterialTrans MaterialTrans materialTransStockIn = this.InvFacade.CreateNewMaterialTrans(); materialTransStockIn.Serial = 0; materialTransStockIn.FRMaterialLot = materialLot.MaterialLotNo; materialTransStockIn.FRMITEMCODE = materialLot.ItemCode; materialTransStockIn.FRMStorageID = materialLot.StorageID; materialTransStockIn.TOMaterialLot = materialLotNoStockIn; materialTransStockIn.TOITEMCODE = toItemCode; materialTransStockIn.TOStorageID = stockInStorage; materialTransStockIn.TransQTY = sendQty; materialTransStockIn.Memo = FormatString(this.ucLabelEditMemo.Value); materialTransStockIn.UNIT = materialLot.Unit; materialTransStockIn.VendorCode = materialLot.VendorCode; materialTransStockIn.IssueType = IssueType.IssueType_Receive; materialTransStockIn.TRANSACTIONCODE = moCode; materialTransStockIn.BusinessCode = materialBusiness.BusinessCode; materialTransStockIn.OrganizationID = orgIdStockIn; materialTransStockIn.MaintainUser = ApplicationService.Current().UserCode; materialTransStockIn.MaintainDate = dBDateTime.DBDate; materialTransStockIn.MaintainTime = dBDateTime.DBTime; this.InvFacade.AddMaterialTrans(materialTransStockIn); } else { //当目标库没有管理时,只更新出库的TBLMaterialLot.lotqty materialLotNoStockIn = materialLot.MaterialLotNo; materialLot.LotQty = materialLot.LotQty - sendQty; materialLot.MaintainUser = ApplicationService.Current().UserCode; materialLot.MaintainDate = dBDateTime.DBDate; materialLot.MaintainTime = dBDateTime.DBTime; this.InvFacade.UpdateMaterialLot(materialLot); } //出库的TBLMaterialTrans MaterialTrans materialTransStockOut = this.InvFacade.CreateNewMaterialTrans(); materialTransStockOut.Serial = 0; materialTransStockOut.FRMaterialLot = materialLot.MaterialLotNo; materialTransStockOut.FRMITEMCODE = materialLot.ItemCode; materialTransStockOut.FRMStorageID = materialLot.StorageID; materialTransStockOut.TOMaterialLot = materialLotNoStockIn; materialTransStockOut.TOITEMCODE = toItemCode; materialTransStockOut.TOStorageID = stockInStorage; materialTransStockOut.TransQTY = sendQty; materialTransStockOut.Memo = FormatString(this.ucLabelEditMemo.Value); materialTransStockOut.UNIT = materialLot.Unit; materialTransStockOut.VendorCode = materialLot.VendorCode; materialTransStockOut.IssueType = IssueType.IssueType_Issue; materialTransStockOut.TRANSACTIONCODE = moCode; materialTransStockOut.BusinessCode = materialBusiness.BusinessCode; materialTransStockOut.OrganizationID = orgIdStockOut; materialTransStockOut.MaintainUser = ApplicationService.Current().UserCode; materialTransStockOut.MaintainDate = dBDateTime.DBDate; materialTransStockOut.MaintainTime = dBDateTime.DBTime; this.InvFacade.AddMaterialTrans(materialTransStockOut); if (materialBusiness.SAPCODE.Trim().Length > 0) { SAPMaterialTrans sAPMaterialTrans = this.InvFacade.CreateNewSAPMaterialTrans(); sAPMaterialTrans.MaterialLotNo = materialLot.MaterialLotNo; sAPMaterialTrans.PostSeq = this.InvFacade.GetSAPMaterialTransMaxSeq(materialLot.MaterialLotNo); sAPMaterialTrans.OrganizationID = orgIdStockOut; sAPMaterialTrans.ItemCode = materialLot.ItemCode; sAPMaterialTrans.AccountDate = FormatHelper.TODateInt(ucDateAccount.Value); sAPMaterialTrans.VoucherDate = FormatHelper.TODateInt(ucDateVoucher.Value); sAPMaterialTrans.FRMStorageID = fromSAPStorageID; sAPMaterialTrans.TOStorageID = toSAPStorageID; sAPMaterialTrans.TransQTY = sendQty; sAPMaterialTrans.ReceiveMemo = FormatString(this.ucLabelEditMemo.Value); sAPMaterialTrans.Unit = materialLot.Unit; //当非即售时Vendor为空 if (radioButtonSaleDelay.Checked == true) { sAPMaterialTrans.VendorCode = " "; } else { sAPMaterialTrans.VendorCode = materialLot.VendorCode; } sAPMaterialTrans.MoCode = moCode; sAPMaterialTrans.Flag = FlagStatus.FlagStatus_MES; sAPMaterialTrans.TransactionCode = " "; sAPMaterialTrans.ToItemCode = toItemCode; sAPMaterialTrans.SAPCode = materialBusiness.SAPCODE; sAPMaterialTrans.MaintainUser = ApplicationService.Current().UserCode; sAPMaterialTrans.MaintainDate = dBDateTime.DBDate; sAPMaterialTrans.MaintainTime = dBDateTime.DBTime; this.InvFacade.AddSAPMaterialTrans(sAPMaterialTrans); } } lotNoList.Add(ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString()); } } if (saveData) { this.DataProvider.CommitTransaction(); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_SendMaterialLot_Success")); } } catch (Exception ex) { this.DataProvider.RollbackTransaction(); Messages msg = new Messages(); msg.Add(new UserControl.Message(ex)); ApplicationRun.GetInfoForm().Add(msg); } if (saveData) { //_DataTableLoadedPart.Clear(); //ucBtnQuery_Click ucBtnQuery_Click(this, null); } }
/// <summary> /// Test /// </summary> /// <param name="file"></param> /// <returns></returns> public ActionResult UploadMaterialFiles() { var result = new ResultInfoModel() { IsSuccess = false }; StringBuilder strbuild = new StringBuilder(); string FileName; string savePath; HttpPostedFileBase file = Request.Files["file"]; if (file == null || file.ContentLength <= 0) { result.Message = "please choose file"; return(Content(JsonHelper.JsonSerializer(result))); } else { string fileName = Path.GetFileName(file.FileName); int filesize = file.ContentLength; //获取上传文件的大小单位为字节byte string fileEx = Path.GetExtension(fileName); //获取上传文件的扩展名 string NoFileName = Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名 int Maxsize = 4000 * 1024; //定义上传文件的最大空间大小为4M string FileType = ".xls,.xlsx"; //定义上传文件的类型字符串 FileName = NoFileName + fileEx; if (!FileType.Contains(fileEx)) { result.Message = "please upload .xls and .xlsx"; return(Content(JsonHelper.JsonSerializer(result))); } if (filesize >= Maxsize) { result.Message = string.Format("file size can't big than {0}", Maxsize); return(Content(JsonHelper.JsonSerializer(result))); } string path = Server.MapPath("~/App_Data/uploads"); savePath = Path.Combine(path, FileName); file.SaveAs(savePath); string strConn; strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;"; using (OleDbConnection conn = new OleDbConnection(strConn)) { conn.Open(); OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn); DataSet myDataSet = new DataSet(); try { myCommand.Fill(myDataSet, "ExcelInfo"); } catch (Exception ex) { result.Message = ex.Message; return(Content(JsonHelper.JsonSerializer(result))); } DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable(); try { for (int i = 0; i < table.Rows.Count; i++) { MaterialInfoModel model = new MaterialInfoModel(); model.MIProcessType = table.Rows[i][0].ToString(); model.MICustomer = table.Rows[i][1].ToString(); model.MISapPN = table.Rows[i][2].ToString(); model.MIProductName = table.Rows[i][3].ToString(); model.MIInjectionMC = table.Rows[i][4].ToString(); model.MICustomerPN = table.Rows[i][5].ToString(); model.MICavity = DataConvertHelper.ToInt(table.Rows[i][6].ToString(), 0); model.MICycletime = DataConvertHelper.ToDecimal(table.Rows[i][7].ToString(), 0); model.MICycletimeCav = DataConvertHelper.ToDecimal(table.Rows[i][8].ToString(), 0); model.MIStandardHeadcount = DataConvertHelper.ToInt(table.Rows[i][9].ToString(), 0); model.MTStandardScrap = table.Rows[i][10].ToString(); model.MIMaterialPN = table.Rows[i][11].ToString(); model.MICavityG = DataConvertHelper.ToDecimal(table.Rows[i][12].ToString(), 0); model.MIMoldNo = table.Rows[i][13].ToString(); model.MIAssAC = table.Rows[i][14].ToString(); model.MIWorkOrder = table.Rows[i][15].ToString(); MaterialBusiness.SaveMaterial(model, this.LoginUser); var insertResult = MaterialBusiness.SaveMaterial(model, LoginUser); } result.IsSuccess = true; } catch (Exception ex) { result.Message = ex.Message; return(Content(JsonHelper.JsonSerializer(result))); } conn.Close(); } return(Content(JsonHelper.JsonSerializer(result))); } }