public void AddColors() { var listColorsResponse = client.ListColors(); if (listColorsResponse.Result == 1 && listColorsResponse.Colors.Count > 0) { foreach (var listColor in listColorsResponse.Colors) { Color color = ColorService.GetColor(listColor.ColorName); if (color == null || color.ColorID == 0) { color = new Color() { Name = listColor.ColorName, PrintAuraID = listColor.ColorId }; ColorService.AddColor(color); } } } }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteColor") { int colorId = SQLDataHelper.GetInt(e.CommandArgument); if (!ColorService.IsColorUsed(colorId)) { ColorService.DeleteColor(colorId); } else { MsgError(string.Format(Resource.Admin_ColorsDictionary_CantDelete, colorId)); } } if (e.CommandName == "AddColor") { try { GridViewRow footer = grid.FooterRow; int temp; var pic = (FileUpload)footer.FindControl("fuColorPicrure"); var a = pic; int.TryParse(((TextBox)footer.FindControl("txtNewSortOrder")).Text, out temp); if (string.IsNullOrEmpty(((TextBox)footer.FindControl("txtNewName")).Text)) { grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ffcccc"); return; } if (!IsValidColorCode(((TextBox)footer.FindControl("txtNewColorCode")).Text)) { grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ffcccc"); return; } if (ColorService.AddColor(new Color { ColorName = ((TextBox)footer.FindControl("txtNewName")).Text.Trim(), ColorCode = ((TextBox)footer.FindControl("txtNewColorCode")).Text.Trim(), SortOrder = temp }) != 0) { grid.ShowFooter = false; } } catch (Exception ex) { Debug.LogError(ex); } } if (e.CommandName == "CancelAdd") { grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ccffcc"); grid.ShowFooter = false; } }