public void UpdateForwarder(ForwarderInfo item) { try { IPalletRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository>(); DataTable exists = itemRepository.GetExistForwarder(item); if (exists != null && exists.Rows.Count > 0) { if (exists.Rows[0][0].ToString() != item.Id.ToString()) { //!!!need change //已经存在具有相同Date、Forwarder、MAWB、Driver和Truck ID的Forwarder记录 List<string> erpara = new List<string>(); FisException ex; ex = new FisException("DMT055", erpara); throw ex; } } itemRepository.UpdateForwarder(item); } catch (Exception) { throw; } }
public void DeleteForwarder(ForwarderInfo item) { try { IPalletRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository>(); ForwarderInfo itemForwarder = new ForwarderInfo(); itemForwarder.Id = item.Id; itemRepository.DeleteForwarder(itemForwarder); } catch (Exception) { throw; } }
/// <summary> /// 根据输入的TruckID,获取Forwarder对象,并放到Session中 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); var palletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>(); IList<ForwarderInfo> lstFwder = palletRepository.GetForwarderInfoByTruckID(Key); ForwarderInfo fwderInfo = new ForwarderInfo(); if (lstFwder == null || lstFwder.Count == 0) { List<string> errpara = new List<string>(); errpara.Add(this.Key); throw new FisException("CHK147", errpara); } //fwderInfo = lstFwder[0]; string dateStr = (string)CurrentSession.GetValue(Session.SessionKeys.DateCode); try { lstFwder = (from fr in lstFwder where fr.Date == dateStr select fr).ToList(); if (lstFwder.Count == 0) throw new NullReferenceException(); //fwderInfo = lstFwder.First(fi => fi.Date == dateStr); //fwderInfo = lstFwder[0]; } catch (Exception) { List<string> errpara = new List<string>(); errpara.Add(this.Key); throw new FisException("CHK147", errpara); } IList<MAWBInfo> lstMawb = null; foreach (ForwarderInfo fi in lstFwder) { fwderInfo = fi; if (string.IsNullOrEmpty(fwderInfo.MAWB)) { throw new FisException("CHK148", new string[] { } ); } lstMawb = palletRepository.GetMAWBInfoByMAWBorHAWB(fwderInfo.MAWB); if (lstMawb == null || lstMawb.Count == 0) { throw new FisException("CHK148", new string[] { } ); } } if (!palletRepository.PickCardCheck(Key, dateStr)) { List<string> errpara = new List<string>(); errpara.Add(this.Key); throw new FisException("CHK189", errpara); } string isAutoBOL = "N"; //是自動單? if (lstMawb != null && lstMawb.Count > 0) { MAWBInfo mawbInfo = lstMawb[0]; IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); DeliveryInfo cond = new DeliveryInfo(); cond.DeliveryNo = mawbInfo.Delivery; cond.InfoType = "Flag"; IList<DeliveryInfo> lstD = DeliveryRepository.GetDeliveryInfoList(cond); if (lstD != null && lstD.Count > 0) { foreach (DeliveryInfo di in lstD) { if ("N".Equals(di.InfoValue)) { isAutoBOL = "Y"; break; } } } } CurrentSession.AddValue("IsAutoBOL", isAutoBOL); CurrentSession.AddValue(Session.SessionKeys.Forwarder, fwderInfo); CurrentSession.AddValue(Session.SessionKeys.Forwarder+"List", lstFwder); return base.DoExecute(executionContext); }
protected void btnOK_ServerClick(Object sender, EventArgs e) { //Microsoft.Office.Interop.Excel.Application mApp = null; //Microsoft.Office.Interop.Excel.Workbook m_book = null; //Microsoft.Office.Interop.Excel.Worksheet worksheet = null; string fullFileName = ""; //System.Diagnostics.Process process = null; try { DataTable dt = new DataTable(); if (dFileUpload.FileName.Trim() == "") { pmtMessage4 = this.GetLocalResourceObject(Pre + "_pmtMessage4").ToString(); showErrorMessage(pmtMessage4); //showErrorMessage("需要选择上传的文件."); return; } if (dFileUpload.HasFile) { string fileName = dFileUpload.FileName; string filePath = HttpContext.Current.Server.MapPath("~"); string path = filePath + "\\tmp"; //根下tmp目录存上传临时文件 MakeDirIfNotExist(path); try { //////////////////// string extName = fileName.Substring(fileName.LastIndexOf(".")); //if (extName != ".xls" && extName != ".xlsx" && extName != ".xl" && extName != ".xla" && extName != ".xlt" && extName != ".xlm" && extName != ".xlc" && extName != ".xlw" // && extName != ".xlsm" && extName != ".xltx" && extName != ".xltm" && extName != ".xlsb" && extName != ".xlam") //{ // pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString(); // showErrorMessage(pmtMessage2); // //showErrorMessage("上传的文件格式不正确."); // return; //} if (extName != ".xls") //if (extName != ".xls" && extName != ".xlsx" && extName != ".xlsm") { pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString(); showErrorMessage(pmtMessage2); //showErrorMessage("上传的文件格式不正确."); return; } Guid guid = System.Guid.NewGuid(); fullFileName = path + "\\" + guid.ToString() + extName; dFileUpload.PostedFile.SaveAs(fullFileName); FileStream file = null; file = new FileStream(fullFileName, FileMode.Open); //dt = ExcelManager.getExcelSheetData(dFileUpload.PostedFile.FileName); dt = ExcelManager.ExportDataTableFromExcel2(file, 1, 0, fullFileName); //dt = ExcelManager.RenderDataTableFromExcel(file, 1, 0); //Guid guid = System.Guid.NewGuid(); //fullFileName = path + "\\" + guid.ToString() + extName; //dFileUpload.PostedFile.SaveAs(fullFileName); //mApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); //mApp.Visible = false; //m_book = mApp.Workbooks.Open(fullFileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); //worksheet = ((Microsoft.Office.Interop.Excel.Worksheet)mApp.Sheets[1]); //////////////////// //IntPtr t = new IntPtr(mApp.Hwnd); //int processId = 0; //GetWindowThreadProcessId(t, out processId); //process = System.Diagnostics.Process.GetProcessById(processId); } catch { pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString(); showErrorMessage(pmtMessage2); //showErrorMessage("上传的文件格式不正确."); return; } int startRow = EXCEL_DATA_START_ROW; int endRow = dt.Rows.Count + startRow; if (endRow < startRow) { pmtMessage3 = this.GetLocalResourceObject(Pre + "_pmtMessage3").ToString(); showErrorMessage(pmtMessage3); //showErrorMessage("没有需要上传的数据."); return; } //string excelRange = string.Format("A{0}:{1}{2}",EXCEL_DATA_START_ROW.ToString(), "E", endRow); //object[,] getdata = (object[,])worksheet.get_Range(excelRange, Type.Missing).Value2; List<ForwarderInfo> forwarderList = new List<ForwarderInfo>(); int iRowsCountNPOI = dt.Rows.Count; for (int iRow = 1; iRow < iRowsCountNPOI; iRow++) { int lineNum = iRow + EXCEL_DATA_START_ROW - 1; ForwarderInfo item = new ForwarderInfo(); string Value1NPOI = dt.Rows[iRow][0].ToString(); string Value2NPOI = dt.Rows[iRow][1].ToString(); string Value3NPOI = dt.Rows[iRow][2].ToString(); string Value4NPOI = dt.Rows[iRow][3].ToString(); string Value5NPOI = dt.Rows[iRow][4].ToString(); //string Value6NPOI = dt.Rows[iRow][5].ToString(); //object value1 = getdata[iRow, 1]; //string strValue1 = Null2String(value1); //object value2 = getdata[iRow, 2]; //string strValue2 = Null2String(value2); //object value3 = getdata[iRow, 3]; //string strValue3 = Null2String(value3); //object value4 = getdata[iRow, 4]; //string strValue4 = Null2String(value4); //object value5 = getdata[iRow, 5]; //string strValue5 = Null2String(value5); if (Value1NPOI == "" && Value2NPOI == "" && Value3NPOI == "" && Value4NPOI == "" && Value5NPOI == "") { continue; } if (Value1NPOI == "" || Value2NPOI == "" || Value3NPOI == "" || Value4NPOI == "" || Value5NPOI == "" ) { pmtMessage5 = this.GetLocalResourceObject(Pre + "_pmtMessage5").ToString() + " " + lineNum.ToString(); showErrorMessage(pmtMessage5); return; } double days; bool isSuccess = Double.TryParse(Value1NPOI, out days); if (isSuccess) { //微软的bug, excel中直接拉,认为有1900-2-29,实际上没有,在那里差了一天 //Excel中1900-2-28取到的数是59, //1900-3-1取到的数是61,不连续 if (days <= 60) { days = days - 1; } else { days = days - 2; } DateTime curDate = DateTime.Parse("1900-01-01").AddDays(days); Value1NPOI = curDate.ToString("yyyy/MM/dd", System.Globalization.DateTimeFormatInfo.InvariantInfo); } else { try { DateTime curDate = DateTime.Parse(Value1NPOI); Value1NPOI = curDate.ToString("yyyy/MM/dd", System.Globalization.DateTimeFormatInfo.InvariantInfo); } catch { //什么都不做,保持原来的数据形式 pmtMessage5 = this.GetLocalResourceObject(Pre + "_pmtMessage5").ToString() + " " + lineNum.ToString(); showErrorMessage(pmtMessage5); return; } } item.Date = Value1NPOI; item.Forwarder = Value2NPOI.ToUpper(); item.MAWB = Value3NPOI; item.Driver = Value4NPOI; item.TruckID = Value5NPOI.ToUpper(); item.ContainerId = ""; item.Editor = this.HiddenUserName.Value; item.Cdt = DateTime.Now; item.Udt = DateTime.Now; forwarderList.Add(item); } if (forwarderList.Count < 1) { //showErrorMessage("没有需要上传的数据."); pmtMessage3 = this.GetLocalResourceObject(Pre + "_pmtMessage3").ToString(); showErrorMessage(pmtMessage3); return; } this.hidIsSubmitOK.Value = "OK"; iForwarder.ImportForwarder(forwarderList); } else { //pmtMessage4 = this.GetLocalResourceObject(Pre + "_pmtMessage4").ToString(); //showErrorMessage(pmtMessage4); ////showErrorMessage("需要选择上传的文件."); //return; pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString(); showErrorMessage(pmtMessage2); //showErrorMessage("上传的文件格式不正确."); return; } } //catch (SmtpException ex) catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } finally { TryDeleteTempFile(fullFileName); } //finally //{ // if (mApp != null) // { // try // { // if (m_book != null) m_book.Close(false, null, null); // mApp.Quit(); // if (worksheet != null) System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet); // if (m_book != null) System.Runtime.InteropServices.Marshal.ReleaseComObject(m_book); // System.Runtime.InteropServices.Marshal.ReleaseComObject(mApp); // } // catch // { // //ignore // } // worksheet = null; // m_book = null; // mApp = null; // } // if (process != null) // { // try // { // process.Kill(); // } // catch // { // // ignore // } // } // // Collect the unreferenced objects // GC.Collect(); // GC.WaitForPendingFinalizers(); // TryDeleteTempFile(fullFileName); //} ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "OKComplete", "OKComplete();HideWait();", true); }
//protected void btnAdd_ServerClick(Object sender, EventArgs e) //{ // QCRatioDef item = new QCRatioDef(); // String itemId; // String model = this.cmbMaintainModelByFamily.InnerDropDownList.SelectedValue; // if (model != "") // { // item.Family = model; // } // else // { // item.Family = this.cmbMaintainFamily.InnerDropDownList.SelectedValue; // } // item.QCRatio = this.dQCRatio.Text.Trim(); // item.EOQCRatio = this.dEQQCRatio.Text.Trim(); // item.PAQCRatio = this.dPAQCRatio.Text.Trim(); // item.Customer = this.cmbCustomer.InnerDropDownList.SelectedValue; // item.Editor = this.HiddenUserName.Value; // try // { // itemId = iQCRatio.AddQCRatio(item); // } // catch (FisException ex) // { // showErrorMessage(ex.mErrmsg); // return; // } // catch (Exception ex) // { // //show error // showErrorMessage(ex.Message); // return; // } // ShowListByCustom(); // itemId = replaceSpecialChart(itemId); // this.updatePanel2.Update(); // ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "AddUpdateComplete('" + itemId + "');DealHideWait();", true); //} protected void btnDelete_ServerClick(Object sender, EventArgs e) { //string familyId = this.dFamily.Text.Trim(); string oldId = this.dOldId.Value.Trim(); try { ForwarderInfo item = new ForwarderInfo(); item.Id = Int32.Parse(oldId); iForwarder.DeleteForwarder(item); } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } ShowList(); this.updatePanel1.Update(); ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "DeleteComplete();DealHideWait();", true); }
//protected void btnReworkChange_ServerClick(Object sender, EventArgs e) //{ // ShowList2(); // this.updatePanel2.Update(); // ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "HideWait", "DealHideWait();", true); //} protected void btnUpdate_ServerClick(Object sender, EventArgs e) { ForwarderInfo item = new ForwarderInfo(); item.Driver = this.dDriver.Text.Trim(); item.TruckID = this.dTruckID.Text.Trim().ToUpper(); item.Editor = this.HiddenUserName.Value; string oldItemId = this.dOldId.Value.Trim(); item.Id = Int32.Parse(oldItemId); item.Date = this.dDateValue.Value.Trim(); item.Forwarder = this.dForwarderValue.Value.Trim(); item.MAWB = this.dMAWBValue.Value.Trim(); item.ContainerId = this.dContainerID.Text.Trim(); try { iForwarder.UpdateForwarder(item); } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } ShowList(); String itemId = item.Id.ToString(); this.updatePanel1.Update(); ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "AddUpdateComplete('" + itemId + "');DealHideWait();", true); }