private TopTable getNewTable(float XRatio, float YRatio, string f) { TopTable Table = new TopTable(Hud) { RatioPositionX = XRatio, RatioPositionY = YRatio, HorizontalCenter = true, VerticalCenter = false, PositionFromRight = false, PositionFromBottom = false, ShowHeaderLeft = false, ShowHeaderTop = true, ShowHeaderRight = false, ShowHeaderBottom = false, DefaultCellDecorator = DefaultCellDecorator, DefaultHighlightDecorator = HighlightCellDecorator, DefaultHeaderDecorator = new TopTableCellDecorator(Hud) { TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, true), } }; Table.DefineColumns(getHeader(f).ToArray()); return(Table); }
public void FlattenTableCounters() { if (TopTable.IsRoot || !TopTable.ParentTable.IsRoot) { throw new InvalidOperationException("Table must be direct child of root table"); } TopTable.FlattenTableCountersToGlobal(); }
private void ProcessTables() { //scaling and positining var w = Hud.Window.Size.Width; var h = Hud.Window.Size.Height; var XRatio = XPosRatio; var YRatio = YPosRatio; int tablesPerLine = (int)(1.0 / Table2TableXDistance); int count = 1; //iterate floors where monsters are tracked for int maxLineCount = 0; foreach (string f in MonsterTracked.Keys.ToList()) { if (!MonsterProgression.ContainsKey(f) || !MonsterSeenCount.ContainsKey(f) || !MonsterSummonedCount.ContainsKey(f) || !MonsterKilledCount.ContainsKey(f)) { continue; } //create table for floor TopTable t = getNewTable(XRatio, YRatio, f); //fill table with each tracked monster on floor foreach (string m in MonsterProgression[f].Keys.ToList()) { string mtype = m.ToString(); string floor = f.ToString(); TopTableCell[] l = getLine(floor, mtype).ToArray(); t.AddLine( new TopTableHeader(Hud, (pos, curPos) => string.Empty) { RatioWidth = 62 / (float)Hud.Window.Size.Height, RatioHeight = CellRatioHeight, HighlightFunc = (pos, curPos) => false, //highlight empty line for new area TextAlign = align, }, l ); }//foreach-end monster //sort and add table t.SortLines((int)SortByColumn, SortDescending); Tables.Add(t); //counters and offsets maxLineCount = (t.Lines.Count > maxLineCount) ? t.Lines.Count : maxLineCount; XRatio += Table2TableXDistance; if (count % tablesPerLine == 0) //move tables to next line { XRatio = XPosRatio; YRatio = YPosRatio + CellRatioHeight * maxLineCount + Table2TableYDistance; maxLineCount = 0; } count++; }//foreach-end floor tablesProcessed = true; }
public Value GetReturnValue(TypeSymbol type) { Value assignmentTarget = _assignmentScopes.Count > 0 ? _assignmentScopes.Peek().TargetValue : null; if (assignmentTarget != null && IsTriviallyAssignableTo(type, assignmentTarget.UserType)) { return(assignmentTarget); } return(TopTable.CreateInternalValue(type)); }
private void AddClientToSelectedYearTableButton_Click(object sender, RoutedEventArgs e) { if (mMode == ClientMode.DatabaseClientsTableDuplicates || mMode == ClientMode.DatabaseClientsTableUpdateClient || mMode == ClientMode.DatabaseClientsTableAddClient) { int rowToInsert = -1; int selectedRowCount = 0; string clientID = ""; string firstName = ""; string lastName = ""; //See see if only 1 row is selected and get that row number for (int i = 0; i < mDatabaseClientsTable.Rows.Count; i++) { if (BottomTable.IsSelected(i)) { rowToInsert = i; selectedRowCount++; } } //See see if only 1 row is selected if (selectedRowCount > 1) { System.Windows.MessageBox.Show("Only Select 1 client"); return; } //See if we should insert the client into the mSelectedYear table if (rowToInsert != -1) { //Get information to display to the user for confirmation clientID = mDatabaseClientsTable.Rows[rowToInsert]["Client_ID"].ToString(); lastName = mDatabaseClientsTable.Rows[rowToInsert]["Last_Name"].ToString(); firstName = mDatabaseClientsTable.Rows[rowToInsert]["First_Name"].ToString(); //Update Access Database string insertCommand = "INSERT INTO " + Main.mSelectedYear + " (Box_Number,Client_ID) VALUES (-1," + mDatabaseClientsTable.Rows[rowToInsert]["Client_ID"] + ")"; Main.mChristmasBasketsAccessDatabase.ExecuteNonQuery(insertCommand); } //Update data grid display TopTable.Refresh(); BottomTable.Refresh(); if (rowToInsert != -1) { //Show status message box System.Windows.MessageBox.Show("Client: " + clientID + " - " + lastName + ", " + firstName + " ADDED in " + Main.mSelectedYear + " Table"); //Close the Import Helper this.Close(); } } }
private void DeleteSelectedClientButton_Click(object sender, RoutedEventArgs e) { if (mMode == ClientMode.DatabaseClientsTableDuplicates || mMode == ClientMode.DatabaseClientsTableUpdateClient || mMode == ClientMode.DatabaseClientsTableAddClient || mMode == ClientMode.DatabaseClientsTableAddClient) { int rowToDelete = -1; int selectedRowCount = 0; string clientID = ""; string firstName = ""; string lastName = ""; //See see if only 1 row is selected and get that row number for (int i = 0; i < mDatabaseClientsTable.Rows.Count; i++) { if (BottomTable.IsSelected(i)) { rowToDelete = i; selectedRowCount++; } } //See see if only 1 row is selected if (selectedRowCount > 1) { System.Windows.MessageBox.Show("Only Select 1 client"); return; } //See if we should delete the client into the Clients table if (rowToDelete != -1) { //Get information to display to the user for confirmation clientID = mDatabaseClientsTable.Rows[rowToDelete]["Client_ID"].ToString(); lastName = mDatabaseClientsTable.Rows[rowToDelete]["Last_Name"].ToString(); firstName = mDatabaseClientsTable.Rows[rowToDelete]["First_Name"].ToString(); //Update Access Database string deleteCommand = "DELETE FROM Clients WHERE Client_ID = " + mDatabaseClientsTable.Rows[rowToDelete]["Client_ID"]; Main.mChristmasBasketsAccessDatabase.ExecuteNonQuery(deleteCommand); //Update data grid source mDatabaseClientsTable.Rows.RemoveAt(rowToDelete); } //Update data grid display TopTable.Refresh(); BottomTable.Refresh(); if (rowToDelete != -1) { //Show status message box System.Windows.MessageBox.Show("Client: " + clientID + " - " + lastName + ", " + firstName + " DELETED from Clients Table"); } } }
private void OpenScope() { #if UDONSHARP_DEBUG _scopeDepth += 1; #endif ValueTable newTable = new ValueTable(Module, TopTable); TopTable.AddChildTable(newTable); _valueTableStack.Push(newTable); }
private void InitTable() { Table = new TopTable(Hud) { RatioPositionX = 0.5f, RatioPositionY = 0.2f, HorizontalCenter = true, VerticalCenter = false, PositionFromRight = false, PositionFromBottom = false, ShowHeaderLeft = true, ShowHeaderTop = true, ShowHeaderRight = false, ShowHeaderBottom = false, DefaultCellDecorator = new TopTableCellDecorator(Hud) { BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0), BorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, -1), TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, true), }, DefaultHighlightDecorator = new TopTableCellDecorator(Hud) { BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 242, 0), BorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, -1), TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, true), }, DefaultHeaderDecorator = new TopTableCellDecorator(Hud) { //BackgroundBrush = Hud.Render.CreateBrush(0, 0, 0, 0, 0), //BorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, 1), TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, true), } }; var columnCount = difficultiesData.GetLength(1); var headers = Enumerable.Range(0, columnCount).Select(x => HeaderTemplate).ToArray(); Table.DefineColumns(headers); var lineCount = difficultiesData.GetLength(0); for (var i = 0; i < lineCount; i++) { Table.AddLine( LineHeaderTemplate, LineCellsTemplate ); } }
/// <summary> /// 指定されたコマの所持数を1増やす /// </summary> /// <param name="topId"></param> public bool GetTop(int topId) { TopTable topTable = topTableList.Find(top => top.Id == topId); /* コマは5つ以上持てないようにする */ if (topDic[topId] >= 5) { return(false); } //float値を登録 SetPossessingItemsIntVal(topTable.Page, topTable.Digit); //リスト値を登録 topDic[topId]++; return(true); }
public override void Load(IController hud) { base.Load(hud); Table = new TopTable(Hud) { RatioPositionX = 0.5f, RatioPositionY = 0.03f, HorizontalCenter = true, VerticalCenter = false, PositionFromRight = false, PositionFromBottom = false, ShowHeaderLeft = false, ShowHeaderTop = true, ShowHeaderRight = false, ShowHeaderBottom = false, DefaultCellDecorator = new TopTableCellDecorator(Hud) { BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0), BorderBrush = Hud.Render.CreateBrush(255, 70, 56, 42, 1.5f), TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, false, false, false), }, DefaultHighlightDecorator = new TopTableCellDecorator(Hud) { BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 242, 0), BorderBrush = Hud.Render.CreateBrush(255, 70, 56, 42, 1.5f), TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, false, false, false), }, DefaultHeaderDecorator = new TopTableCellDecorator(Hud) { BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0), BorderBrush = Hud.Render.CreateBrush(255, 70, 56, 42, 1.5f), TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, false, false, true), } }; DefineColumns(); }
private void InitTable() { Table = new TopTable(Hud) { RatioPositionX = 0.5f, RatioPositionY = 0.2f, HorizontalCenter = true, VerticalCenter = false, PositionFromRight = false, PositionFromBottom = false, ShowHeaderLeft = true, ShowHeaderTop = true, ShowHeaderRight = false, ShowHeaderBottom = false, DefaultCellDecorator = new TopTableCellDecorator(Hud) { BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0), BorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, -1), TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, true), }, DefaultHighlightDecorator = new TopTableCellDecorator(Hud) { BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 242, 0), BorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, -1), TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, true), }, DefaultHeaderDecorator = new TopTableCellDecorator(Hud) { //BackgroundBrush = Hud.Render.CreateBrush(0, 0, 0, 0, 0), //BorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, 1), TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, true), } }; Table.DefineColumns( new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioHeight = 22 / 1080f, // define only once on first column, value on others will be ignored RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, }, new TopTableHeader(Hud, (pos, curPos) => GetColumnHeaderText(pos)) { RatioWidth = 0.075f, HighlightFunc = (pos, curPos) => HighlightColumn(pos), TextAlign = HorizontalAlign.Center, } ); for (var i = 0; i < 13; i++) { Table.AddLine( new TopTableHeader(Hud, (pos, curPos) => GetLineHeaderText(pos)) { RatioWidth = 62 / 1080f, // define only once on first line, value on other will be ignored RatioHeight = 22 / 1080f, HighlightFunc = (pos, curPos) => false, TextAlign = HorizontalAlign.Right, HighlightDecorator = new TopTableCellDecorator(Hud) { BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0), BorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, -1), TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, true, false, true), }, CellHighlightDecorator = new TopTableCellDecorator(Hud) { BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0), BorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, -1), TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, true, false, true), }, }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center }, new TopTableCell(Hud, (line, column, lineSorted, columnSorted) => GetCellText(line, column)) { TextAlign = HorizontalAlign.Center } ); } }
public Value GetUserValue(Symbol valueSymbol) { return(TopTable.GetUserValue(valueSymbol)); }
public Value CreateGlobalInternalValue(TypeSymbol type) { return(TopTable.CreateGlobalInternalValue(type)); }
private void AddSelectedClientToClientsAndSelectedYearTableButton_Click(object sender, RoutedEventArgs e) { int rowToAdd = -1; int selectedRowCount = 0; string clientID = ""; string firstName = ""; string lastName = ""; if (mMode == ClientMode.DatabaseClientsTableAddClient) { //Check for null values for (int i = 0; i < mExcelClientsTable.Rows.Count; i++) { if (TopTable.IsSelected(i)) { rowToAdd = i; selectedRowCount++; } } //Add the record into the Clients Table //See see if only 1 row is selected if (selectedRowCount > 1) { System.Windows.MessageBox.Show("Only Select 1 client"); return; } //See if we should add the client to the Clients table if (rowToAdd != -1) { //Check for null values foreach (DataColumn column in mExcelClientsTable.Columns) { if (mExcelClientsTable.Rows[rowToAdd][column.ColumnName].ToString() == "") { mExcelClientsTable.Rows[rowToAdd][column.ColumnName] = "null"; } } //Update Access Database string insertCommand = "INSERT INTO Clients (Last_Name,First_Name,Middle_Name,Title,Address_Number,Street_Address,City,Zipcode,Phone,Organization,Directions,Instructions,Year_Last_Delivered_To)" + " VALUES (" + "'" + mExcelClientsTable.Rows[rowToAdd]["Last_Name"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["First_Name"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Middle_Name"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Title"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Address_Number"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Street_Address"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["City"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Zipcode"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Phone"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Organization"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Directions"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Instructions"].ToString() + "'," + "'" + mExcelClientsTable.Rows[rowToAdd]["Year_Last_Delivered_To"].ToString() + "')"; Main.mChristmasBasketsAccessDatabase.ExecuteNonQuery(insertCommand); //Figure out what the Client_ID was assigned string selectCommand = "SELECT * FROM Clients WHERE " + "Last_Name = '" + mExcelClientsTable.Rows[rowToAdd]["Last_Name"].ToString() + "' AND " + "First_Name = '" + mExcelClientsTable.Rows[rowToAdd]["First_Name"].ToString() + "' AND " + "Middle_Name = '" + mExcelClientsTable.Rows[rowToAdd]["Middle_Name"].ToString() + "' AND " + "Title = '" + mExcelClientsTable.Rows[rowToAdd]["Title"].ToString() + "' AND " + "Address_Number = '" + mExcelClientsTable.Rows[rowToAdd]["Address_Number"].ToString() + "' AND " + "Street_Address = '" + mExcelClientsTable.Rows[rowToAdd]["Street_Address"].ToString() + "' AND " + "City = '" + mExcelClientsTable.Rows[rowToAdd]["City"].ToString() + "' AND " + "Zipcode = '" + mExcelClientsTable.Rows[rowToAdd]["Zipcode"].ToString() + "' AND " + "Phone = '" + mExcelClientsTable.Rows[rowToAdd]["Phone"].ToString() + "' AND " + "Organization = '" + mExcelClientsTable.Rows[rowToAdd]["Organization"].ToString() + "' AND " + "Directions = '" + mExcelClientsTable.Rows[rowToAdd]["Directions"].ToString() + "' AND " + "Instructions = '" + mExcelClientsTable.Rows[rowToAdd]["Instructions"].ToString() + "' AND " + "Year_Last_Delivered_To = '" + mExcelClientsTable.Rows[rowToAdd]["Year_Last_Delivered_To"].ToString() + "'"; DataSet Client = Main.mChristmasBasketsAccessDatabase.PerformSelectQuery(selectCommand, "Clients"); if (Client != null) { //Get the record information to display to the user clientID = Client.Tables[0].Rows[0]["Client_ID"].ToString(); lastName = mExcelClientsTable.Rows[rowToAdd]["Last_Name"].ToString(); firstName = mExcelClientsTable.Rows[rowToAdd]["First_Name"].ToString(); System.Windows.MessageBox.Show("Client: " + clientID + " - " + lastName + ", " + firstName + " ADDED in Clients Table"); //Copy Record over into mDatabaseClientsTable mDatabaseClientsTable.Rows.Add(); foreach (DataColumn column in mExcelClientsTable.Columns) { mDatabaseClientsTable.Rows[0][column.ColumnName] = mExcelClientsTable.Rows[0][column.ColumnName]; } mDatabaseClientsTable.Rows[0]["Client_ID"] = clientID; //Insert the record to the Table string insertCommandTwo = "INSERT INTO " + Main.mSelectedYear + " (Box_Number,Client_ID) VALUES (-1," + clientID + ")"; Main.mChristmasBasketsAccessDatabase.ExecuteNonQuery(insertCommandTwo); //Show status message box System.Windows.MessageBox.Show("Client: " + clientID + " - " + lastName + ", " + firstName + " ADDED in " + Main.mSelectedYear + " Table"); //Close the Import Helper this.Close(); } TopTable.Refresh(); BottomTable.Refresh(); } } }
private void UpdateClientInformationButton_Click(object sender, RoutedEventArgs e) { if (mMode == ClientMode.DatabaseClientsTableDuplicates || mMode == ClientMode.DatabaseClientsTableUpdateClient || mMode == ClientMode.DatabaseClientsTableAddClient) { int rowToUpdate = -1; int selectedRowCount = 0; string clientID = ""; string firstName = ""; string lastName = ""; //See see if only 1 row is selected and get that row number for (int i = 0; i < mDatabaseClientsTable.Rows.Count; i++) { if (BottomTable.IsSelected(i)) { rowToUpdate = i; selectedRowCount++; } } //See see if only 1 row is selected if (selectedRowCount > 1) { System.Windows.MessageBox.Show("Only Select 1 client"); return; } //See if we should update the client in the Clients table if (rowToUpdate != -1) { //Get information to display to the user for confirmation clientID = mDatabaseClientsTable.Rows[rowToUpdate]["Client_ID"].ToString(); lastName = mDatabaseClientsTable.Rows[rowToUpdate]["Last_Name"].ToString(); firstName = mDatabaseClientsTable.Rows[rowToUpdate]["First_Name"].ToString(); //Check for null values foreach (DataColumn column in mDatabaseClientsTable.Columns) { if (mDatabaseClientsTable.Rows[rowToUpdate][column.ColumnName].ToString() == "") { mDatabaseClientsTable.Rows[rowToUpdate][column.ColumnName] = "null"; } } string updateCommand = "UPDATE Clients SET Last_Name = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Last_Name"].ToString() + "', " + "First_Name = '" + mDatabaseClientsTable.Rows[rowToUpdate]["First_Name"].ToString() + "', " + "Middle_Name = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Middle_Name"].ToString() + "', " + "Title = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Title"].ToString() + "', " + "Address_Number = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Address_Number"].ToString() + "', " + "Street_Address = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Street_Address"].ToString() + "', " + "City = '" + mDatabaseClientsTable.Rows[rowToUpdate]["City"].ToString() + "', " + "Zipcode = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Zipcode"].ToString() + "', " + "Phone = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Phone"].ToString() + "', " + "Organization = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Organization"].ToString() + "', " + "Directions = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Directions"].ToString() + "', " + "Instructions = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Instructions"].ToString() + "', " + "Year_Last_Delivered_To = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Year_Last_Delivered_To"].ToString() + "'" + " WHERE Client_ID = " + mDatabaseClientsTable.Rows[rowToUpdate]["Client_ID"].ToString(); Main.mChristmasBasketsAccessDatabase.ExecuteNonQuery(updateCommand); } //Update data grid display TopTable.Refresh(); BottomTable.Refresh(); if (rowToUpdate != -1) { //Show Status message box System.Windows.MessageBox.Show("Client: " + clientID + " - " + lastName + ", " + firstName + " UPDATED in Clients Table"); } } }