internal void AssignReceived(SyncBlockState newState) { _Welding = newState.Welding; _NeedWelding = newState.NeedWelding; _CurrentWeldingBlock = newState.CurrentWeldingBlock; _Grinding = newState.Grinding; _NeedGrinding = newState.NeedGrinding; _CurrentGrindingBlock = newState.CurrentGrindingBlock; MissingComponents.Clear(); foreach (var item in newState.MissingComponentsSync) { MissingComponents.Add(item.Component, item.Amount); } PossibleWeldTargets.Clear(); foreach (var item in newState.PossibleWeldTargetsSync) { PossibleWeldTargets.Add(new TargetBlockData(SyncBlockId.GetSlimBlock(item.Block), item.Distance)); } PossibleGrindTargets.Clear(); foreach (var item in newState.PossibleGrindTargetsSync) { PossibleGrindTargets.Add(new TargetBlockData(SyncBlockId.GetSlimBlock(item.Block), item.Distance)); } Changed = true; }
public void FilterRemainingComponets() { using (SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString())) { SqlCommand query1 = new SqlCommand(@"exec Get_AllComponentsByReceptId @ReceptID;", conn1); query1.Parameters.AddWithValue("@ReceptID", recepie.ReceptId); conn1.Open(); SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(query1); DataTable dataTable1 = new DataTable(); sqlDataAdapter1.Fill(dataTable1); foreach (DataRow row1 in dataTable1.Rows) { Components c = new Components { ComponentId = int.Parse(row1[0].ToString()), ReceptId = int.Parse(row1[1].ToString()), ComponentName = row1[2].ToString(), ComponentAmount = int.Parse(row1[3].ToString()) }; if (LoginWindow.CurrentUser.Username == "Admin") { c.CanAddToCart = false; } if (LoginWindow.CurrentUser.Username != "Admin") { c.CanAddToCart = true; } bool contains = false; foreach (Components item in UserHaveComponents) { if (item.ComponentName == c.ComponentName) { contains = true; break; } } if (!contains) { MissingComponents.Add(c); } } } }