protected void bindInsertPage(int _helpPageID) { int hpID = Convert.ToInt32(Server.HtmlEncode(Request.QueryString["hp"])); SqlConnection conn; SqlCommand comm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("SELECT helpPageName, content FROM helpPages WHERE helpPageID=@helpPageID", conn); comm.Parameters.Add("@helpPageID", SqlDbType.Int); comm.Parameters["@helpPageID"].Value = hpID; try { conn.Open(); reader = comm.ExecuteReader(); reader.Read(); labelPageTitle.Text = "<h3>" + reader["helpPageName"].ToString() + "</h3>"; labelPageContent.Text = reader["content"].ToString(); reader.Close(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error loading help page content: [ " + ex.Message + " ]", labelInsertError); } finally { conn.Close(); } }
public void showMessage(string message, string title) { messageBox msgBox = new messageBox(message, title); msgBox.Owner = this; msgBox.ShowDialog(); }
protected void bindHelpTopicsGrid() { SqlConnection conn; SqlCommand comm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("SELECT * FROM helpTopics", conn); try { conn.Open(); reader = comm.ExecuteReader(); repeaterHelpTopics.DataSource = reader; repeaterHelpTopics.DataBind(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error loading help topics: [" + ex.Message + " ] ", labelError); } finally { conn.Close(); } }
// function to bind help topics to new help page drop down menu protected void bindHelpTopicDDL() { SqlConnection conn; SqlCommand comm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("SELECT helpTopicID, name FROM helpTopics ORDER BY helpTopicID ASC", conn); try { conn.Open(); reader = comm.ExecuteReader(); dropDownHelpTopics.DataSource = reader; dropDownHelpTopics.DataTextField = "name"; dropDownHelpTopics.DataValueField = "helpTopicID"; dropDownHelpTopics.DataBind(); reader.Close(); } catch (SqlException ex) { labelError.Visible = true; messageBox box = new messageBox("error", "There has been an error binding drop down list: [ " + ex.Message + " ]", labelError); } finally { conn.Close(); } }
// function to load selected help page info protected void bindSelectedHelpPage() { string helpPageID = HttpContext.Current.Server.HtmlEncode(Request.QueryString["ID"].ToString()); SqlConnection conn; SqlCommand comm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("SELECT helpPages.helpPageID, helpPages.helpTopicID, helpPages.helpPageName, helpPages.content, helpPages.sortOrder, helpTopics.[name] " + "FROM helpTopics " + "JOIN helpPages on helpTopics.helpTopicID = helpPages.helpTopicID WHERE helpPages.helpPageID=" + helpPageID.ToString() + "", conn); try { conn.Open(); reader = comm.ExecuteReader(); reader.Read(); textBoxSortOrder.Text = reader["sortOrder"].ToString(); dropDownHelpTopics.SelectedValue = reader["helpTopicID"].ToString(); textBoxHelpPageName.Text = reader["helpPageName"].ToString(); htmlEditorEditHelp.Content = reader["content"].ToString(); reader.Close(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error loading page: [ " + ex.Message + " ]", labelError); } finally { conn.Close(); } }
private bool login() { if (DataBase.SqlFunctionsUsers.ExistTableDBCA(txtUser.Text)) { if (DataBase.SqlFunctionsUsers.CheckPasswordDBCA(txtUser.Text, txtSenha.Password)) { DataBase.SqlFunctionsUsers.IntoDateDBCA(txtUser.Text, DataBase.SqlFunctionsUsers.MD5Cryptography(txtSenha.Password), DataBase.SqlFunctionsUsers.GetLastValueTableDBCA(txtUser.Text, "GroupUser"), DataBase.SqlFunctionsUsers.GetLastValueTableDBCA(txtUser.Text, "Email"), "Entrou"); VariaveisGlobais.UserLogged_GS = txtUser.Text; VariaveisGlobais.GroupUserLogged_GS = DataBase.SqlFunctionsUsers.GetLastValueTableDBCA(txtUser.Text, "GroupUser"); VariaveisGlobais.PasswordLogged_GS = txtSenha.Password; if (VariaveisGlobais.GroupUserLogged_GS.Equals("Operador")) { VariaveisGlobais.NumberOfGroup_GS = 1; } else if (VariaveisGlobais.GroupUserLogged_GS.Equals("Manutenção")) { VariaveisGlobais.NumberOfGroup_GS = 2; } else if (VariaveisGlobais.GroupUserLogged_GS.Equals("Administrador")) { VariaveisGlobais.NumberOfGroup_GS = 3; } txtUser.IsEnabled = false; txtSenha.Password = ""; txtSenha.IsEnabled = false; iconLogin.Kind = MaterialDesignThemes.Wpf.PackIconKind.Logout; iconLogin.Foreground = new SolidColorBrush(Colors.Red); return(true); } else { Utilidades.messageBox inputDialog = new messageBox("Senha Incorreta", "Senha incorreta, por favor verifique e tente novamente", MaterialDesignThemes.Wpf.PackIconKind.Error, "OK", "Fechar"); inputDialog.ShowDialog(); return(false); } } else { Utilidades.messageBox inputDialog = new messageBox("Usuário não Cadastrado", "Usuário não cadastrado, por favor verifique e tente novamente", MaterialDesignThemes.Wpf.PackIconKind.Information, "OK", "Fechar"); inputDialog.ShowDialog(); return(false); } }
// Bind recommended video grid for member when selected protected void bindRecMemberGrid(int userID) { int id = userID; SqlConnection conn; SqlCommand comm; SqlCommand validateComm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); validateComm = new SqlCommand("SELECT recID FROM recommendedVideos WHERE userID=" + userID.ToString() + "", conn); comm = new SqlCommand("SELECT [videoInfo].videoName, [recommendedVideos].recID, [recommendedVideos].userID, [recommendedVideos].sortID, " + "[recommendedVideos].createdDate, [recommendedVideos].completedDate, " + "[user].firstName, [user].lastName, [user].practiceName, [user].renOrgID " + "FROM [recommendedVideos] " + "JOIN [videoInfo] on [recommendedVideos].videoId = [videoInfo].videoInfoID " + "JOIN [user] on [recommendedVideos].userID = [user].userID " + "WHERE [recommendedVideos].userID=" + id.ToString() + " ORDER BY sortID ASC", conn); try { conn.Open(); reader = validateComm.ExecuteReader(); if (!reader.Read()) { recVidsMemberGrid.Visible = false; messageBox noticeBox = new messageBox("notice", "No videos have been recommended for this member.", searchError); labelTitleInfo.Text = ""; reader.Close(); } else { recVidsMemberGrid.Visible = true; reader.Close(); reader = comm.ExecuteReader(); recVidsMemberGrid.DataSource = reader; recVidsMemberGrid.DataBind(); reader.Close(); reader = comm.ExecuteReader(); reader.Read(); labelTitleInfo.Text = "<h3>" + reader["firstName"].ToString() + reader["lastName"].ToString() + " - " + reader["practiceName"].ToString() + "</h3>"; reader.Close(); } } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error [" + ex.Message + "]", searchError); } finally { conn.Close(); } }
private void motor_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (Utilidades.VariaveisGlobais.NumberOfGroup_GS == 0) { Utilidades.messageBox inputDialog = new messageBox(Utilidades.VariaveisGlobais.faltaUsuarioTitle, Utilidades.VariaveisGlobais.faltaUsuarioMessage, MaterialDesignThemes.Wpf.PackIconKind.Error, "OK", "Fechar"); inputDialog.ShowDialog(); return; } equip.OpenWindow(); }
private bool calculaApartirPesoTotalDesejado(Utilidades.Producao producao) { bool ret = false; Double pesoDesejado = 0; //atualiza o peso total da produção Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1].pesoTotalProducao = Convert.ToSingle(txtPesoDesejado.Text); if (!String.IsNullOrEmpty(txtPesoDesejado.Text)) { if (Double.TryParse(txtPesoDesejado.Text, out pesoDesejado)) { //Calcula peso total da receita float pesoTotalReceita = 0.0f; foreach (var produtos in Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1].receita.listProdutos) { pesoTotalReceita = pesoTotalReceita += produtos.pesoProdutoReceita; } float fatorPeso = Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1].pesoTotalProducao / pesoTotalReceita; //Calcula Peso de cada produto foreach (var produtos in Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1].receita.listProdutos) { produtos.pesoProdutoDesejado = Convert.ToSingle(Math.Round(fatorPeso * produtos.pesoProdutoReceita, 2)); } ret = true; } else { inputDialog = new Utilidades.messageBox("Valor não é inteiro", "Por favor verifique se o valor pertecem aos números inteiros", MaterialDesignThemes.Wpf.PackIconKind.Error, "OK", "Fechar"); inputDialog.ShowDialog(); } } else { inputDialog = new Utilidades.messageBox("Campo Necessário", "Por favor verifique se o campo Peso Total Desejado esta vazio!", MaterialDesignThemes.Wpf.PackIconKind.Error, "OK", "Fechar"); inputDialog.ShowDialog(); } atualizaGridProdutos(); return(ret); }
/*public GameObject mainBody, rightHand, leftHand; * public GameObject getMainBody() { return mainBody; } * public GameObject getRightHand() { return rightHand; } * public GameObject getLeftHand() { return leftHand; } this doesn't work */ // Use this for initialization void Start() { messageDisplay = gameObject.AddComponent <messageBox>(); if (debugMode) { return; } List <string> choices = new List <string> { "Start default task", "Load task from file", "See tutorial" }; messageDisplay.showMessageOptions("Welcome to PAGI World! What would you like to do?", choices, new messageBox.ReturnFromMsgBox(startPromptResponder), "Welcome!"); }
private void btInformacoesEspecificacoes_Click(object sender, RoutedEventArgs e) { if (Utilidades.VariaveisGlobais.NumberOfGroup_GS < 2) { Utilidades.messageBox inputDialog = new messageBox(Utilidades.VariaveisGlobais.faltaPermissaoTitle, Utilidades.VariaveisGlobais.faltaPermissaoMessage, MaterialDesignThemes.Wpf.PackIconKind.Error, "OK", "Fechar"); inputDialog.ShowDialog(); return; } if (spConfiguracao != null) { spConfiguracao.Children.Clear(); } spConfiguracao.Children.Add(especificaoes); }
protected string buildSubHelpTopics(int topicID) { SqlConnection conn; SqlCommand comm; SqlDataReader reader; System.Text.StringBuilder sb = new System.Text.StringBuilder(); string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("SELECT helpPageID, helpPageName, sortOrder FROM helpPages WHERE helpTopicID=@helpTopicID ORDER BY sortOrder ASC", conn); comm.Parameters.Add("@helpTopicID", SqlDbType.Int); comm.Parameters["@helpTopicID"].Value = topicID; try { conn.Open(); reader = comm.ExecuteReader(); while (reader.Read()) { // build subtopic page links using string builder class sb.Append("<li class=\"subMenu\"><a href='?hp="); sb.Append(reader["helpPageID"]); sb.Append("' name=\"clickSubMenu\">"); sb.Append(reader["helpPageName"].ToString()); sb.Append("</a></li>"); } reader.Close(); reader = comm.ExecuteReader(); if (reader.Read()) { return sb.ToString(); } reader.Close(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error loading sub categories: [ " + ex.Message + " ] ", labelError); } finally { conn.Close(); } return sb.ToString(); }
// Check videos off in checkbox list when "Edit Videos" is pressed from grid //Load videos to recommended checkbox list protected void bindRecommendVideos(int templateID) { int nID = templateID; SqlConnection conn; SqlCommand comm; DataSet dataSet = new DataSet(); SqlDataReader reader; SqlDataAdapter adapter; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("SELECT videoInfoID, videoName FROM videoInfo ORDER BY videoName ASC", conn); adapter = new SqlDataAdapter("SELECT videoID FROM recommendedTemplateVids WHERE recNameID=" + nID + "", conn); adapter.Fill(dataSet, "videoInfoIDs"); try { conn.Open(); reader = comm.ExecuteReader(); recommendVidCBL.DataSource = reader; recommendVidCBL.DataTextField = "videoName"; recommendVidCBL.DataValueField = "videoInfoID"; recommendVidCBL.DataBind(); reader.Close(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error trying to bind recommended videos<br /> [" + ex.Message + "]", labelDBerror); } finally { conn.Close(); } foreach (DataRow dr in dataSet.Tables[0].Rows) { for(int i = 0; i < recommendVidCBL.Items.Count; i++) { if(Convert.ToInt32(recommendVidCBL.Items[i].Value) == Convert.ToInt32(dr["videoID"])) { recommendVidCBL.Items[i].Selected = true; } } } }
private void EscritaInformacoes(int bufferPlc_Auxiliares) { VariaveisGlobais.Buffer_PLC[bufferPlc_Auxiliares].Enable_Read = false; VariaveisGlobais.controleProducao.TempoLimpezaDosagem = Convert.ToInt32(txtTempoLimpezaDosagem.Text); VariaveisGlobais.controleProducao.TempoLimpezaMisturador = Convert.ToInt32(txtTempoLimpezaMistura.Text); VariaveisGlobais.controleProducao.TempoEstabilizacao = Convert.ToInt32(txtTempoEstabilizacao.Text); VariaveisGlobais.controleProducao.TempoPulmaoVazio = Convert.ToInt32(txtTempoPulmaoVazio.Text); writeVariables_AuxiliaresProcesso(1); inputDialog = new Utilidades.messageBox("Salvar", "Informações salvas com Sucesso!", MaterialDesignThemes.Wpf.PackIconKind.Plus, "OK", "Fechar"); inputDialog.ShowDialog(); }
private void btDiminui_Click(object sender, RoutedEventArgs e) { if (pesoTodosProdutos > 0) { pesoProdutosReceita = pesoProdutosReceita - (pesoTodosProdutos / 2); txtPesoDesejado.Text = Convert.ToString(pesoProdutosReceita); txtQtdReceita.Text = Convert.ToString(pesoProdutosReceita / pesoTodosProdutos); calculaApartirPesoTotalDesejado(Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1]); } else { inputDialog = new Utilidades.messageBox("Sem peso receita", "Por favor verifique se a receita possui produtos com peso válidos!", MaterialDesignThemes.Wpf.PackIconKind.Information, "OK", "Fechar"); inputDialog.ShowDialog(); } }
private void btManutencao_Click(object sender, RoutedEventArgs e) { if (Utilidades.VariaveisGlobais.NumberOfGroup_GS == 0) { Utilidades.messageBox inputDialog = new messageBox(Utilidades.VariaveisGlobais.faltaUsuarioTitle, Utilidades.VariaveisGlobais.faltaUsuarioMessage, MaterialDesignThemes.Wpf.PackIconKind.Error, "OK", "Fechar"); inputDialog.ShowDialog(); return; } if (spInical != null) { spInical.Children.Clear(); spInical.Children.Add(Utilidades.VariaveisGlobais.manutencao); AtualizaButton(pckManutencao); } }
private void btManualAuto_Click(object sender, RoutedEventArgs e) { if (Utilidades.VariaveisGlobais.NumberOfGroup_GS == 0) { Utilidades.messageBox inputDialog = new messageBox(Utilidades.VariaveisGlobais.faltaUsuarioTitle, Utilidades.VariaveisGlobais.faltaUsuarioMessage, MaterialDesignThemes.Wpf.PackIconKind.Error, "OK", "Fechar"); inputDialog.ShowDialog(); return; } Utilidades.VariaveisGlobais.Buffer_PLC[1].Enable_Read = false; VariaveisGlobais.controleProducao.Manual_Automatico = !VariaveisGlobais.controleProducao.Manual_Automatico; Comunicacao.Sharp7.S7.SetWordAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 18, Utilidades.Move_Bits.ControleProducaoToWord(VariaveisGlobais.controleProducao)); Utilidades.VariaveisGlobais.Buffer_PLC[1].Enable_Write = true; }
// Handle confirm button protected void confirmVideo(object sender, EventArgs e) { if (Session["videoDetailID"] == null) { messageBox box = new messageBox("error", "There has been an error please <a href='memberVideos.aspx'>Click Here</a> to try again.", errorMessage); } else { string videoInfoID = Session["videoDetailID"].ToString(); string userID = Session["userLoggedIn"].ToString(); SqlConnection conn; SqlCommand comm; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("INSERT INTO videoTracking (videoInfoID, userID, createdDate) VALUES (" + videoInfoID + ", " + userID + ", GETDATE())", conn); try { conn.Open(); comm.ExecuteNonQuery(); } catch (SqlException ex) { errorMessage.Text = "<div class=\"errorMessageSearch\">Error submitting your registration try again later, and/or change the entered data.<br /> [" + ex.Message + "]</div>"; } finally { conn.Close(); Session["confirmVideo"] = true; Response.Redirect("memberVideos.aspx"); } } }
protected void clickCancelDelete(object sender, EventArgs e) { Label tID = (Label)recVidsTemplateGrid.Rows[0].FindControl("templateIDLbl"); int templateID = Convert.ToInt32(tID.Text); bindRecTemplateGrid(templateID); panelDelete.Visible = false; messageBox box = new messageBox("notice", "Deletion has been cancelled", labelNotice); }
// bind checkbox list for new template // Load videos to recommended checkbox list protected void bindRecommendVideosNew() { SqlConnection conn; SqlCommand comm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("SELECT videoInfoID, videoName FROM videoInfo ORDER BY videoName ASC", conn); try { conn.Open(); reader = comm.ExecuteReader(); recommendVidCBL.DataSource = reader; recommendVidCBL.DataTextField = "videoName"; recommendVidCBL.DataValueField = "videoInfoID"; recommendVidCBL.DataBind(); reader.Close(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error trying to bind recommended videos<br /> [" + ex.Message + "]", labelDBerror); } finally { conn.Close(); } }
// Cancel template name delete protected void clickCancelTemplateDelete(object sender, EventArgs e) { panelDeleteTemplate.Visible = false; messageBox box = new messageBox("notice", "Deletion has been cancelled", labelNotice); ViewState["editTemplateDataSet"] = null; bindEditTemplatesGrid(); }
private void BT_confirma_Click(object sender, RoutedEventArgs e) { if (Utilidades.VariaveisGlobais.NumberOfGroup_GS == 0) { Utilidades.messageBox inputDialog = new messageBox(Utilidades.VariaveisGlobais.faltaUsuarioTitle, Utilidades.VariaveisGlobais.faltaUsuarioMessage, MaterialDesignThemes.Wpf.PackIconKind.Error, "OK", "Fechar"); inputDialog.ShowDialog(); return; } if (VariaveisGlobais.controleProducao.primeiroProdutoDosar) { VariaveisGlobais.controleProducao.primeiroProdutoDosar = false; if (DataBase.SQLFunctionsProducao.Update_IniciouDosagemProduto(VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].id, VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto].produto.id) > 0) { Utilidades.VariaveisGlobais.Buffer_PLC[1].Enable_Read = false; VariaveisGlobais.controleProducao.Dosando = true; VariaveisGlobais.controleProducao.IniciadoDosagemProduto_PLC = false; VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto].iniciouDosagem = true; //Atualiza Valores dos pesos do produto VariaveisGlobais.controleProducao.PesoDosar = VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto].pesoProdutoDesejado; VariaveisGlobais.controleProducao.PesoTolerancia = VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto].tolerancia; Comunicacao.Sharp7.S7.SetWordAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 18, Utilidades.Move_Bits.ControleProducaoToWord(VariaveisGlobais.controleProducao)); Comunicacao.Sharp7.S7.SetRealAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 26, VariaveisGlobais.controleProducao.PesoDosar); Comunicacao.Sharp7.S7.SetRealAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 30, VariaveisGlobais.controleProducao.PesoTolerancia); } else { Utilidades.messageBox inputDialog = new messageBox("Erro Update DB", "Erro ao Atualizar Produto no db, Tente novamente", MaterialDesignThemes.Wpf.PackIconKind.Error, "OK", "Fechar"); inputDialog.ShowDialog(); return; } } else { if (DataBase.SQLFunctionsProducao.Update_FinalizouDosagemProduto(VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].id, VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto].produto.id) > 0 && VariaveisGlobais.controleProducao.IniciadoDosagemProduto_PLC) { if (DataBase.SQLFunctionsProducao.Update_PesoDosado_Produto(VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].id, VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto].produto.id, VariaveisGlobais.controleProducao.Peso_Parcial_Produzindo) > 0) { VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto].pesoProdutoDosado = VariaveisGlobais.controleProducao.Peso_Parcial_Produzindo; VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto].finalizouDosagem = true; //Verifica se não é o ultimo produto if (!VariaveisGlobais.controleProducao.EncerrarDosagem) { if (DataBase.SQLFunctionsProducao.Update_IniciouDosagemProduto(VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].id, VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto + 1].produto.id) > 0) { Utilidades.VariaveisGlobais.Buffer_PLC[1].Enable_Read = false; VariaveisGlobais.controleProducao.Troca_Produto = true; VariaveisGlobais.controleProducao.Estabilizado = false; VariaveisGlobais.controleProducao.IniciadoDosagemProduto_PLC = false; VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto + 1].iniciouDosagem = true; //Atualiza Valores dos pesos do produto VariaveisGlobais.controleProducao.PesoDosar = VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto + 1].pesoProdutoDesejado; VariaveisGlobais.controleProducao.PesoTolerancia = VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].receita.listProdutos[VariaveisGlobais.controleProducao.indexProduto + 1].tolerancia; Comunicacao.Sharp7.S7.SetWordAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 18, Utilidades.Move_Bits.ControleProducaoToWord(VariaveisGlobais.controleProducao)); Comunicacao.Sharp7.S7.SetRealAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 26, VariaveisGlobais.controleProducao.PesoDosar); Comunicacao.Sharp7.S7.SetRealAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 30, VariaveisGlobais.controleProducao.PesoTolerancia); } else { return; } } else { Utilidades.VariaveisGlobais.Buffer_PLC[1].Enable_Read = false; DataBase.SQLFunctionsProducao.Update_PesoDosadoTotal(Utilidades.VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].id, VariaveisGlobais.controleProducao.Peso_Total_Produzindo); Utilidades.VariaveisGlobais.OrdensProducao[VariaveisGlobais.controleProducao.indexProducao].pesoTotalProduzido = VariaveisGlobais.controleProducao.Peso_Total_Produzindo; //Atualiza Valores dos pesos do produto VariaveisGlobais.controleProducao.PesoDosar = 0; VariaveisGlobais.controleProducao.PesoTolerancia = 0; VariaveisGlobais.controleProducao.Troca_Produto = false; VariaveisGlobais.controleProducao.Dosando = false; VariaveisGlobais.controleProducao.IniciadoDosagemProduto_PLC = false; Comunicacao.Sharp7.S7.SetWordAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 18, Utilidades.Move_Bits.ControleProducaoToWord(VariaveisGlobais.controleProducao)); Comunicacao.Sharp7.S7.SetRealAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 26, 0); Comunicacao.Sharp7.S7.SetRealAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 30, 0); VariaveisGlobais.controleProducao.EncerrarDosagem = false; } } } else { return; } } Utilidades.VariaveisGlobais.Buffer_PLC[1].Enable_Write = true; VariaveisGlobais.controleProducao.HabilitadoDosarEmManual = false; }
protected void clickDeleteAssoc(object sender, EventArgs e) { int hasRows = recVidsTemplateGrid.Rows.Count; if (hasRows > 0) { if (globalFunctions.gridLineItemChecked(recVidsTemplateGrid, "RowLevelCheckBoxT")) { panelDelete.Visible = true; messageBox deleteBox = new messageBox("notice", "Please confirm that you wish to delete selected records", labelNotice); } else { panelDelete.Visible = false; messageBox box = new messageBox("notice", "You have not selected any videos to delete", labelNotice); } } }
// Handle delete help page protected void gridViewMHP_RowDeleting(object sender, CommandEventArgs e) { int deleteHelpPageID = Convert.ToInt32(e.CommandArgument); SqlConnection conn; SqlCommand comm; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("DELETE FROM helpPages WHERE helpPageID=" + deleteHelpPageID.ToString() + "", conn); try { conn.Open(); comm.ExecuteNonQuery(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error trying to delete help page: [ " + ex.Message + " ] ", labelError); } finally { conn.Close(); ViewState["helpPagesDataSet"] = null; BindHelpPagesGrid(); } }
protected void gridViewMHT_RowUpdating(Object sender, GridViewUpdateEventArgs e) { if (gridViewMHelpTopic.EditIndex != -1) { // Get helpTopicID through the datakey and edit row index int editRowIndex = gridViewMHelpTopic.EditIndex; int helpTopicID = (int)gridViewMHelpTopic.DataKeys[editRowIndex].Values["helpTopicID"]; TextBox name = (TextBox)gridViewMHelpTopic.Rows[editRowIndex].Cells[2].FindControl("textBoxName"); string helpTopicName = name.Text; TextBox keyWords = (TextBox)gridViewMHelpTopic.Rows[editRowIndex].Cells[2].FindControl("textBoxKeyWords"); string helpTopicKeyWords = keyWords.Text; SqlConnection conn; SqlCommand comm; SqlCommand validatComm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); validatComm = new SqlCommand("SELECT name FROM helpTopics WHERE name=@helpTopicName AND helpTopicID <>" + helpTopicID.ToString() + "", conn); comm = new SqlCommand("UPDATE helpTopics SET name=@helpTopicNameEdit, keyWords=@helpKeyWords WHERE helpTopicID=" + helpTopicID.ToString() + "", conn); validatComm.Parameters.Add("@helpTopicName", SqlDbType.NVarChar, 100); validatComm.Parameters["@helpTopicName"].Value = helpTopicName; comm.Parameters.Add("@helpTopicNameEdit", SqlDbType.NVarChar, 100); comm.Parameters["@helpTopicNameEdit"].Value = helpTopicName; comm.Parameters.Add("@helpKeyWords", SqlDbType.NVarChar, 200); comm.Parameters["@helpKeyWords"].Value = helpTopicKeyWords; try { conn.Open(); reader = validatComm.ExecuteReader(); if (!reader.Read()) { reader.Close(); comm.ExecuteNonQuery(); labelNotice.Visible = false; // Close connection, clear view state, reset grid to view mode and re-bind to refresh data. conn.Close(); ViewState["helpTopicDataSet"] = null; gridViewMHelpTopic.EditIndex = -1; BindHelpTopicGrid(); } else { conn.Close(); reader.Close(); labelNotice.Visible = true; messageBox boxConflict = new messageBox("notice", "The name you are trying to use is already in use, please use a different name and try again.", labelNotice); } } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error updating record: [ " + ex.Message + " ]", labelError); } } }
protected void deleteTemplateVideo(int recordID) { int recID = recordID; SqlConnection conn; SqlCommand comm; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("DELETE FROM recommendedTemplateVids WHERE recTempVidID=" + recID.ToString() + "", conn); try { conn.Open(); comm.ExecuteNonQuery(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error [ " + ex.Message + " ]", labelDBerror); } finally { conn.Close(); } }
protected void gridViewEditTemplates_RowDeleting(object sender, GridViewDeleteEventArgs e) { int deleteIndex = e.RowIndex; GridViewRow row = (GridViewRow)gridViewEditTemplates.Rows[deleteIndex]; int templateDeleteID = (int)gridViewEditTemplates.DataKeys[deleteIndex].Values["recTempNameID"]; // Check to see if any videos are associated to template. If so show error. hiddenFieldTempID.Value = templateDeleteID.ToString(); if (checkDelete(templateDeleteID)) { labelNotice.Visible = true; panelDeleteTemplate.Visible = false; messageBox box = new messageBox("notice", "There are still videos associated to this template. You must delete them first to delete the template itself.", labelNotice); bindRecTemplateGrid(templateDeleteID); globalFunctions.resetGridBackground(gridViewEditTemplates); row.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#E1EBED"); } else { labelNotice.Visible = true; messageBox box = new messageBox("notice", "Are you sure you wish to delete this template? Once template is deleted it cannot be retrieved and must be re-created to duplicate.", labelNotice); panelDeleteTemplate.Visible = true; bindRecTemplateGrid(templateDeleteID); globalFunctions.resetGridBackground(gridViewEditTemplates); row.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#E1EBED"); } }
// Handle update link button from member's recommended videos grid protected void clickUpdateSort(object sender, EventArgs e) { // panelDelete.Visible = false; int hasRows = recVidsTemplateGrid.Rows.Count; if (hasRows > 0) { if (globalFunctions.gridLineItemChecked(recVidsTemplateGrid, "RowLevelCheckBoxT")) { Label tID = (Label)recVidsTemplateGrid.Rows[0].FindControl("templateIDLbl"); int templateID = Convert.ToInt32(tID.Text); for (int i = 0; i < recVidsTemplateGrid.Rows.Count; i++) { GridViewRow row = recVidsTemplateGrid.Rows[i]; TextBox updateSortID = (TextBox)recVidsTemplateGrid.Rows[i].FindControl("recVidSortEdit"); Label recordID = (Label)recVidsTemplateGrid.Rows[i].FindControl("recordIDLbl"); bool isChecked = ((CheckBox)row.FindControl("RowLevelCheckBoxT")).Checked; if (isChecked) { int updateSort = Convert.ToInt32(updateSortID.Text); int recID = Convert.ToInt32(recordID.Text); updateTemplateVids(recID, updateSort, templateID); } } bindRecTemplateGrid(templateID); messageBox boxSuccess = new messageBox("success", "Success, template videos have been updated", labelNotice); } else { messageBox box = new messageBox("notice", "You have not selected any videos to update.", labelNotice); } } }
// Function to create new template called by the clickSaveTemplate method above protected Int32 createNewTemplate() { SqlConnection conn; SqlCommand comm; int tempNameID; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("INSERT INTO recommendedTemplateName(templateName, createdDate, modifiedDate, templateDescription, createdBy) VALUES (@name, @date, NULL, @description, @user);SELECT SCOPE_IDENTITY();", conn); comm.Parameters.Add("@name", SqlDbType.NVarChar, 250); comm.Parameters["@name"].Value = textBoxName.Text; comm.Parameters.Add("@description", SqlDbType.NVarChar, 250); comm.Parameters["@description"].Value = textBoxDescription.Text; comm.Parameters.Add("@date", SqlDbType.NVarChar, 50); comm.Parameters["@date"].Value = DateTime.Now.ToString(); comm.Parameters.Add("@user", SqlDbType.Int); comm.Parameters["@user"].Value = Convert.ToInt32(Session["userLoggedIn"]); try { conn.Open(); int id = Convert.ToInt32(comm.ExecuteScalar()); return id; } catch (SqlException ex) { labelDBerror.Visible = true; messageBox box = new messageBox("error", "There has been an error: [ " + ex.Message + " ] ", labelDBerror); } finally { conn.Close(); } tempNameID = 0; return tempNameID; }
protected void clickConfirmDelete(object sender, EventArgs e) { Label tID = (Label)recVidsTemplateGrid.Rows[0].FindControl("templateIDLbl"); int templateID = Convert.ToInt32(tID.Text); if (globalFunctions.gridLineItemChecked(recVidsTemplateGrid, "RowLevelCheckBoxT")) { for (int i = 0; i < recVidsTemplateGrid.Rows.Count; i++) { GridViewRow row = recVidsTemplateGrid.Rows[i]; bool isChecked = ((CheckBox)row.FindControl("RowLevelCheckBoxT")).Checked; Label recordID = (Label)recVidsTemplateGrid.Rows[i].FindControl("recordIDLbl"); if (isChecked) { int recID = Convert.ToInt32(recordID.Text); deleteTemplateVideo(recID); } } bindRecTemplateGrid(templateID); panelDelete.Visible = false; messageBox successBox = new messageBox("success", "Success, videos have been deleted from template and grid has been refreshed.", labelNotice); } else { messageBox box = new messageBox("notice", "You have not selected anything to delete", labelDBerror); } bindRecommendVideos(templateID); }
private void btContinuar_Click(object sender, RoutedEventArgs e) { if (Convert.ToDouble(txtPesoDesejado.Text) < 300 && Convert.ToDouble(txtPesoDesejado.Text) > 0) { if (VariaveisGlobais.controleProducao.Producao0 == -1) { inputDialog = new Utilidades.messageBox("Confirmação", "Você tem certeza que deseja iniciar a produção? Após o inicio não poderá ser retirado a produção! ", MaterialDesignThemes.Wpf.PackIconKind.Error, "Sim", "Não"); inputDialog.ShowDialog(); if (inputDialog.DialogResult == true) { //Preenche data inicial e data final Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1].dateTimeInicioProducao = DateTime.Now; Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1].dateTimeFimProducao = DateTime.Now; //Preenche que iniciou a produção Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1].IniciouProducao = true; calculaApartirPesoTotalDesejado(Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1]); DataBase.SQLFunctionsProducao.AddProducaoBD(Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1]); Utilidades.VariaveisGlobais.Buffer_PLC[1].Enable_Read = false; VariaveisGlobais.controleProducao.Producao0 = Utilidades.VariaveisGlobais.OrdensProducao[Utilidades.VariaveisGlobais.OrdensProducao.Count - 1].id; Comunicacao.Sharp7.S7.SetDIntAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 2, VariaveisGlobais.controleProducao.Producao0); var index = Utilidades.VariaveisGlobais.OrdensProducao.FindIndex(x => x.id == VariaveisGlobais.controleProducao.Producao0); if (index != -1) { Int32 codigoReceita = Utilidades.VariaveisGlobais.OrdensProducao[index].receita.Codigo; Comunicacao.Sharp7.S7.SetDIntAt(Utilidades.VariaveisGlobais.Buffer_PLC[1].Buffer, 34, Convert.ToInt32(DataBase.SqlFunctionsReceitas.getTempoMistura(codigoReceita))); } Utilidades.VariaveisGlobais.Buffer_PLC[1].Enable_Write = true; //Verifica qual Produção esta em execução e carrega a produção DataBase.SQLFunctionsProducao.AtualizaOrdemProducaoEmExecucao(); Iniciou = true; if (this.IniciouProducao != null) { this.IniciouProducao(this, e); } } } else { inputDialog = new Utilidades.messageBox("Liberado", "Verifique se tem alguma produção na dosagem", MaterialDesignThemes.Wpf.PackIconKind.Information, "OK", "Fechar"); inputDialog.ShowDialog(); } } else { inputDialog = new Utilidades.messageBox("Liberado", "O peso está acima de 300 kg ou abaixo de 0 kg! Diminua a produção.", MaterialDesignThemes.Wpf.PackIconKind.Information, "OK", "Fechar"); inputDialog.ShowDialog(); } }
protected void clickResetSortT(object sender, EventArgs e) { if (labelTemplateID.Text == "0") { labelNotice.Visible = true; messageBox box = new messageBox("notice", "Cannot resolve request, please select template or start over.", labelNotice); } else { Label tID = (Label)recVidsTemplateGrid.Rows[0].FindControl("templateIDLbl"); int recordID = Convert.ToInt32(tID.Text); resetSortOrderT(recordID); } }
protected void clickSaveHelpTopic(object sender, EventArgs e) { SqlConnection conn; SqlCommand comm; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("INSERT INTO helpTopics (name, keyWords) VALUES(@helpTopicName, @helpKeyWords)", conn); comm.Parameters.Add("@helpTopicName", SqlDbType.NVarChar, 100); comm.Parameters["@helpTopicName"].Value = textBoxTopicName.Text; comm.Parameters.Add("@helpKeyWords", SqlDbType.NVarChar, 200); comm.Parameters["@helpKeyWords"].Value = textBoxKeyWords.Text; string insertName = HttpContext.Current.Server.HtmlEncode(textBoxTopicName.Text); if (checkHelpTopicName(insertName)) { labelNotice.Visible = true; messageBox box = new messageBox("notice", "There is already a help topic with the name you are trying to use. Please use a different name and try again.", labelNotice); } else { try { conn.Open(); comm.ExecuteNonQuery(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error: [ " + ex.Message + " ] ", labelError); } finally { conn.Close(); labelNotice.Visible = true; messageBox successBox = new messageBox("success", "Success, new help topic has been added.", labelNotice); } } }
protected void gridViewEditTemplates_RowUpdating(object sender, EventArgs e) { bool updateSuccess = false; // Get templateID through the datakey and edit row index int editRowIndex = gridViewEditTemplates.EditIndex; int templateID = (int)gridViewEditTemplates.DataKeys[editRowIndex].Values["recTempNameID"]; // Find original name to use in validation check when saving Label name = (Label)gridViewEditTemplates.Rows[editRowIndex].Cells[1].FindControl("compareName"); string compareName = name.Text; // Find edit info in the gridview control using the edit row index and cells array TextBox newTemplateName = (TextBox)gridViewEditTemplates.Rows[editRowIndex].Cells[1].FindControl("textBoxEditName"); string templateName = newTemplateName.Text; TextBox newTemplateDesc = (TextBox)gridViewEditTemplates.Rows[editRowIndex].Cells[2].FindControl("textBoxEditDescription"); string templateDesc = newTemplateDesc.Text; SqlConnection conn; SqlCommand validateComm; SqlCommand comm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("UPDATE recommendedTemplateName SET templateName=@name, modifiedDate=@date, templateDescription=@description, modifiedBy=@modifiedBy WHERE recTempNameID=@record", conn); validateComm = new SqlCommand("SELECT templateName FROM recommendedTemplateName WHERE templateName=@nameCheck", conn); //Add SQL parameters validateComm.Parameters.Add("@nameCheck", SqlDbType.NVarChar, 250); validateComm.Parameters["@nameCheck"].Value = templateName; comm.Parameters.Add("@record", SqlDbType.Int); comm.Parameters["@record"].Value = templateID; comm.Parameters.Add("@name", SqlDbType.NVarChar, 250); comm.Parameters["@name"].Value = templateName; comm.Parameters.Add("@date", SqlDbType.NVarChar, 50); comm.Parameters["@date"].Value = DateTime.Now.ToString(); comm.Parameters.Add("@description", SqlDbType.NVarChar, 250); comm.Parameters["@description"].Value = templateDesc; comm.Parameters.Add("@modifiedBy", SqlDbType.Int); comm.Parameters["@modifiedBy"].Value = Convert.ToInt32(Session["userLoggedIn"]); try { conn.Open(); reader = validateComm.ExecuteReader(); if (reader.Read()) { // Check to see if the name being updated is the same name that was there before. // Update database with row info. if (compareName == reader["templateName"].ToString()) { reader.Close(); comm.ExecuteNonQuery(); updateSuccess = true; } else { // Name already exist. updateSuccess = false; } } else { // Name does not exist and name has been modified update row. reader.Close(); comm.ExecuteNonQuery(); updateSuccess = true; } } catch(SqlException ex) { messageBox box = new messageBox("error", "There has been an error: [ " + ex.Message + " ]", labelDBerror); } finally { conn.Close(); } if (updateSuccess) { labelNotice.Visible = true; messageBox successBox = new messageBox("success", "Success, template has been updated.", labelNotice); // Set grid view back to non edit mode. gridViewEditTemplates.EditIndex = -1; //Bind data to the GridView control. bindEditTemplatesGrid(); } else { labelNotice.Visible = true; messageBox box = new messageBox("notice", "The name you are trying to use already exist for another template, please use a different name and try again.", labelNotice); } }
protected void clickSaveNewHelp(object sender, EventArgs e) { int topicID = Convert.ToInt32(dropDownHelpTopics.SelectedValue); string helpPageName = HttpContext.Current.Server.HtmlEncode(textBoxHelpPageName.Text); int sortOrder = Convert.ToInt32(textBoxSortOrder.Text); string helpPageContent = htmlEditorNewHelp.Content.ToString(); SqlConnection conn; SqlCommand comm; SqlCommand validateComm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); validateComm = new SqlCommand("SELECT helpPageName FROM helpPages WHERE helpPageName=@helpPageName", conn); comm = new SqlCommand("INSERT INTO helpPages (helpTopicID, helpPageName, content, sortOrder) VALUES(@helpTopicID, @helpPageName, @helpPageContent, @sortOrder)", conn); comm.Parameters.Add("@helpTopicID", SqlDbType.Int); comm.Parameters["@helpTopicID"].Value = topicID; comm.Parameters.Add("@helpPageName", SqlDbType.NVarChar, 100); comm.Parameters["@helpPageName"].Value = helpPageName; comm.Parameters.Add("@helpPageContent", SqlDbType.Text); comm.Parameters["@helpPageContent"].Value = helpPageContent; comm.Parameters.Add("@sortOrder", SqlDbType.Int); comm.Parameters["@sortOrder"].Value = sortOrder; validateComm.Parameters.Add("@helpPageName", SqlDbType.NVarChar, 100); validateComm.Parameters["@helpPageName"].Value = helpPageName; try { conn.Open(); reader = validateComm.ExecuteReader(); reader.Read(); string validateString = reader["helpPageName"].ToString(); reader.Close(); reader = validateComm.ExecuteReader(); if (reader.Read() && validateString != "Overview") { reader.Close(); conn.Close(); labelNotice.Visible = true; messageBox validateBox = new messageBox("notice", "There is already a help page with the name you are trying to use. Please use a new name.", labelNotice); } else { reader.Close(); comm.ExecuteNonQuery(); conn.Close(); labelNotice.Visible = true; messageBox successBox = new messageBox("success", "Success, new help page has been saved.", labelNotice); } } catch (SqlException ex) { labelError.Visible = true; messageBox box = new messageBox("error", "There has been an error saving help page: [ " + ex.Message + " ]", labelError); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { messageBox box = new messageBox("notice", "Use <b>toolbar</b> above to get started.", labelNotice); // Bind checkbox list to select videos from bindEditTemplatesGrid(); } }
protected void gridViewMHT_RowDeleting(Object sender, CommandEventArgs e) { //check to make sure that grid view is not in edit mode. if (gridViewMHelpTopic.EditIndex != -1) { labelNotice.Visible = true; messageBox box = new messageBox("notice", "You can not delete while in edit mode, please exit and try again.", labelNotice); } else { // get record id int recordID = Convert.ToInt32(e.CommandArgument); SqlConnection conn; SqlCommand comm; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("DELETE FROM helpTopics WHERE helpTopicID=" + recordID.ToString() + "", conn); try { conn.Open(); comm.ExecuteNonQuery(); } catch (SqlException ex) { labelError.Visible = true; messageBox box = new messageBox("error", "There has been an error trying to delete: [ " + ex.Message + " ] ", labelError); } finally { conn.Close(); ViewState["helpTopicDataSet"] = null; BindHelpTopicGrid(); } } }
// Reset sort order protected void resetSortOrderT(int templateID) { int sortCounter = 0; int tID = templateID; SqlConnection conn; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); DataSet dataSet = new DataSet(); SqlDataAdapter adapter; adapter = new SqlDataAdapter("SELECT recTempVidID FROM recommendedTemplateVids WHERE recNameID=" + tID.ToString() + "", conn); adapter.Fill(dataSet, "recTempIDDS"); SqlCommand setSortOrderComm; foreach (DataRow dr in dataSet.Tables[0].Rows) { sortCounter++; setSortOrderComm = new SqlCommand("UPDATE recommendedTemplateVids SET sortID=" + sortCounter.ToString() + " WHERE recTempVidID=" + dr["recTempVidID"].ToString() + "", conn); try { conn.Open(); setSortOrderComm.ExecuteNonQuery(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error: [" + ex.Message + "]", labelDBerror); } finally { conn.Close(); } } messageBox successBox = new messageBox("success", "Success, sort order has been reset", labelNotice); bindRecTemplateGrid(tID); }
protected void Page_Load(object sender, EventArgs e) { // Handle mini ribbon color change if menu item active LinkButton mpLinkButtonM = (LinkButton)Master.FindControl("membersLB"); mpLinkButtonM.ForeColor = System.Drawing.Color.White; LinkButton mpLinkButtonV = (LinkButton)Master.FindControl("videosLB"); mpLinkButtonV.ForeColor = System.Drawing.Color.White; LinkButton mpLinkButtonIS = (LinkButton)Master.FindControl("helpPagesLB"); mpLinkButtonIS.ForeColor = System.Drawing.ColorTranslator.FromHtml("#9CC5C9"); LinkButton mpLinkButtonRC = (LinkButton)Master.FindControl("recVidsLB"); mpLinkButtonRC.ForeColor = System.Drawing.Color.White; LinkButton mpLinkButtonS = (LinkButton)Master.FindControl("searchLB"); mpLinkButtonS.ForeColor = System.Drawing.Color.White; if (!IsPostBack) { //Load Intro Message messageBox box = new messageBox("notice", "Use menu bar above to get started.", labelNotice); } }
// Handle update list function for member's recommended videos grid // loop through grid find selected items // get recVidSortEdit value // update recommendedVideos table with value protected void updateTemplateVids(int recID, int ID, int templateNameID) { int recordID = recID; int sortID = ID; int name = templateNameID; SqlConnection conn; SqlCommand comm; SqlCommand updateModComm; string dt = DateTime.Now.ToString(); int modBy = Convert.ToInt32(Session["userLoggedIn"]); string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("UPDATE recommendedTemplateVids SET sortID=" + sortID.ToString() + " WHERE recTempVidID=" + recordID.ToString() + "", conn); updateModComm = new SqlCommand("UPDATE recommendedTemplateName SET modifiedDate=@date, modifiedBy=@modifiedBy WHERE recTempNameID=" + name + "", conn); updateModComm.Parameters.Add("@date", SqlDbType.NVarChar, 50); updateModComm.Parameters["@date"].Value = DateTime.Now.ToString(); updateModComm.Parameters.Add("@modifiedBy", SqlDbType.Int); updateModComm.Parameters["@modifiedBy"].Value = modBy; string debug = "UPDATE recommendedTemplateName SET modifiedDate=" + dt + ", modifiedBy=" + modBy.ToString() + " WHERE recTempNameID=" + name.ToString(); try { conn.Open(); comm.ExecuteNonQuery(); updateModComm.ExecuteNonQuery(); } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error: [" + ex.Message + "<br />" + debug + "]", labelDBerror); } finally { conn.Close(); } }
// Handle save button protected void clickSaveTemplate(object sender, EventArgs e) { if(checkTempName(textBoxName.Text.ToString())) { messageBox box = new messageBox("notice", "The template name you are trying to use already exist, please use a different name to proceed.", labelNotice); } else { if (videosPresent()) { int templateID = createNewTemplate(); int[] videoIDs = new int[recommendVidCBL.Items.Count]; int sortOrder = 0; bool newRecord = false; SqlConnection conn; SqlCommand comm; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); //Loop through video checkbox list to find checked videos //Add each checked video to database under for (int i = 0; i < recommendVidCBL.Items.Count; i++) { videoIDs[i] = Convert.ToInt32(recommendVidCBL.Items[i].Value); if (recommendVidCBL.Items[i].Selected) { sortOrder++; comm = new SqlCommand("INSERT INTO recommendedTemplateVids VALUES(" + templateID.ToString() + ", " + videoIDs[i].ToString() + ", " + sortOrder.ToString() + ")", conn); try { conn.Open(); comm.ExecuteNonQuery(); newRecord = true; } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error: [" + ex.Message + "]", labelDBerror); } finally { conn.Close(); } if (newRecord) { messageBox box = new messageBox("success", "Success, new template has been created.", labelNotice); } } } } else { messageBox box = new messageBox("notice", "You must select videos to create template. Please use video list below to make your choices.", labelNotice); } } }
// confirm deletion of template protected void clickConfirmTemplateDelete(Object sender, EventArgs e) { int id = Convert.ToInt32(hiddenFieldTempID.Value); SqlConnection conn; SqlCommand comm; string connectionString = ConfigurationManager.ConnectionStrings["leoQuickStart"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("DELETE FROM recommendedTemplateName WHERE recTempNameID=" + id.ToString() + "", conn); try { conn.Open(); comm.ExecuteNonQuery(); ViewState["editTemplateDataSet"] = null; } catch (SqlException ex) { messageBox box = new messageBox("error", "There has been an error: [ " + ex.Message + " ]", labelDBerror); } finally { conn.Close(); messageBox box = new messageBox("success", "Success, template has been deleted and grid has been refreshed", labelNotice); panelDeleteTemplate.Visible = false; bindEditTemplatesGrid(); labelTemplateID.Text = "0"; } }