protected void cmdQuery_ServerClick(object sender, System.EventArgs e) { string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.DownLoadPathBom, null); if (fileName == null) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileIsEmpty"); } string fileName2 = fileName.ToUpper(); if (fileName2.LastIndexOf(".XLS") == -1) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileTypeError_XLS"); } //this.ViewState.Add("UploadedFileName",fileName); this.UploadedFileName = fileName; this.RequestData(); //chbSelectAll.Checked = true; //this.gridHelper.CheckAllRows(CheckStatus.Checked); foreach (GridRecord row in gridWebGrid.Rows) { row.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = true; } }
protected void cmdView_ServerClick(object sender, System.EventArgs e) { string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.DownLoadPathMO, null); if (fileName == null) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileIsEmpty"); } //add by crystal chu 2005/07/15 if (!(fileName.ToLower().EndsWith(".xls") || fileName.ToLower().EndsWith(".xlsx"))) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileTypeError_XLS"); } this.ViewState.Add("UploadedFileName", fileName); this.RequestData(); //this.gridHelper.CheckAllRows(CheckStatus.Checked); // modify by Simone //如果没有异常信息,将导入按钮置为可用 for (int i = 0; i < this.gridWebGrid.Rows.Count; i++) { if (string.IsNullOrEmpty(this.gridWebGrid.Rows[i].Items.FindItemByKey("importException").Text)) { this.cmdEnter.Disabled = false; } } if (this.gridWebGrid.Rows.Count == 0) { this.cmdEnter.Disabled = true; } }
protected void cmdView_ServerClick(object sender, System.EventArgs e) { string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.DownLoadPathMO, null); if (fileName == null) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileIsEmpty"); } //add by crystal chu 2005/07/15 if (fileName.LastIndexOf(".csv") == -1) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileTypeError"); } this.ViewState.Add("UploadedMOBOMFileName", fileName); this.RequestData(); }
protected void cmdQuery_ServerClick(object sender, System.EventArgs e) { string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.DownLoadPathBom, null); if (fileName == null) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileIsEmpty"); } string fileName2 = fileName.ToUpper(); if (fileName2.LastIndexOf(".XLS") == -1) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileTypeError_XLS"); } this.UploadedFileName = fileName; this.RequestData(); ArrayList importArray = this.GetAllRows(); if (importArray.Count == 0) { return; } DataTable dt = this.GetImportDT(importArray); ImportData.ImportDateEngine importEngine = new BenQGuru.eMES.Web.BaseSetting.ImportData.ImportDateEngine( base.DataProvider, this.InputType, dt, this.GetUserCode(), importArray, this.gridHelper); importEngine.CheckDataValid(); foreach (GridRecord row in gridWebGrid.Rows) { if (!string.IsNullOrEmpty(row.Items.FindItemByKey("ImportResult").Text)) { this.cmdEnter.Disabled = true; this.cmdGridExport.Disabled = false; return; } } this.cmdEnter.Disabled = false; this.cmdGridExport.Disabled = true; }
protected void cmdQuery_ServerClick(object sender, System.EventArgs e) { string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.DownLoadPathBom, null); if (fileName == null || fileName.Trim().Length <= 0) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileIsEmpty"); } else if (fileName.ToUpper().LastIndexOf(".XLS") < 0) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileTypeError_XLS"); } this.UploadedFileName = fileName; this.RequestData(); //chbSelectAll.Checked = true; //this.gridHelper.CheckAllRows(CheckStatus.Checked); }
protected void cmdView_ServerClick(object sender, System.EventArgs e) { string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.fileInit, null); if (fileName == null) { BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileIsEmpty"); } if (!fileName.ToLower().EndsWith(".csv")) { BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileTypeError"); } this.ViewState.Add("UploadedFileName", fileName); this.cmdQuery_Click(null, null); if (this.gridWebGrid.Rows.Count > 0) { this.cmdEnter.Disabled = false; } }
protected void cmdView_ServerClick(object sender, System.EventArgs e) { string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.fileInit, null); if (fileName == null) { BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileIsEmpty"); } if (!(fileName.ToLower().EndsWith(".xls") || fileName.ToLower().EndsWith(".xlsx"))) { BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileTypeError_XLS"); } this.ViewState.Add("UploadedFileName", fileName); this.cmdQuery_Click(null, null); /* * if (this.gridWebGrid.Rows.Count > 0) * { * this.cmdImport.Disabled = false; * } */ this.cmdEnter.Disabled = false; if (this.items != null) { for (int i = 0; i < this.items.Length; i++) { SMTFeederMaterial item = (SMTFeederMaterial)items[i]; if (item.EAttribute2 == "false") // if (item.EAttribute1.StartsWith(false.ToString()) == true) { this.cmdEnter.Disabled = true; break; } } } }
protected void cmdImport_ServerClick(object sender, EventArgs e) { string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.fileInit, null); if (fileName == null) { BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileIsEmpty"); } if (!fileName.ToLower().EndsWith(".csv")) { BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileTypeError"); } if (items == null) { items = GetAllItem(fileName); if (items == null) { return; } } if (items == null || items.Length == 0) { return; } int successNum = 0; CultureInfo culture = new System.Globalization.CultureInfo("en-US"); string userCode = this.GetUserCode(); if (facade == null) { facade = new BaseModelFacade(this.DataProvider); } SoftWareVersion softWareVersion = this.facade.CreateNewSoftWareVersion(); ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false; ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection(); DataProvider.BeginTransaction(); try { for (int i = 0; i < items.Length; i++) { #region Check string versionCode = GetFieldValue(items[i], "VersionCode"); if (versionCode == string.Empty) { throw new Exception("软件版本不能为空"); } else { object obj = facade.GetSoftWareVersion(versionCode); if (obj != null) { throw new Exception(string.Format("软件版本:{0} 已经存在", versionCode)); } } if (Encoding.Default.GetByteCount(versionCode) > 40) { throw new Exception("软件版本长度超出范围,最大长度40字节"); } string effectiveDate = GetFieldValue(items[i], "EffectiveDate"); if (effectiveDate == string.Empty) { throw new Exception("生效日期不能为空"); } else { try { DateTime endDate = DateTime.ParseExact(effectiveDate, "yyyyMMdd", culture); } catch { throw new Exception("生效日期格式不正确"); } } string invalidDate = GetFieldValue(items[i], "InvalidDate"); if (invalidDate == string.Empty) { throw new Exception("失效日期不能为空"); } else { try { DateTime endDate = DateTime.ParseExact(invalidDate, "yyyyMMdd", culture); } catch { throw new Exception("失效日期格式不正确"); } } #endregion softWareVersion.VersionCode = versionCode; softWareVersion.Status = SoftWareVersionStatus.Valid; softWareVersion.EffectiveDate = int.Parse(effectiveDate); softWareVersion.InvalidDate = int.Parse(invalidDate); softWareVersion.MaintainUser = userCode; softWareVersion.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID; this.facade.AddSoftWareVersion(softWareVersion); successNum++; } this.DataProvider.CommitTransaction(); string strMessage = "导入:" + successNum + "笔"; string alertInfo = string.Format("<script language=javascript>alert('{0}');</script>", strMessage); if (!this.IsClientScriptBlockRegistered("ImportAlert")) { this.RegisterClientScriptBlock("ImportAlert", alertInfo); } items = null; this.gridHelper.RequestData(); this.buttonHelper.PageActionStatusHandle(PageActionType.Query); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); ExceptionManager.Raise(this.GetType().BaseType, ex.Message); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection(); ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true; } }
protected void cmdImport_ServerClick(object sender, System.EventArgs e) { this._Facade = new MaterialFacade(this.DataProvider); string errorItemCode = string.Empty; string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.fileInit, null); if (fileName == null) { WebInfoPublish.Publish(this, "$Error_UploadFileIsEmpty", this.languageComponent1); return; } if (!fileName.ToLower().EndsWith(".csv")) { WebInfoPublish.Publish(this, "$Error_UploadFileTypeError", this.languageComponent1); return; } this.ViewState.Add("UploadedFileName", fileName); if (items == null) { items = GetAllItem(); if (items == null) { return; } } if (items == null || items.Length == 0) { return; } int successNum = 0; int failNum = 0; string objValue = string.Empty; string orgID = GlobalVariables.CurrentOrganizations.First().OrganizationID.ToString(); string mUser = GetUserCode(); for (int i = 0; i < items.Length; i++) { string itemCode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(GetFieldValue(items[i], "ITEMCODE"))); string requestQty = FormatHelper.CleanString(GetFieldValue(items[i], "RequestQTY")); if (string.Compare(GetFieldValue(items[i], "EAttribute1"), "OK", true) == 0 || string.Compare(GetFieldValue(items[i], "EAttribute1"), "Insert", true) == 0) { object obj = _Facade.GetMaterialReqStd(itemCode, int.Parse(orgID)); MaterialReqStd newMaterialReqStd = new MaterialReqStd(); if (string.Compare(GetFieldValue(items[i], "EAttribute1"), "Insert", true) == 0) { newMaterialReqStd.ItemCode = itemCode; newMaterialReqStd.OrganizationID = int.Parse(orgID); newMaterialReqStd.RequestQTY = int.Parse(requestQty); newMaterialReqStd.MaintainUser = mUser; _Facade.AddMaterialReqStd(newMaterialReqStd); } else { MaterialReqStd objMaterialReqStd = obj as MaterialReqStd; objValue = requestQty.ToString(); if (objValue != string.Empty) { objMaterialReqStd.RequestQTY = int.Parse(objValue); } objMaterialReqStd.MaintainUser = mUser; if (string.Compare(GetFieldValue(items[i], "EAttribute1"), "OK", true) == 0) { _Facade.UpdateMaterialReqStd(objMaterialReqStd); } } successNum++; } else { failNum++; errorItemCode += GetFieldValue(items[i], "ITEMCODE").ToString() + "\\n";; } } errorItemCode = "\\n导入失败的料号:\\n" + errorItemCode; string strMessage = "导入完成: 成功" + successNum + "笔, 失败" + failNum + "笔\\n" + errorItemCode; string alertInfo = string.Format("<script language=javascript>alert('{0}');</script>", strMessage); if (!this.IsClientScriptBlockRegistered("ImportAlert")) { this.RegisterClientScriptBlock("ImportAlert", alertInfo); } items = null; }
protected void cmdImport_ServerClick(object sender, EventArgs e) { string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.fileInit, null); if (fileName == null) { WebInfoPublish.Publish(this, "$Error_UploadFileIsEmpty", this.languageComponent1); return; } if (!fileName.ToLower().EndsWith(".csv")) { WebInfoPublish.Publish(this, "$Error_UploadFileTypeError", this.languageComponent1); return; } if (items == null) { items = GetAllItem(fileName); if (items == null) { return; } } if (items == null || items.Length == 0) { return; } int successNum = 0; CultureInfo culture = new System.Globalization.CultureInfo("en-US"); string userCode = this.GetUserCode(); if (facade == null) { facade = new BaseModelFacade(this.DataProvider); } SoftWareVersion softWareVersion = this.facade.CreateNewSoftWareVersion(); ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false; ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection(); DataProvider.BeginTransaction(); try { for (int i = 0; i < items.Length; i++) { #region Check string versionCode = GetFieldValue(items[i], "VersionCode"); if (versionCode == string.Empty) { WebInfoPublish.Publish(this, "软件版本不能为空", this.languageComponent1); return; } else { object obj = facade.GetSoftWareVersion(versionCode); if (obj != null) { WebInfoPublish.Publish(this, string.Format("软件版本:{0} 已经存在", versionCode), this.languageComponent1); return; } } if (Encoding.Default.GetByteCount(versionCode) > 40) { WebInfoPublish.Publish(this, "软件版本长度超出范围,最大长度40字节", this.languageComponent1); return; } string effectiveDate = GetFieldValue(items[i], "EffectiveDate"); if (effectiveDate == string.Empty) { WebInfoPublish.Publish(this, "生效日期不能为空", this.languageComponent1); return; } else { try { DateTime endDate = DateTime.ParseExact(effectiveDate, "yyyyMMdd", culture); } catch { WebInfoPublish.Publish(this, "生效日期格式不正确", this.languageComponent1); return; } } string invalidDate = GetFieldValue(items[i], "InvalidDate"); if (invalidDate == string.Empty) { WebInfoPublish.Publish(this, "失效日期不能为空", this.languageComponent1); return; } else { try { DateTime endDate = DateTime.ParseExact(invalidDate, "yyyyMMdd", culture); } catch { WebInfoPublish.Publish(this, "失效日期格式不正确", this.languageComponent1); return; } } #endregion softWareVersion.VersionCode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(versionCode)); softWareVersion.Status = SoftWareVersionStatus.Valid; softWareVersion.EffectiveDate = int.Parse(effectiveDate); softWareVersion.InvalidDate = int.Parse(invalidDate); softWareVersion.MaintainUser = userCode; softWareVersion.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID; this.facade.AddSoftWareVersion(softWareVersion); successNum++; } this.DataProvider.CommitTransaction(); string strMessage = "导入:" + successNum + "笔"; WebInfoPublish.Publish(this, strMessage, this.languageComponent1); items = null; } catch (Exception ex) { this.DataProvider.RollbackTransaction(); WebInfoPublish.Publish(this, ex.Message, this.languageComponent1); return; } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection(); ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true; } }