public frmGroupChat(XmppClientConnection xmppCon, Jid roomJid) { InitializeComponent(); this.rtfSend.Select(); _roomJid = roomJid; _xmppCon = xmppCon; this.groupChatServerLabel.Text = "Room Name: " + _roomJid.User; frmInputBox input = new frmInputBox("Nickname", "Nickname"); if (!Util.GroupChatForms.Contains(roomJid.Bare) && input.ShowDialog() == DialogResult.OK) { _nickname = input.Result; Util.GroupChatForms.Add(roomJid.Bare.ToLower(), this); this.Show(); } else { return; } // Setup new Message Callback _xmppCon.MessageGrabber.Add(roomJid, new BareJidComparer(), new MessageCB(MessageCallback), null); // Setup new Presence Callback _xmppCon.PresenceGrabber.Add(roomJid, new BareJidComparer(), new PresenceCB(PresenceCallback), null); }
private void tsmiNewScriptFile_Click(object sender, EventArgs e) { try { string newName = ""; var newNameForm = new frmInputBox("Enter the name of the new file without extension", "New File"); newNameForm.txtInput.Text = tvProject.SelectedNode.Name; newNameForm.ShowDialog(); if (newNameForm.DialogResult == DialogResult.OK) { newName = newNameForm.txtInput.Text; } else if (newNameForm.DialogResult == DialogResult.Cancel) { return; } if (newName.EndsWith(".json")) { throw new Exception("Invalid file name"); } string selectedNodePath = tvProject.SelectedNode.Tag.ToString(); string newFilePath = Path.Combine(selectedNodePath, newName + ".json"); UIListView newScriptActions = NewLstScriptActions(); List <ScriptVariable> newScripVariables = new List <ScriptVariable>(); List <ScriptElement> newScriptElements = new List <ScriptElement>(); var helloWorldCommand = new ShowMessageCommand(); helloWorldCommand.v_Message = "Hello World"; newScriptActions.Items.Insert(0, CreateScriptCommandListViewItem(helloWorldCommand)); if (!File.Exists(newFilePath)) { Script.SerializeScript(newScriptActions.Items, newScripVariables, newScriptElements, newFilePath); NewNode(tvProject.SelectedNode, newFilePath, "file"); OpenFile(newFilePath); } else { int count = 1; string newerFilePath = newFilePath; while (File.Exists(newerFilePath)) { string newDirectoryPath = Path.GetDirectoryName(newFilePath); string newFileNameWithoutExtension = Path.GetFileNameWithoutExtension(newFilePath); newerFilePath = Path.Combine(newDirectoryPath, $"{newFileNameWithoutExtension} ({count}).json"); count += 1; } Script.SerializeScript(newScriptActions.Items, newScripVariables, newScriptElements, newerFilePath); NewNode(tvProject.SelectedNode, newerFilePath, "file"); OpenFile(newerFilePath); } } catch (Exception ex) { Notify("An Error Occured: " + ex.Message, Color.Red); } }
private void uiBtnRenameSequence_Click(object sender, EventArgs e) { frmInputBox renameSequence = new frmInputBox("New Sequence Name", "Rename Sequence"); renameSequence.txtInput.Text = Text; renameSequence.ShowDialog(); if (renameSequence.DialogResult == DialogResult.OK) { Text = renameSequence.txtInput.Text; } }
private void ProxyCreateRandom() { // Default sample size int pSample = 25; var mSelectedLayer = ExtFunctions.GetSelectedLayer(theMap); IFeatureLayer mLayer = null; if (mSelectedLayer == null || !(mSelectedLayer is IFeatureLayer)) { this.Log("No feature layer selected, please select a layer and try again."); return; } mLayer = (IFeatureLayer)mSelectedLayer; var mFrmInputBox = new frmInputBox("Specify size of sample", "Please specify number of items to be included in the output file", pSample); if (DialogResult.OK == mFrmInputBox.ShowDialog()) { if (mFrmInputBox.GetAsInteger() != null) { pSample = (int)mFrmInputBox.GetAsInteger(); Utilities.LogDebug("Using specified sample size: " + pSample); } else if (mFrmInputBox.GetAsPercent() != null) { int mPercentage = (int)mFrmInputBox.GetAsPercent(); IFeatureSet mFeatureSet = mLayer.DataSet; pSample = (int)Math.Floor(((double)mPercentage * (double)mFeatureSet.NumRows()) / 100); Utilities.LogDebug("Using " + mPercentage + "% : " + pSample); } else { Utilities.LogDebug("Using default sample size: " + pSample); } this.Log(pSample.ToString()); if (pSample > 0) { var mRndFeatureSet = ExtFunctions.CreateRandomSelection(mLayer, pSample); if (mRndFeatureSet == null) { Utilities.LogDebug("Creation of random selection layer failed"); return; } var mLayer2 = (IFeatureLayer)ExtFunctions.GetFeatureLayer(theMap.Layers, mRndFeatureSet, mLayer.LegendText + " : random", ExtFunctions.CopyLayerSymbolizer(mLayer), mLayer.Projection); ExtFunctions.AddLabelsForFeatureLayer(mLayer2, "Address unit numbers", "#[ADDRESSUNITNR], [ROADNAME_EN]", GoogleMapsColors.BoundaryMajor); } } }
private void tsmiNewFolder_Click(object sender, EventArgs e) { try { string newName = ""; var newNameForm = new frmInputBox("Enter the name of the new folder", "New Folder"); newNameForm.txtInput.Text = tvProject.SelectedNode.Name; newNameForm.ShowDialog(); if (newNameForm.DialogResult == DialogResult.OK) { newName = newNameForm.txtInput.Text; } else if (newNameForm.DialogResult == DialogResult.Cancel) { return; } if (newName.EndsWith(".json")) { throw new Exception("Invalid folder name"); } string selectedNodePath = tvProject.SelectedNode.Tag.ToString(); string newFolderPath = Path.Combine(selectedNodePath, newName); if (!Directory.Exists(newFolderPath)) { Directory.CreateDirectory(newFolderPath); DirectoryInfo newDirectoryInfo = new DirectoryInfo(newFolderPath); NewNode(tvProject.SelectedNode, newFolderPath, "folder"); } else { int count = 1; string newerFolderPath = newFolderPath; while (Directory.Exists(newerFolderPath)) { newerFolderPath = $"{newFolderPath} ({count})"; count += 1; } Directory.CreateDirectory(newerFolderPath); DirectoryInfo newDirectoryInfo = new DirectoryInfo(newerFolderPath); NewNode(tvProject.SelectedNode, newerFolderPath, "folder"); } } catch (Exception ex) { Notify("An Error Occured: " + ex.Message, Color.Red); } }
public static string InputBox(string prompt, string title, string inputValue) { string retVal = string.Empty; frmInputBox frm = new frmInputBox(prompt, title, inputValue); if (frm.ShowDialog() == DialogResult.OK) { retVal = frm.InputValue; } frm.Dispose(); return(retVal); }
private void tsmiRenameFolder_Click(object sender, EventArgs e) { try { string selectedNodePath = tvProject.SelectedNode.Tag.ToString(); if (selectedNodePath != ScriptProjectPath) { DirectoryInfo selectedNodeDirectoryInfo = new DirectoryInfo(selectedNodePath); string newName = ""; var newNameForm = new frmInputBox("Enter the new name of the folder", "Rename Folder"); newNameForm.txtInput.Text = tvProject.SelectedNode.Name; newNameForm.ShowDialog(); if (newNameForm.DialogResult == DialogResult.OK) { newName = newNameForm.txtInput.Text; } else if (newNameForm.DialogResult == DialogResult.Cancel) { return; } string newPath = Path.Combine(selectedNodeDirectoryInfo.Parent.FullName, newName); bool isInvalidProjectName = new[] { @"/", @"\" }.Any(c => newName.Contains(c)); if (isInvalidProjectName) { throw new Exception("Illegal characters in path"); } if (Directory.Exists(newPath)) { throw new Exception("A folder with this name already exists"); } FileSystem.Rename(selectedNodePath, newPath); tvProject.SelectedNode.Name = newName; tvProject.SelectedNode.Text = newName; tvProject.SelectedNode.Tag = newPath; } } catch (Exception ex) { Notify("An Error Occured: " + ex.Message, Color.Red); } }
private void uiBtnRenameSequence_Click(object sender, EventArgs e) { frmInputBox renameSequence = new frmInputBox("New Sequence Name", "Rename Sequence"); renameSequence.txtInput.Text = Text; renameSequence.ShowDialog(); if (renameSequence.DialogResult == DialogResult.OK) { Text = renameSequence.txtInput.Text; if (!uiScriptTabControl.SelectedTab.Text.Contains(" *")) { uiScriptTabControl.SelectedTab.Text += " *"; } } renameSequence.Dispose(); }
private void BomEdit(DataRowView selectedItem) { try { if (selectedItem.IsNotNullOrEmpty()) { frmInputBox inp = new frmInputBox("BOM-Edit", "Unit"); inp.ShowDialog(); selectedItem.BeginEdit(); selectedItem["Component_Quantity"] = inp.Txt_InputBox.Text; selectedItem.EndEdit(); } } catch (Exception ex) { ex.LogException(); } }
private DialogResult AdventurerAssociation_Form_Start(Form newForm) { if (newForm is frmInputBox) { frmInputBox frmInputBox = newForm as frmInputBox; switch (frmInputBox.InputBoxType) { case InputBoxTypes.NewFile: case InputBoxTypes.RenameFile: case InputBoxTypes.AddColumn: case InputBoxTypes.RenameColumn: //輸入值 (frmInputBox.Controls.Find("txtInput", false)[0] as TextBox).Text = InputText; //按下OK frmInputBox.btnConfirm_Click(frmInputBox, new EventArgs()); break; default: break; } } return(newForm.DialogResult); }
private void tsmiRenameFile_Click(object sender, EventArgs e) { try { string selectedNodePath = tvProject.SelectedNode.Tag.ToString(); string selectedNodeName = tvProject.SelectedNode.Text.ToString(); string selectedNodeNameWithoutExtension = Path.GetFileNameWithoutExtension(selectedNodeName); string selectedNodeFileExtension = Path.GetExtension(selectedNodePath); if (selectedNodeName != _mainFileName && selectedNodeName != "project.config") { FileInfo selectedNodeDirectoryInfo = new FileInfo(selectedNodePath); string newNameWithoutExtension = ""; var newNameForm = new frmInputBox("Enter the new name of the file without extension", "Rename File"); newNameForm.ShowDialog(); if (newNameForm.DialogResult == DialogResult.OK) { newNameWithoutExtension = newNameForm.txtInput.Text; } else if (newNameForm.DialogResult == DialogResult.Cancel) { return; } string newName = newNameWithoutExtension + selectedNodeFileExtension; string newPath = Path.Combine(selectedNodeDirectoryInfo.DirectoryName, newName); bool isInvalidProjectName = new[] { @"/", @"\" }.Any(c => newNameWithoutExtension.Contains(c)); if (isInvalidProjectName) { throw new Exception("Illegal characters in path"); } if (File.Exists(newPath)) { throw new Exception("A file with this name already exists"); } var foundTab = uiScriptTabControl.TabPages.Cast <TabPage>().Where(t => t.ToolTipText == selectedNodePath) .FirstOrDefault(); if (foundTab != null) { DialogResult result = CheckForUnsavedScript(foundTab); if (result == DialogResult.Cancel) { return; } uiScriptTabControl.TabPages.Remove(foundTab); } FileSystem.Rename(selectedNodePath, newPath); tvProject.SelectedNode.Name = newName; tvProject.SelectedNode.Text = newName; tvProject.SelectedNode.Tag = newPath; } } catch (Exception ex) { Notify("An Error Occured: " + ex.Message); } }
private void Refresh() { frmInputBox inp; SapModel.HalbDetails = null; SapModel.BomDetails = null; SapModel.FertKDetails = null; SapModel.FertMDetails = null; SapModel.FertYDetails = null; SapModel.ProductionVersionDetails = null; SapModel.RoutingDetails = null; if (!SapModel.PartNo.IsNotNullOrEmpty()) { ShowInformationMessage(PDMsg.NotEmpty("Part No")); return; } switch (sapType) { case "BOM": { if (!_sapBll.IsProcessSheetAvailableDetails(SapModel)) { ShowInformationMessage(PDMsg.NoRecordFound); return; } inputInfo: { inp = new frmInputBox("BOM"); inp.ShowDialog(); if (inp.BlnOk) { SapModel.OperCode = inp.Txt_InputBox.Text; if (SapModel.OperCode.Length == 4 || SapModel.OperCode.Length == 6) { } else { ShowInformationMessage("Enter Four Or Six Digit Code"); goto inputInfo; } } else { SapModel.OperCode = ""; return; } _sapBll.GetBomMasterDetails(SapModel, ref _statusMsg, ref arrExportHeader); if (_statusMsg == PDMsg.NoRecordFound.ToString()) { ShowInformationMessage(PDMsg.NoRecordFound); } } if (SapModel.Plant == 1000) { KeyDateVisible = Visibility.Hidden; // Changed from Hidden to Collapsed - Jeyan } } break; case "FERT": { if (!_sapBll.IsProcessSheetAvailableDetails(SapModel)) { ShowInformationMessage(PDMsg.NoRecordFound); return; } inputInfo: { inp = new frmInputBox("FERT"); inp.ShowDialog(); if (inp.BlnOk) { SapModel.OperCode = inp.Txt_InputBox.Text; if (SapModel.OperCode.Length == 4 || SapModel.OperCode.Length == 6) { } else { ShowInformationMessage("Enter Four Or Six Digit Code"); goto inputInfo; } } else { SapModel.OperCode = ""; return; } } _sapBll.GetFertMasterDetails(SapModel, ref _statusMsg, ref arrExportHeader); if (_statusMsg == "M") { GrpMFertVisibility = Visibility.Visible; GrpKFertVisibility = Visibility.Collapsed; GrpYFertVisibility = Visibility.Collapsed; } else if (_statusMsg == "K-O") { GrpMFertVisibility = Visibility.Collapsed; GrpKFertVisibility = Visibility.Visible; GrpYFertVisibility = Visibility.Collapsed; } else if (_statusMsg == "K") { GrpMFertVisibility = Visibility.Collapsed; GrpKFertVisibility = Visibility.Visible; GrpYFertVisibility = Visibility.Collapsed; } else if (_statusMsg == "Y") { GrpMFertVisibility = Visibility.Collapsed; GrpKFertVisibility = Visibility.Collapsed; GrpYFertVisibility = Visibility.Visible; } else { GrpMFertVisibility = Visibility.Visible; GrpKFertVisibility = Visibility.Collapsed; GrpYFertVisibility = Visibility.Collapsed; } if (_statusMsg == PDMsg.NoRecordFound.ToString()) { ShowInformationMessage(PDMsg.NoRecordFound); } } break; case "HALB": { SapModel.HalbDetails = null; if (!_sapBll.IsProcessSheetAvailableDetails(SapModel)) { ShowInformationMessage(PDMsg.NoRecordFound); return; } inputInfoHalb: { inp = new frmInputBox("HALB"); inp.Txt_InputBox.Focus(); inp.ShowDialog(); SapModel.OperCode = inp.Txt_InputBox.Text; if (inp.BlnOk) { if (SapModel.OperCode.Length == 4 || SapModel.OperCode.Length == 6) { } else { ShowInformationMessage("Enter Four Or Six Digit Code"); goto inputInfoHalb; } } else { SapModel.OperCode = ""; return; } _sapBll.GetHalbMasterDetails(SapModel, ref _statusMsg, ref arrExportHeader); NotifyPropertyChanged("SapModel"); if (_statusMsg == PDMsg.NoRecordFound.ToString()) { ShowInformationMessage(PDMsg.NoRecordFound); } } } break; case "ROUTING": if (!_sapBll.IsProcessSheetAvailableDetails(SapModel)) { ShowInformationMessage(PDMsg.NoRecordFound); return; } inputInfoRout: { inp = new frmInputBox("ROUTING"); inp.ShowDialog(); if (inp.BlnOk) { SapModel.OperCode = inp.Txt_InputBox.Text; if (SapModel.OperCode.Length == 4 || SapModel.OperCode.Length == 6) { } else { ShowInformationMessage("Enter Four Or Six Digit Code"); goto inputInfoRout; } } else { SapModel.OperCode = ""; return; } _sapBll.GetRoutingMasterDetails(SapModel, ref _statusMsg, ref arrExportHeader); if (_statusMsg == PDMsg.NoRecordFound.ToString()) { ShowInformationMessage(PDMsg.NoRecordFound); } } break; case "PRDVERSION": if (!_sapBll.IsProcessSheetAvailableDetails(SapModel)) { ShowInformationMessage(PDMsg.NoRecordFound); return; } inputInfoPrd: { inp = new frmInputBox("PRODUCTION VERSION"); inp.ShowDialog(); if (inp.BlnOk) { SapModel.OperCode = inp.Txt_InputBox.Text; if (SapModel.OperCode.Length == 4 || SapModel.OperCode.Length == 6) { } else { ShowInformationMessage("Enter Four Or Six Digit Code"); goto inputInfoPrd; } } else { SapModel.OperCode = ""; return; } _sapBll.GetPrdVersionMasterDetails(SapModel, ref _statusMsg, ref arrExportHeader); if (_statusMsg == PDMsg.NoRecordFound.ToString()) { ShowInformationMessage(PDMsg.NoRecordFound); } } NotifyPropertyChanged("SapModel"); break; default: break; } if (SapModel.PartNo.IsNotNullOrEmpty()) { if (sapType == "HALB") { _sapBll.GetNoofOperationsHalb(SapModel); } else { _sapBll.GetNoofOperations(SapModel); } } }
private void tsmiNewScriptFile_Click(object sender, EventArgs e) { try { string newName = ""; var newNameForm = new frmInputBox("Enter the name of the new file WITH extension", "New File"); switch (ScriptProject.ProjectType) { case ProjectType.OpenBots: newNameForm.txtInput.Text = ".obscript"; break; case ProjectType.Python: newNameForm.txtInput.Text = ".py"; break; case ProjectType.TagUI: newNameForm.txtInput.Text = ".tag"; break; case ProjectType.CSScript: newNameForm.txtInput.Text = ".cs"; break; } newNameForm.ShowDialog(); if (newNameForm.DialogResult == DialogResult.OK) { newName = newNameForm.txtInput.Text; newNameForm.Dispose(); } else if (newNameForm.DialogResult == DialogResult.Cancel) { newNameForm.Dispose(); return; } if (!Path.HasExtension(newName)) { throw new FileFormatException($"No extension provided for '{newName}'"); } string selectedNodePath = tvProject.SelectedNode.Tag.ToString(); string newFilePath = Path.Combine(selectedNodePath, newName); string extension = Path.GetExtension(newFilePath); if (File.Exists(newFilePath)) { int count = 1; string newerFilePath = newFilePath; while (File.Exists(newerFilePath)) { string newDirectoryPath = Path.GetDirectoryName(newFilePath); string newFileNameWithoutExtension = Path.GetFileNameWithoutExtension(newFilePath); newerFilePath = Path.Combine(newDirectoryPath, $"{newFileNameWithoutExtension} ({count}){extension}"); count += 1; } newFilePath = newerFilePath; } switch (extension.ToLower()) { case ".obscript": UIListView newScriptActions = NewLstScriptActions(); List <ScriptVariable> newScriptVariables = new List <ScriptVariable>(); List <ScriptArgument> newScriptArguments = new List <ScriptArgument>(); List <ScriptElement> newScriptElements = new List <ScriptElement>(); try { dynamic helloWorldCommand = TypeMethods.CreateTypeInstance(AContainer, "ShowMessageCommand"); helloWorldCommand.v_Message = "Hello World"; newScriptActions.Items.Insert(0, CreateScriptCommandListViewItem(helloWorldCommand)); } catch (Exception) { var brokenHelloWorldCommand = new BrokenCodeCommentCommand(); brokenHelloWorldCommand.v_Comment = "Hello World"; newScriptActions.Items.Insert(0, CreateScriptCommandListViewItem(brokenHelloWorldCommand)); } EngineContext engineContext = new EngineContext { Variables = newScriptVariables, Arguments = newScriptArguments, Elements = newScriptElements, FilePath = newFilePath, Container = AContainer }; Script.SerializeScript(newScriptActions.Items, engineContext); NewNode(tvProject.SelectedNode, newFilePath, "file"); OpenOpenBotsFile(newFilePath); break; case ".py": File.WriteAllText(newFilePath, _helloWorldTextPython); NewNode(tvProject.SelectedNode, newFilePath, "file"); OpenTextEditorFile(newFilePath, ProjectType.Python); break; case ".tag": File.WriteAllText(newFilePath, _helloWorldTextTagUI); NewNode(tvProject.SelectedNode, newFilePath, "file"); OpenTextEditorFile(newFilePath, ProjectType.TagUI); break; case ".cs": File.WriteAllText(newFilePath, _helloWorldTextCSScript); NewNode(tvProject.SelectedNode, newFilePath, "file"); OpenTextEditorFile(newFilePath, ProjectType.CSScript); break; default: File.Create(newFilePath).Close(); NewNode(tvProject.SelectedNode, newFilePath, "file"); return; } } catch (Exception ex) { Notify("An Error Occured: " + ex.Message, Color.Red); } }
private void tsmiRenameFolder_Click(object sender, EventArgs e) { try { string selectedNodePath = tvProject.SelectedNode.Tag.ToString(); DirectoryInfo selectedNodeDirectoryInfo = new DirectoryInfo(selectedNodePath); string newName = ""; string prompt; string title; if (selectedNodePath == ScriptProjectPath) { prompt = "Enter the new name of the project"; title = "Rename Project"; } else { prompt = "Enter the new name of the folder"; title = "Rename Folder"; } var newNameForm = new frmInputBox(prompt, title); newNameForm.txtInput.Text = tvProject.SelectedNode.Name; newNameForm.ShowDialog(); if (newNameForm.DialogResult == DialogResult.OK) { newName = newNameForm.txtInput.Text; newNameForm.Dispose(); } else if (newNameForm.DialogResult == DialogResult.Cancel) { newNameForm.Dispose(); return; } string newPath = Path.Combine(selectedNodeDirectoryInfo.Parent.FullName, newName); bool isInvalidProjectName = new[] { @"/", @"\" }.Any(c => newName.Contains(c)); if (isInvalidProjectName) { throw new Exception("Illegal characters in path"); } if (Directory.Exists(newPath)) { throw new Exception("A folder with this name already exists"); } if (CloseAllFiles()) { FileSystem.Rename(selectedNodePath, newPath); tvProject.SelectedNode.Name = newName; tvProject.SelectedNode.Text = newName; tvProject.SelectedNode.Tag = newPath; tvProject.SelectedNode.Collapse(); tvProject.SelectedNode.Expand(); if (selectedNodePath == ScriptProjectPath) { ScriptProject.ProjectName = newName; ScriptProjectPath = newPath; Project.RenameProject(ScriptProject, ScriptProjectPath); _appSettings.ClientSettings.RecentProjects.RemoveAt(0); _appSettings.ClientSettings.RecentProjects.Insert(0, ScriptProjectPath); _appSettings.Save(_appSettings); } string mainFilePath = Path.Combine(ScriptProjectPath, ScriptProject.Main); OpenOpenBotsFile(mainFilePath); } } catch (Exception ex) { Notify("An Error Occured: " + ex.Message, Color.Red); } }
private void btnExOk_Click(object sender, EventArgs e) { try { if (dgvIgEx.Rows.Count == 0) { throw new Exception("没有任何积分兑换记录,请重新输入!"); } string strBillNo = txtBillNo.Text.Trim(); if (strBillNo == "") { throw new Exception("请先打印回执!"); } int AssID = int.Parse(txtAssID.Text.Trim()); string strCardID = txtCardID.Text.Trim(); int IgSum = int.Parse(txtIgSum.Text.Trim()); bool continueflg = true; using (AMSEntities amsContext = new AMSEntities()) { tbAssociatorCard asscard1 = amsContext.tbAssociatorCard.FirstOrDefault(ac => ac.iAssID == AssID && ac.vcAssCardID == strCardID); while (continueflg) { frmInputBox inbox = new frmInputBox("请输入会员卡密码:", "PWD"); inbox.ShowDialog(); if (GlobalParams.strInputBoxMes == "Cancel") { GlobalParams.strInputBoxMes = ""; return; } else { if (GlobalParams.strInputBoxMes == "") { MessageBox.Show("会员卡密码不能为空,请重新输入!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (asscard1 == null) { MessageBox.Show("会员信息有误,请重试!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (GlobalParams.strInputBoxMes != asscard1.vcAssPwd) { MessageBox.Show("输入的会员卡密码错误,请重试!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { continueflg = false; } } } } tbIntegral intg1 = amsContext.tbIntegral.FirstOrDefault(ig => ig.iAssID == AssID && ig.vcAssCardID == strCardID); if (intg1 == null) { throw new Exception("获取会员卡积分错误,请重试!"); } if (intg1.iIgValue < IgSum) { throw new Exception("当前积分余额不足,请重新读卡后重试!"); } long billNo = long.Parse(strBillNo); tbBillInvoice bill1 = amsContext.tbBillInvoice.FirstOrDefault(bl => bl.iBillNo == billNo); if (bill1 == null) { throw new Exception("帐单不存在,请重试!"); } long igserialNo = 0; using (AMSEntities amscontext2 = new AMSEntities()) { tbIgSerialNo igserial1 = new tbIgSerialNo(); igserial1.vcFill = "0"; amscontext2.AddTotbIgSerialNo(igserial1); amscontext2.SaveChanges(); igserialNo = igserial1.iSerialNo; } DateTime dtoperdate = DateTime.Now; intg1.iIgValue = intg1.iIgValue - IgSum; ObjectStateEntry ose = amsContext.ObjectStateManager.GetObjectStateEntry(intg1); DataTable dtIgList = (DataTable)dgvIgEx.DataSource; int lastig = int.Parse(ose.OriginalValues["iIgValue"].ToString()); for (int i = 0; i < dtIgList.Rows.Count; i++) { tbIntegralLog intglog1 = new tbIntegralLog(); intglog1.iIgSerial = igserialNo; intglog1.iNo = i + 1; intglog1.iAssID = intg1.iAssID; intglog1.vcAssCardID = intg1.vcAssCardID; intglog1.iIgLast = lastig; intglog1.dtIgDate = dtoperdate; intglog1.vcIgName = dtIgList.Rows[i]["积分兑换项目"].ToString(); intglog1.vcIgType = "IG002"; intglog1.iIgGet = -(int.Parse(dtIgList.Rows[i]["兑换分值"].ToString())); intglog1.iIgArrival = lastig + intglog1.iIgGet; intglog1.iLinkCons = null; intglog1.vcOperID = GlobalParams.oper.vcOperID; intglog1.vcComments = dtIgList.Rows[i]["备注"].ToString(); amsContext.AddTotbIntegralLog(intglog1); lastig = (int)intglog1.iIgArrival; } bill1.vcLinkSerial = igserialNo; bill1.vcEffFlag = "1"; tbBusiLog busilog1 = new tbBusiLog(); busilog1.vcAssName = txtAssName.Text.Trim(); busilog1.vcAssCardID = intg1.vcAssCardID; busilog1.vcLinkSerial = igserialNo; busilog1.vcOperType = "OT013"; busilog1.vcOperID = GlobalParams.oper.vcOperID; busilog1.vcOperName = GlobalParams.oper.vcOperName; busilog1.dtOperDate = dtoperdate; busilog1.iAssID = intg1.iAssID; amsContext.AddTotbBusiLog(busilog1); amsContext.SaveChanges(); btnExOk.Enabled = false; btnPrint.Enabled = false; btnAdd.Enabled = false; btnDel.Enabled = false; btnRead.Enabled = true; txtIgSum.Text = "0"; txtBillNo.Text = ""; txtAssID.Text = ""; txtCardID.Text = ""; txtAssName.Text = ""; txtCurCharge.Text = ""; txtCurIg.Text = ""; DataTable dtIgExList = new DataTable(); dtIgExList.Columns.Add("积分兑换项目"); dtIgExList.Columns.Add("兑换分值"); dtIgExList.Columns.Add("备注"); dgvIgEx.DataSource = dtIgExList; MessageBox.Show("本次积分兑换成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { ErrorLog.Write(this, ex, "积分兑换异常"); } }