private void getButton_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection sel = grid.SelectedRows; if (sel == null || sel.Count == 0) { if (MessageBox.Show("Do you want an allocation for every group?", "No selection", MessageBoxButtons.YesNo) == DialogResult.No) { MessageBox.Show("Then you must first select the group(s) you want."); return; } // Go through each group, getting an allocation for each one // ... even if it already has one? m_IdMan.GetAllocation(); } else { foreach (DataGridViewRow row in sel) { IdGroup g = (IdGroup)row.Cells["dgcGroupName"].Value; g.GetAllocation(false); // no announcement } } RefreshList(); SetChanged(); }
private void textBox_correo_buscar_TextChanged(object sender, EventArgs e) { if (textBox_correo_buscar.TextLength > 3) { //general = Persistencia.SentenciasSQL.select(SentenciasSQL.SQL[1]); busqueda = general; DataTable telefonos = Persistencia.SentenciasSQL.select("SELECT ctos_detemail.IdEntidad,ctos_detemail.Descripcion, ctos_detemail.Email FROM ctos_detemail WHERE (((ctos_detemail.Email) Like '%" + textBox_correo_buscar.Text + "%')) GROUP BY ctos_detemail.IdEntidad"); var query = from tbl1 in busqueda.AsEnumerable() join tbl2 in telefonos.AsEnumerable() on tbl1["IDEntidad"] equals tbl2["IdEntidad"] group tbl1 by tbl1.Field <int>("IDEntidad") into IdGroup let row = IdGroup.First() select new { ID = IdGroup.Key, Field1 = row["Entidad"], Field2 = row["Email"], Field3 = row["Telefono"] }; DataTable newTable = new DataTable(); newTable.Columns.Add("IDEntidad", typeof(int)); newTable.Columns.Add("Entidad", typeof(string)); newTable.Columns.Add("Email", typeof(string)); newTable.Columns.Add("Telefono", typeof(string)); foreach (var rowInfo in query) { newTable.Rows.Add(rowInfo.ID, rowInfo.Field1, rowInfo.Field2, rowInfo.Field3); } dataGridView1.DataSource = newTable; dataGridView1.Columns[0].Width = 50; dataGridView1.Columns[1].Width = 400; dataGridView1.Columns[2].Width = 250; dataGridView1.Columns[3].Width = 100; } else { dataGridView1.DataSource = general; dataGridView1.Columns[4].Visible = false; dataGridView1.Columns[2].Visible = false; dataGridView1.Columns[5].Visible = false; //ajustarDatagrid(); } }
public override string ToString() { string result = ""; result += "Filename: " + Filename + "\r\n"; result += "ContentType: " + ContentType + "\r\n"; result += "IdUser: "******"\r\n"; result += "IsPublic: " + IsPublic + "\r\n"; result += "IdGroup: " + (IdGroup.HasValue ? IdGroup.ToString() : "null") + "\r\n"; result += "IdFolder: " + (IdFolder.HasValue ? IdFolder.ToString() : "null") + "\r\n"; result += "CreationDate: " + CreationDate + "\r\n"; result += "ModificationDate: " + ModificationDate; return(result); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="obj">The object to compare with the current object.</param> /// <returns>Boolean true if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(object obj) { if (obj == null) { return(false); } Exam exam = obj as Exam; if (exam == null) { return(false); } return((Date.Equals(exam.Date) && IdSubject.Equals(exam.IdSubject) && IdGroup.Equals(exam.IdGroup) && Type.Equals(exam.Type)) && NumberOfSession.Equals(exam.NumberOfSession)); }
private void grid_DoubleClick(object sender, EventArgs e) { // Return if more than one thing is selected (how we got a // double-click message is therefore a bit odd). DataGridViewSelectedRowCollection sel = grid.SelectedRows; if (sel == null || sel.Count != 1) { return; } // Make an allocation for the selected group. IdGroup g = (IdGroup)sel[0].Cells["dgcGroupName"].Value; g.GetAllocation(false); // no announcement RefreshList(); SetChanged(); }
private void textBox_telefono_buscar_KeyPress(object sender, KeyPressEventArgs e) { if (textBox_telefono_buscar.TextLength > 0) { busqueda = general; DataTable telefonos = Persistencia.SentenciasSQL.select("SELECT ctos_dettelf.IdEntidad,ctos_dettelf.Telefono FROM ctos_dettelf WHERE (((ctos_dettelf.Telefono) Like '%" + textBox_telefono_buscar.Text + "%')) GROUP BY ctos_dettelf.IdEntidad;"); var query = from tbl1 in busqueda.AsEnumerable() join tbl2 in telefonos.AsEnumerable() on tbl1["IDEntidad"] equals tbl2["IdEntidad"] group tbl1 by tbl1.Field <int>("IDEntidad") into IdGroup let row = IdGroup.First() select new { ID = IdGroup.Key, Field1 = row["Entidad"], Field2 = row["Email"], Field3 = row["Telefono"] }; DataTable newTable = new DataTable(); newTable.Columns.Add("ID", typeof(int)); newTable.Columns.Add("Entidad", typeof(string)); newTable.Columns.Add("Email", typeof(string)); newTable.Columns.Add("Telefono", typeof(string)); foreach (var rowInfo in query) { newTable.Rows.Add(rowInfo.ID, rowInfo.Field1, rowInfo.Field2, rowInfo.Field3); } dataGridView1.DataSource = newTable; dataGridView1.Columns[0].Width = 50; dataGridView1.Columns[1].Width = 400; dataGridView1.Columns[2].Width = 250; dataGridView1.Columns[3].Width = 100; } else { dataGridView1.DataSource = null; } }
public void InitializePlaceholders() { List <Object> Temp = new List <Object>(); IEnumerable <Object> SortedContents; switch (Rucksack.SortProperty) { case SortingProperty.Time: SortedContents = Rucksack.Contents; break; case SortingProperty.Name: SortedContents = Rucksack.Contents.OrderBy(x => x.DisplayName); break; case SortingProperty.Id: SortedContents = Rucksack.Contents.OrderBy(x => x.bigCraftable.Value).ThenBy(x => x.ParentSheetIndex); break; case SortingProperty.Category: //SortedContents = Rucksack.Contents.OrderBy(x => x.getCategorySortValue()); SortedContents = Rucksack.Contents.OrderBy(x => x.getCategoryName()); break; case SortingProperty.Quantity: SortedContents = Rucksack.Contents.OrderBy(x => x.Stack); break; case SortingProperty.SingleValue: SortedContents = Rucksack.Contents.OrderBy(x => ItemBag.GetSingleItemPrice(x)); break; case SortingProperty.StackValue: SortedContents = Rucksack.Contents.OrderBy(x => ItemBag.GetSingleItemPrice(x) * x.Stack); break; case SortingProperty.Similarity: //Possible TODO: Maybe SortingProperty.Similarity shouldn't exist - maybe it should just be a "bool GroupBeforeSorting" //that only groups by ItemId (and maybe also sorts by Quality after). Then the grouping can be applied to any of the other sorting properties. //So it could just be a togglebutton to turn on/off like the Autofill Toggle SortedContents = Rucksack.Contents .OrderBy(Item => Item.getCategoryName()).GroupBy(Item => Item.getCategoryName()) // First sort and group by CategoryName .SelectMany( CategoryGroup => CategoryGroup.GroupBy(Item => Item.ParentSheetIndex) // Then Group by item Id .SelectMany(IdGroup => IdGroup.OrderBy(y => y.Quality)) // Then sort by Quality ); break; default: throw new NotImplementedException(string.Format("Unexpected SortingProperty: {0}", Rucksack.SortProperty.ToString())); } if (Rucksack.SortOrder == SortingOrder.Descending) { SortedContents = SortedContents.Reverse(); } //Possible TODO Add filtering? //For EX: if you only wanted to show Fish, //SortedContents = SortedContents.Where(x => x.Category == <WhateverTheIdIsForFishCategory>); TempVisualFeedback = new Dictionary <Object, DateTime>(); foreach (Object Item in SortedContents) { bool WasRecentlyModified = Bag.RecentlyModified.TryGetValue(Item, out DateTime ModifiedTime); int NumSlots = (Item.Stack - 1) / Rucksack.MaxStackSize + 1; int RemainingQty = Item.Stack; for (int i = 0; i < NumSlots; i++) { Object Copy = ItemBag.CreateCopy(Item); ItemBag.ForceSetQuantity(Copy, Math.Min(RemainingQty, Rucksack.MaxStackSize)); Temp.Add(Copy); RemainingQty -= Copy.Stack; if (WasRecentlyModified) { TempVisualFeedback.Add(Copy, ModifiedTime); } } } this.PlaceholderItems = Temp.AsReadOnly(); }
public static void Main(string[] args) { var item1 = new IdGroup { Id = 2, Messages = new List <Message>() }; var item2 = new IdGroup { Id = 45, Messages = new List <Message>() }; var item3 = new IdGroup { Id = 36, Messages = new List <Message>() }; var item4 = new IdGroup { Id = 8, Messages = new List <Message>() }; var message1 = new Message { Id = 3, IdGroup = item1 }; var message2 = new Message { Id = 7, IdGroup = item1 }; var message3 = new Message { Id = 9, IdGroup = item1 }; item1.Messages.Add(message1); item1.Messages.Add(message2); item1.Messages.Add(message3); var message4 = new Message { Id = 4, IdGroup = item2 }; var message5 = new Message { Id = 10, IdGroup = item2 }; var message6 = new Message { Id = 76, IdGroup = item2 }; item2.Messages.Add(message4); item2.Messages.Add(message5); item2.Messages.Add(message6); var message7 = new Message { Id = 6, IdGroup = item3 }; var message8 = new Message { Id = 32, IdGroup = item3 }; item3.Messages.Add(message7); item3.Messages.Add(message8); var message9 = new Message { Id = 11, IdGroup = item4 }; var message10 = new Message { Id = 16, IdGroup = item4 }; var message11 = new Message { Id = 19, IdGroup = item4 }; var message12 = new Message { Id = 77, IdGroup = item4 }; item4.Messages.Add(message9); item4.Messages.Add(message10); item4.Messages.Add(message11); item4.Messages.Add(message12); List <IdGroup> items = new List <IdGroup> { item1, item2, item3, item4 }; List <Message> messages = new List <Message> { message1, message2, message3, message4, message5, message6, message7, message8, message9, message10, message11, message12 }; Dictionary <int, int> lastMessagesPerItem = new Dictionary <int, int> { { 2, 3 }, { 45, 10 }, { 36, 6 }, { 8, 11 } }; var result = SynchronizedChatMessages(messages, lastMessagesPerItem); var discard = Console.ReadKey(); }
public DataSet UpdateBatchImageOnImageServerDatabase(int BatchId, DataSet dsDocumentScans) { String _strImageDatabaseConnectionString = ""; SqlDataAdapter objSqlDataAdapterImages = null; SqlCommandBuilder objSqlCommandBuilderImages = null; SqlConnection sqlConnectionDxImages = null; SqlCommand objSqlCommandImages = null; SqlTransaction objSqlTransactionImages = null; DataTable objectDataTable = null; string _SqlQuery = ""; // DataSet dsDocumentScans = decom(data); //DecompressData(data); //DataSet dsnew = decom(data); try { //if (ImageRecordId != 0) //In Case ImageRecordId > 0 then its case of records Updation only //{ _strImageDatabaseConnectionString = System.Configuration.ConfigurationManager.AppSettings.Get("ImageDatabaseConnectionString"); if (_strImageDatabaseConnectionString == "" || _strImageDatabaseConnectionString == null) { throw new Exception("Error opening connection for Image DatabaseConfigurationName"); } sqlConnectionDxImages = new SqlConnection(_strImageDatabaseConnectionString); // objSqlCommandImages.CommandTimeout = 1000; sqlConnectionDxImages.Open(); objSqlTransactionImages = null; objSqlTransactionImages = sqlConnectionDxImages.BeginTransaction(); var result = from r in dsDocumentScans.Tables["ImageRecordItems"].AsEnumerable() group r by r.Field <int>("ImageRecordId") into IdGroup let row = IdGroup.First() select new { ImageRecordId = row.Field <int>("ImageRecordId"), }; string imageId = string.Empty; bool flag = true; foreach (var r in result) { if (flag == true) { flag = false; } else { imageId += ","; } imageId += Convert.ToString(r.ImageRecordId); } string scannedtype = "S"; // Convert.ToString(dsDocumentScans.Tables["ImageRecords"].Rows[0]["ScannedOrUploaded"].ToString()); // _SqlQuery = "Select * from ImageRecordItems where ItemImage is not null"; _SqlQuery = "Select * from ImageRecordItems where ImageRecordId IN (" + imageId + ")"; objSqlCommandImages = new SqlCommand(_SqlQuery, sqlConnectionDxImages); objSqlDataAdapterImages = new SqlDataAdapter(objSqlCommandImages); objSqlDataAdapterImages.SelectCommand.Transaction = objSqlTransactionImages; objSqlCommandBuilderImages = new SqlCommandBuilder(objSqlDataAdapterImages); objSqlDataAdapterImages.InsertCommand = objSqlCommandBuilderImages.GetInsertCommand(); objSqlDataAdapterImages.InsertCommand.Transaction = objSqlTransactionImages; objSqlDataAdapterImages.UpdateCommand = objSqlCommandBuilderImages.GetUpdateCommand(); objSqlDataAdapterImages.UpdateCommand.Transaction = objSqlTransactionImages; objSqlDataAdapterImages.UpdateBatchSize = 20; objSqlDataAdapterImages.Update(dsDocumentScans.Tables["ImageRecordItems"]); objSqlTransactionImages.Commit(); sqlConnectionDxImages.Close(); objectDataTable = new DataTable(); objectDataTable = GetScannedBatchImagesfromDatabase(imageId); // } DataSet objDs = new DataSet(); objDs.Tables.Add(objectDataTable.Copy()); return(objDs); } catch (Exception ex) { objSqlTransaction.Rollback(); sqlConnectionDxImages.Close(); //if (_boolCommittedImagesTable == true) // DeleteImages(_strImageDatabaseConnectionString, _dsOriginalDocumentScans); return(null); //throw (ex); } finally { if (objSqlDataAdapterImages != null) { objSqlDataAdapterImages.Dispose(); } if (objSqlCommandBuilderImages != null) { objSqlCommandBuilderImages.Dispose(); } if (sqlConnectionDxImages != null) { sqlConnectionDxImages.Dispose(); } if (objSqlCommandImages != null) { objSqlCommandImages.Dispose(); } _strImageDatabaseConnectionString = null; } }