//Writes on the output textbox. private void WriteOnOutput(string message) { if (ServerWorking) { OutputTextbox.BeginInvoke(txtDelegate, message, OutputTextbox, true); } }
private void WriteOutput() { //string rawOutput = _listener.GetOutput(); // string rawOutput = @"<results> // <page fullPath='/core/HomeDev/A15'> // <start resultText='11:13:34' source='D:\Web\ACN21338\Data\logs\log.20141222.111144.txt' lineNumber='1879' /> // <end resultText='11:16:09' source='D:\Web\ACN21338\Data\logs\log.20141222.111144.txt' lineNumber='9351' /> // </page> // <page fullPath='/core/HomeDev/A16'> // <start resultText='16:27:13' source='D:\Web\ACN21338\Data\logs\log.20141222.111144.txt' lineNumber='135993' /> // <end resultText='16:31:25' source='D:\Web\ACN21338\Data\logs\log.20141222.111144.txt' lineNumber='144772' /> // </page> // </results>"; // XslCompiledTransform xslt = new XslCompiledTransform(); // StringReader xsr = new StringReader("); // StringReader sr = new StringReader(rawOutput); // XmlReader reader = XmlReader.Create(sr); // StringBuilder output = new StringBuilder(); // StringWriter sw = new StringWriter(output); // xslt.Transform(reader, null, sw); OutputTextbox.Invoke((Action) delegate() { OutputTextbox.Clear(); OutputTextbox.Text = _listener.GetOutput() .Replace("<page", Environment.NewLine + '\t' + "<page") .Replace("<start", Environment.NewLine + '\t' + '\t' + "<start") .Replace("<end", Environment.NewLine + '\t' + '\t' + "<end") .Replace("</page>", Environment.NewLine + '\t' + "</page>") .Replace("</results>", Environment.NewLine + "</results>"); }); }
private void Button_Click(object sender, EventArgs e) { if ((OutputTextbox.Text == "0") || (checkOperation) || OutputTextbox.Text == "Math Error") { OutputTextbox.ResetText(); } Button button = (Button)sender; buttonNUM = buttonNUM + button.Text; checkOperation = false; if (button.Text == "Ans") { OutputTextbox.Text = OutputTextbox.Text + ans; } if (button.Text == ".") { if (!OutputTextbox.Text.Contains(".")) { OutputTextbox.Text = OutputTextbox.Text + button.Text; } } else { if (button.Text != "Ans") { OutputTextbox.Text = OutputTextbox.Text + button.Text; } } }
private void AppendLineToOutput(string text, Color color) { if (OutputTextbox.InvokeRequired) { SetTextColorCallback d = new SetTextColorCallback(AppendLineToOutput); this.Invoke(d, new object[] { text, color }); } else { OutputTextbox.SelectionStart = OutputTextbox.TextLength; OutputTextbox.SelectionLength = 0; OutputTextbox.SelectionColor = color; OutputTextbox.AppendText("[" + System.DateTime.Now.ToString("dd/MM HH:mm:ss") + "] " + text + Environment.NewLine); OutputTextbox.SelectionColor = OutputTextbox.ForeColor; if (!this.ContainsFocus) { OutputTextbox.ScrollToCaret(); } Console.Out.WriteLine("[" + System.DateTime.Now.ToString() + "] " + text); } }
private void AppendOutputText(string text, Brush bgColor) { OutputText += text + "\r\n"; OutputBgColor = bgColor; OutputTextbox.ScrollToEnd(); }
public void Log(string line) { if (!string.IsNullOrWhiteSpace(OutputTextbox.Text)) { OutputTextbox.Text += Environment.NewLine; } OutputTextbox.Text += line; OutputTextbox.ScrollToEnd(); }
//show the community in eash list box private void CommunityListShowing(Community comm) { //clear the list box ComunityListBoxClear(); //output names foreach (var res in comm.Residents) { PersonListbox.Items.Add(String.Format("{0}\t{1}\t{2}", res.FirstName, (DateTime.Now.Year - res.Birthday.Year), res.Occupation)); } //house output ResidenceListbox.Items.Add("House"); ResidenceListbox.Items.Add("-----------------"); foreach (var property in comm.Props) { if (property as House != null) { //resdients output if (property.ForSale) { ResidenceListbox.Items.Add(String.Format("{0} *", property.StreetAddr)); } else { ResidenceListbox.Items.Add(String.Format("{0}", property.StreetAddr)); } } } //apartment output ResidenceListbox.Items.Add(""); ResidenceListbox.Items.Add("Apartment"); ResidenceListbox.Items.Add("-----------------"); foreach (var property in comm.Props) { if (property as Apartment != null) { //resdients output if (property.ForSale) { ResidenceListbox.Items.Add(String.Format("{0} # {1} *", property.StreetAddr, ((Apartment)property).Unit)); } else { ResidenceListbox.Items.Add(String.Format("{0} # {1}", property.StreetAddr, ((Apartment)property).Unit)); } } } //clear the output box OutputTextbox.Clear(); //Display message OutputTextbox.Text = "The residents and properties of " + comm.Name + " are now listed."; }
public void AddData(byte b) { if (InvokeRequired) { Invoke(new Action <byte>(AddData), b); } else { OutputTextbox.AppendText(new string(Encoding.ASCII.GetChars(new byte[] { b }))); } }
//before drop down is hit private void Dropdown_Preview(object sender, EventArgs e) { OutputTextbox.Clear(); //print out DisplayResidentAmounts(DekalbCommunity); DisplayResidentAmounts(SycamoreCommunity); //if community it clicked then display if (DekalbRadioButton.Checked == true || SycamoreRadioButton.Checked == true) { DisplayResidenceDropdown(currentCommunity); } }
// Precondition: None // Postcondition: Writes a patron report in the textbox with their names and ids private void patronListToolStripMenuItem_Click(object sender, EventArgs e) { OutputTextbox.Clear(); string results = ""; // Placeholder text var patronReport = new StringBuilder(); //stringbuilder that holds the count string NL = Environment.NewLine; // Adds a new line patronReport.Append($"Patron Report: {_lib.GetPatronCount()} Patrons{NL}"); foreach (var patron in _lib.GetPatronsList()) { results += $"Patron Name: {patron.PatronName} Patron ID:{patron.PatronID}{NL}"; } OutputTextbox.Text = patronReport + results; }
// Precondition: None // Postcondition: Writes an item report in the textbox with the titles and call number private void itemListToolStripMenuItem_Click(object sender, EventArgs e) { OutputTextbox.Clear(); string results = ""; // Placeholder text string NL = Environment.NewLine; // Adds a new line var itemReport = new StringBuilder(); // stringbuilder that holds the count itemReport.Append($"Item Report: {_lib.GetItemCount()} items {NL}"); foreach (var item in _lib.GetItemsList()) { results += $"{item}{NL}{NL}"; } OutputTextbox.Text = $"{itemReport}" + $"{results}{NL}"; }
// Precondition: None // Postcondition: Writes a report on the items that are checked out private void checkedOutToolStripMenuItem_Click(object sender, EventArgs e) { OutputTextbox.Clear(); string results = ""; //Placeholder var checkedoutReport = new StringBuilder(); //stringbuilder that holds count string NL = Environment.NewLine; // Adds new line checkedoutReport.Append($"Checked Out Report :{_lib.GetCheckedOutCount()} items {NL}"); foreach (var item in _lib._items) { if (item.IsCheckedOut()) { results += $"{item}{NL}{NL}"; } } OutputTextbox.Text = $"{checkedoutReport}" + $"{results}{NL}"; }
private void InitializeComponent() { TabStop = true; outputTextBox = new OutputTextbox(); outputTextBox.Dock = DockStyle.Fill; outputTextBox.ScrollBars = RichTextBoxScrollBars.Both; outputTextBox.WordWrap = WixEditSettings.Instance.WordWrapInResultsPanel; outputTextBox.AllowDrop = false; Controls.Add(outputTextBox); outputTextBox.TabStop = true; outputTextBox.HideSelection = false; outputTextBox.MouseUp += new MouseEventHandler(outputTextBox_MouseDown); doubleClickTimer.Interval = 100; doubleClickTimer.Tick += new EventHandler(doubleClickTimer_Tick); }
private async void runToolStripMenuItem_Click(object sender, EventArgs e) { OutputTextbox.Clear(); await Task.Run(() => { CodeBlock.OutputFunction printF = OutputTextbox.AppendText; string sourceCode = inputTextBox.Text; Lexer lexer = null; Parser parser = null; try { lexer = new Lexer(sourceCode); } catch (Exception) { printF("Syntax error"); return; } try { parser = new Parser(lexer.GetList); } catch (Exception) { printF("Parsing error"); return; } try { parser.GetProgram().Run(printF); } catch (Exception) { printF("Runtime error"); return; } }); }
//click the person list box private void PersonListbox_MouseClick(object sender, MouseEventArgs e) { //split it string[] personInfo = PersonListbox.SelectedItem.ToString().Split('\t'); string[] propertyInfoList = CheckPersonInList(currentCommunity, personInfo[0], Convert.ToUInt16(personInfo[1]), personInfo[2]); OutputTextbox.Text = String.Format("{0}, Age ({1}), Occupation: {2}, who resides at:\r\n", propertyInfoList[0], personInfo[1], personInfo[2]); //for all items in the array for (int i = 1; i < propertyInfoList.Length; i++) { if (propertyInfoList[i] == null) { break; } OutputTextbox.AppendText(String.Format("\t{0}\r\n", propertyInfoList[i])); } //final output OutputTextbox.AppendText(String.Format("\r\n### END OUTPUT ###")); }
public OutputPanel(EditorForm editorForm, IconMenuItem buildMenu) { this.editorForm = editorForm; this.buildMenu = buildMenu; TabStop = true; outputTextBox = new OutputTextbox(); outputTextBox.Dock = DockStyle.Fill; outputTextBox.ScrollBars = RichTextBoxScrollBars.Both; outputTextBox.WordWrap = WixEditSettings.Instance.WordWrapInResultsPanel; outputTextBox.AllowDrop = false; Controls.Add(outputTextBox); outputTextBox.TabStop = true; outputTextBox.HideSelection = false; outputTextBox.MouseUp += new MouseEventHandler(outputTextBox_MouseDown); doubleClickTimer.Interval = 100; doubleClickTimer.Tick += new EventHandler(doubleClickTimer_Tick); cancelMenuItem = new IconMenuItem(); cancelMenuItem.Text = "Cancel Action"; cancelMenuItem.Click += new EventHandler(cancelMenuItem_Click); cancelMenuItem.Shortcut = Shortcut.CtrlC; cancelMenuItem.ShowShortcut = true; invokeClearRTF = new DelegateClearRtf(ClearRtf); invokeOutput = new DelegateOutput(Output); invokeOutputLine = new DelegateOutputLine(OutputLine); invokeOutputStart = new DelegateOutputStart(OutputStart); invokeOutputDone = new DelegateOutputDone(OutputDone); invokeProcessDone = new DelegateProcessDone(ProcessDone); }
private void Operation_Button(object sender, EventArgs e) { buttonNUM = ""; if (!checkOperation) { if (OutputTextbox.Text == "0") { OutputTextbox.ResetText(); } Button button = (Button)sender; operacion = button.Text; try { result = double.Parse(OutputTextbox.Text); } catch { } checkOperation = true; OutputLabel.Text = result + " " + operacion; } }
private void GAddPropertyButton_Click(object sender, EventArgs e) { //clear the output textbox OutputTextbox.Clear(); //error checking if (string.IsNullOrEmpty(StreetAddressTextbox.Text)) { OutputTextbox.AppendText("Please, enter the street name for the new property."); } else { if (!(DekalbRadioButton.Checked || SycamoreRadioButton.Checked)) { MessageBox.Show("Please, pick a community first"); } else { //add function AddAProperty(currentCommunity); } } }
public void OnStartListeningCommand() { ListenButton.Text = "Stop listening"; OutputTextbox.Clear(); TraceMessagesTextbox.Clear(); List <string> logUrls = LogUrlsTextbox.Text.Split(Environment.NewLine.ToCharArray()).Where(s => !string.IsNullOrEmpty(s)).ToList <string>(); if (logUrls != null && logUrls.Count > 0) { var logRefresher = new HttpLogSourceRefresher(logUrls.Where(s => !string.IsNullOrEmpty(s)).ToList <string>(), LogsFolderTextbox.Text, 2); _listener.LogSourceRefresher = logRefresher; } else { _listener.LogSourceRefresher = null; } string[] inputPages = InputPagesTextbox.Text.Split(Environment.NewLine.ToCharArray()); _listener.LogsFolder = LogsFolderTextbox.Text; _listener.StartListening(inputPages.Where(s => !string.IsNullOrEmpty(s)).ToList <string>()); stopWatch.Reset(); stopWatch.Start(); }
//Server thread function. private void ServerListening() { serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); serverIep = new IPEndPoint(IPAddress.Any, Port); serverSocket.Bind(serverIep); serverSocket.Listen(ClientNumber); OutputTextbox.BeginInvoke(txtDelegate, "-- " + Properties.strings.chatroomTitle + " " + Properties.strings.listeningAtPort + " " + Port, OutputTextbox, true); while (ServerWorking) { ClientHandler client = new ClientHandler(serverSocket.Accept(), this); lock (serverLocker) if (ServerWorking) { connectedClients.Add(client); } RefreshInfo(); } }
private void AddToProperty(Community comm) { //temp variables bool IsGood = false; //keep checking and regenerating till a good number is found while (IsGood == false) { //make new random number int rnd = GenerateRandomNo(); foreach (var res in comm.Residents) { if (res.Id == rnd) { break; } else { IsGood = true; } } //double chacking to make sure it was good if (IsGood == true) { //take in the infroamtion string[] splitstring = NameTextbox.Text.ToString().Split(' '); string fName = splitstring[0]; string lName = splitstring[1]; string occ = OccupationTextbox.Text.ToString(); DateTime dt = BirthdayPicker.Value; //convert int to uint uint id = (uint)(int)rnd; //find the resident id and from address and add it string lookup = ResidenceCombobox.Text; //search for the property and find its id foreach (var property in comm.Props) { bool added = false; //start going through each property listed if (property.StreetAddr == lookup) { bool isFound = false; foreach (var r in comm.Residents) { foreach (var e in r.Residencelds) { if (e == property.Id) { //output OutputTextbox.AppendText("You are already a resident here" + Environment.NewLine); isFound = true; break; } } //if not found then its good if (!isFound) { //Add the property ID to the residnce list var resId = property.Id.ToString(); comm.Residents.Add(new Person(id, dt, lName, fName, occ, resId)); OutputTextbox.AppendText("Success! " + fName + " has been added as a resident to " + comm.Name + Environment.NewLine); CommunityListShowingRefresh(currentCommunity); added = true; SnapPerson(); break; } } } if (added) { break; } } } } }
private void AppendOutputText(string text) { OutputText += text + "\r\n"; OutputTextbox.ScrollToEnd(); }
private void OutputTextbox_TextChanged(object sender, EventArgs e) { OutputTextbox.SelectionStart = OutputTextbox.Text.Length; OutputTextbox.ScrollToCaret(); }
private void IGUAL_Click(object sender, EventArgs e) { switch (operacion) { case "X": try { OutputTextbox.Text = (result * double.Parse(OutputTextbox.Text)).ToString(); History_click(OutputTextbox, result.ToString()); ans = OutputTextbox.Text; result = Convert.ToDouble(ans); AnsLebel(ans); OutputTextbox.ResetText(); buttonNUM = ""; break; } catch { break; } case "-": try { OutputTextbox.Text = (result - double.Parse(OutputTextbox.Text)).ToString(); History_click(OutputTextbox, result.ToString()); ans = OutputTextbox.Text; result = Convert.ToDouble(ans); AnsLebel(ans); OutputTextbox.ResetText(); buttonNUM = ""; break; } catch { break; } case "+": try { OutputTextbox.Text = (result + double.Parse(OutputTextbox.Text)).ToString(); History_click(OutputTextbox, result.ToString()); ans = OutputTextbox.Text; result = Convert.ToDouble(ans); AnsLebel(ans); OutputTextbox.ResetText(); buttonNUM = ""; break; } catch { break; } case " ÷": try { if (OutputTextbox.Text == "0") { OutputTextbox.Text = "Math Error"; OutputLabel.ResetText(); break; } OutputTextbox.Text = (result / double.Parse(OutputTextbox.Text)).ToString(); History_click(OutputTextbox, result.ToString()); ans = OutputTextbox.Text; result = Convert.ToDouble(ans); AnsLebel(ans); OutputTextbox.ResetText(); buttonNUM = ""; break; } catch { break; } default: break; } }
//output the amount of residents private void DisplayResidentAmounts(Community comm) { OutputTextbox.AppendText("There are " + comm.Population + " people living in " + comm.Name + "." + Environment.NewLine); }
private void ResidenceListbox_Click(object sender, EventArgs e) { //clear textbox for display OutputTextbox.Clear(); //make sure not null if (ResidenceListbox.SelectedItem == null) { return; } string[] propertyInfo = SelectedPropertyInfo(); //each property foreach (var property in currentCommunity.Props) { //if not equal if (property.StreetAddr != propertyInfo[0]) { continue; } if (property is Apartment) { if (((Apartment)property).Unit != propertyInfo[2]) { continue; } } //output OutputTextbox.AppendText("Residents live at " + propertyInfo[0] + ((DekalbRadioButton.Checked) ? ", Dekalb" : ", Sycamore")); string name = ""; //blank if no one //check the residentsd foreach (var res in currentCommunity.Residents) { if (res.Id != property.OwnerId) { continue; } name = res.LastName + ", " + res.FirstName; break; } //output before OutputTextbox.AppendText(", owned by " + name + ":" + Environment.NewLine); OutputTextbox.AppendText("------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); foreach (var res in currentCommunity.Residents) { foreach (var resId in res.Residencelds) { if (resId != property.Id) { continue; } //output each name OutputTextbox.AppendText(res.LastName + ", " + res.FirstName + "\t\t" + (DateTime.Now.Year - res.Birthday.Year) + "\t\t" + res.Occupation + Environment.NewLine); } } break; } //final output OutputTextbox.AppendText(Environment.NewLine); OutputTextbox.AppendText(String.Format("### END OUTPUT ###")); }
private void AddAProperty(Community comm) { //temp variables bool IsGood = false; //keep checking and regenerating till a good number is found while (IsGood == false) { //make new random number int rnd = GenerateRandomNo(); foreach (var res in comm.Props) { if (res.Id == rnd) { break; } else { IsGood = true; } } if (IsGood == true) { //Start assigning values to the data for merging to new property uint id = (uint)(int)rnd; //convert int to uint uint x = 9999; //we dont plan to use these for this assignment according to rogness uint y = 9999; //we dont plan to use these for this assignment according to rogness uint oId = default(uint); //0 or default value string stAddr = StreetAddressTextbox.Text.ToString(); string city = null; string zip = null; if (DekalbRadioButton.Checked) { city = "DeKalb"; zip = "60115"; } else if (SycamoreRadioButton.Checked) { city = "Sycamore"; zip = "60178"; } string state = "Illinois"; bool forSale = true; decimal tempbr = BedroomsUpDown.Value; uint bedRoom = (uint)(decimal)tempbr; decimal tempb = BathsUpDown.Value; uint bath = (uint)(decimal)tempb; decimal tempsqft = SquareFtUpDown.Value; uint sqft = (uint)(decimal)tempsqft; decimal tempf = FloorsUpDown.Value; uint floor = (uint)(decimal)tempf; //check wether were adding a apartment or a house if (String.IsNullOrEmpty(AptNumTextbox.Text)) { bool garage = false; bool aGarage = false; //check if it has a garage if (GarageCheckbox.Checked == true) { garage = true; } if (AttachedCheckbox.Checked == true) { aGarage = true; } House house = new House(id, x, y, oId, stAddr, city, state, zip, forSale, bedRoom, bath, sqft, garage, aGarage, floor); comm.Props.Add(house); OutputTextbox.AppendText("Success! A new property at " + stAddr + " has been added to " + comm.Name + "!" + Environment.NewLine); CommunityListShowingRefresh(currentCommunity); //clear everything SnapProperty(); } else { //set the properties unit value var unit = AptNumTextbox.Text; Apartment apartment = new Apartment(id, x, y, oId, stAddr, city, state, zip, forSale, bedRoom, bath, sqft, unit); comm.Props.Add(apartment); OutputTextbox.AppendText("Success! A new property at " + stAddr + " has been added to " + comm.Name + "!" + Environment.NewLine); CommunityListShowingRefresh(currentCommunity); //clear everything SnapProperty(); } } } }
private void btnUsporedi_Click(object sender, EventArgs e) { listBox2MDB.Items.Clear(); listBoxExcel.Items.Clear(); OutputTextbox.Clear(); textBox1.Clear(); textBox2.Clear(); string endcol = exl.getColumnName(exl.ws.UsedRange.Columns.Count); dat = exl.ReadRange(6, exl.getMaxRowNumber(), "A", endcol); usedColumn = Enumerable.Repeat(false, imenaKolona.Count).ToList(); emptyColumn = Enumerable.Repeat(false, imenaKolona.Count).ToList(); results = new Dictionary <string, Dictionary <string, double> >(); // Nadji novi partNo na kojem nisi bio int i; for (i = 1; i < listaExcel.Count; i++) { if (bio[i]) { continue; } bio[i] = true; break; } // obradi mdb string path = m.getMDBpath(listaExcel[i]); if (path == null) { return; } listaMdb = m.getMDBdata(listaExcel[i]); m.CreateTable("mapping", listaExcel[i]); int PNordinal = listaMdb.Columns["reference"].Ordinal; string connectString = @"Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" + m.folderPath + Path.DirectorySeparatorChar + path; cn = new OleDbConnection(connectString); MDBpathLabel.Text = m.folderPath + Path.DirectorySeparatorChar + path; string dir = Path.GetDirectoryName(MDBpathLabel.Text) + Path.DirectorySeparatorChar; TextWriter tw = null; if (!File.Exists(dir + "mapping.log")) { File.Create(dir + "mapping.log").Dispose(); tw = new StreamWriter(dir + "mapping.log"); } else if (File.Exists(dir + "mapping.log")) { tw = new StreamWriter(dir + "mapping.log", true); } string sep = ""; for (int x = 0; x < 30; x++) { sep += '-'; } tw.WriteLine(sep); tw.WriteLine("Unique 100% matches: "); tw.WriteLine(sep); for (int k = 0; k < listaMdb.Columns.Count; ++k) { int count = exl.countColumns("A", exl.getColumnName(exl.ws.UsedRange.Columns.Count)); List <int> candCol = Enumerable.Range(0, count).ToList(); List <int> noOfMatches = Enumerable.Repeat(0, count).ToList(); foreach (var item in listaMdb.AsEnumerable()) { var pn = (string)item.ItemArray[PNordinal]; if (listaExcel.Contains(pn)) { bio[listaExcel.FindIndex(a => a == pn)] = true; index = dat.FindIndex(drow => drow[0] == pn); xmlData = dat[index]; string atr = item.ItemArray[k].ToString(); double num; //if (candCol.Count == 0) break; if (double.TryParse(atr, out num)) { double num2; for (int j = 0; j < xmlData.Count; j++) { if (double.TryParse(xmlData[j], out num2)) { if (num != num2) { candCol.Remove(j); } else { noOfMatches[j]++; } } else { candCol.Remove(j); } } } else if (atr != "") { double num2; for (int j = 0; j < xmlData.Count; j++) { if (!double.TryParse(xmlData[j], out num2) && xmlData[j] != "") { RegexOptions options = RegexOptions.None; Regex regex = new Regex("[ ]{2,}", options); // ukloni visestruke razmake i razmake na pocetku i kraju atr = regex.Replace(atr, " "); atr = atr.Trim(); // ukloni visestruke razmake i razmake na pocetku i kraju xmlData[j] = regex.Replace(xmlData[j], " "); xmlData[j] = xmlData[j].Trim(); if (!string.Equals(atr, xmlData[j], StringComparison.CurrentCultureIgnoreCase)) { candCol.Remove(j); } else { noOfMatches[j]++; } } else { candCol.Remove(j); } } } else { continue; } } else if (!listaExcel.Contains(pn)) { m.DeletePartNumber(cn, pn, MDBpathLabel.Text); listaMdb.Rows.Remove(item); continue; } } //foreach (var cand in candCol) text += cand + ","; if (candCol.Count == 1) { try { cn.Open(); } catch (InvalidOperationException except) { } string upit = "SELECT COUNT(mdb) FROM mapping WHERE mdb = '" + listaMdb.Columns[k].ColumnName + "'"; OleDbCommand cmd = new OleDbCommand(upit, cn); int exists = (int)cmd.ExecuteScalar(); if (exists == 0) { m.AddExtraMapping(imenaKolona[candCol[0]], listaMdb.Columns[k].ColumnName, opisKolona[candCol[0]], cn); } //MessageBox.Show("Mapirao " + imenaKolona[candCol[0]]+" => "+" "+listaMdb.Columns[k]); OutputTextbox.Text += "MDB: " + listaMdb.Columns[k] + " => " + "Excel: " + imenaKolona[candCol[0]] + "\r\n"; tw.WriteLine("MDB: " + listaMdb.Columns[k] + " => " + "Excel: " + imenaKolona[candCol[0]]); usedColumn[candCol[0]] = true; continue; } // SUMNJIVO mapiranje listBox2MDB.Items.Add(listaMdb.Columns[k].ColumnName); string text = listaMdb.Columns[k].ColumnName + " => "; foreach (var cand in candCol) { text += imenaKolona[cand] + ", "; } int cnt = listaMdb.Rows.Count; text += "\n"; string mdbCol = listaMdb.Columns[k].ColumnName; try { results.Add(mdbCol, new Dictionary <string, double>()); } catch { } for (int j = 0; j < count; j++) { if (Math.Round(((double)noOfMatches[j] / cnt), 3) > 0.0) { try { results[mdbCol].Add(imenaKolona[j], (double)noOfMatches[j] / cnt); } catch { } text += imenaKolona[j] + ": " + Math.Round(((double)noOfMatches[j] / cnt), 3) + "\n"; } } text += listaMdb.Rows.Count; //MessageBox.Show(text); } for (int z = 0; z < imenaKolona.Count; z++) { if (usedColumn[z] == false) { bool empty = true; foreach (var row in listaMdb.AsEnumerable()) { var pn = (string)row.ItemArray[PNordinal]; index = dat.FindIndex(drow => drow[0] == pn); List <string> xmlData = dat[index]; if (xmlData[z] != "") { empty = false; break; } } if (!empty) { listBoxExcel.Items.Add(imenaKolona[z]); } else { emptyColumn[z] = true; } } } tw.WriteLine(sep); tw.WriteLine("User mapping: "); tw.WriteLine(sep); tw.Close(); refreshStatusLabel(); }
private void AddNewResidentButton_Clicked(object sender, EventArgs e) { //clear the output textbox OutputTextbox.Clear(); bool IsOk = true; //check if the name texbox is empty if (String.IsNullOrEmpty(NameTextbox.Text)) { OutputTextbox.AppendText("ERROR: Please enter a name for this resident." + Environment.NewLine); IsOk = false; } //check for a space in the name string ischecked = NameTextbox.Text.ToString(); if (ischecked.Contains(" ") == false) { OutputTextbox.AppendText("ERROR: You need a space in between the first and the last name." + Environment.NewLine); IsOk = false; } //check if the Occupation textbox is empty if (String.IsNullOrEmpty(OccupationTextbox.Text)) { OutputTextbox.AppendText("ERROR: Please enter a occupation for this resident." + Environment.NewLine); IsOk = false; } //compare datetimes DateTime dateselected = BirthdayPicker.Value; int result = DateTime.Compare(dateselected, DateTime.Now); if (result > 0) { OutputTextbox.AppendText("ERROR: Birthdays cannot be defined from future dates." + Environment.NewLine); IsOk = false; } //check if the residence combobox is empty if (string.IsNullOrEmpty(ResidenceCombobox.Text)) { OutputTextbox.AppendText("ERROR: Please select a residence for this new resident to reside at." + Environment.NewLine); IsOk = false; } //check for invalid text in combobox if (ResidenceCombobox.Text.Contains("House") == true || ResidenceCombobox.Text.Contains("Apartment") == true || ResidenceCombobox.Text.Contains("-----------------") == true) { OutputTextbox.AppendText("ERROR: Please select a valid item in the combobox." + Environment.NewLine); IsOk = false; } if (IsOk) { if (FindPersonId(currentCommunity, NameTextbox.Text.Split(' ')[0], (ushort)(DateTime.Now.Year - dateselected.Year), OccupationTextbox.Text) != 99999) { OutputTextbox.Text = string.Format("{0} already exist.", NameTextbox.Text); } else { ComunityListBoxClear(); //add function AddToProperty(currentCommunity); } } }