protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) { //Boton Nuevo......... if (Menu1.SelectedItem.Text == "New") { //Limpiando TextBox LimpiandoTextBox(); //Habilitando TextBox HabilitandoTextBox(); //this.lblMessage.Text = "New"; //this.lblMessage.Visible = true; } //Boton Guardar........ if (Menu1.SelectedItem.Text == "Save") { if (this.TextBox1.Text == "") { this.Msg = "There are textbox empty!"; Jalert.MessageBoxError(this, this.Msg); return; } if (this.TextBox2.Text == "") { this.Msg = "There are textbox empty!"; Jalert.MessageBoxError(this, this.Msg); return; } #region "Pasando parametros" SqlParameter[] param = new SqlParameter[4]; param[0] = new SqlParameter("@action", SqlDbType.NVarChar); param[0].Value = "InsertOEACustomers"; param[1] = new SqlParameter("@RNC", SqlDbType.NVarChar); param[1].Value = this.TextBox1.Text; param[2] = new SqlParameter("@CUSTOMER", SqlDbType.NVarChar); param[2].Value = this.TextBox2.Text; param[3] = new SqlParameter("@STATUS", SqlDbType.NVarChar); param[3].Value = this.DropDownList1.Text; #endregion try { //Conectando con StoreProcedure SqlConOEACustomers.Open(); SqlCmdOEACustomers.Connection = SqlConOEACustomers; SqlCmdOEACustomers.Parameters.AddRange(param); SqlCmdOEACustomers.CommandType = CommandType.StoredProcedure; SqlCmdOEACustomers.CommandText = "sp_CargaContenedorizada"; SqlCmdOEACustomers.ExecuteNonQuery(); //this.lblMessage.Visible = true; //this.lblMessage.Text = "Register completed!"; SqlConOEACustomers.Close(); } catch (Exception ex) { this.Msg = ex.Message; //throw new Exception(ex.Message); //this.lblMessage.Text = string.Concat(this.lblMessage.Text, " [ ", this.Mssg = this.Mssg + 1, " ] --> ", this.Msg, " <-- "); //ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Error!')", true); Jalert.MessageBoxError(this, this.Msg); } finally { //Inhabilitando TextBox InhabilitandoTextBox(); //Limpiar TextBox LimpiandoTextBox(); // Jalert.MessageBoxSuccess(this, "Register completed!"); } } //Boton Cancelar......... if (Menu1.SelectedItem.Text == "Cancel") { //Limpiando TextBox LimpiandoTextBox(); Jalert.MessageBoxSuccess(this, "Canceled"); } }
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) { //Boton Nuevo......... if (Menu1.SelectedItem.Text == "New") { //Limpiando TextBox LimpiandoTextBox(); //Habilitando TextBox HabilitandoTextBox(); this.lblMessage.Text = "Insert"; this.lblMessage.Visible = true; //this.lblIDUpdate.Text = "Null"; } //Boton Guardar........ if (Menu1.SelectedItem.Text == "Save") { if (this.TextBox1.Text == "") { this.lblMessage.Text = "There are textbox empty!"; this.lblMessage.Visible = true; return; } #region "Pasando parametros" SqlParameter[] param = new SqlParameter[10]; param[0] = new SqlParameter("@action", SqlDbType.NVarChar); param[0].Value = this.lblMessage.Text; //param[0].Value = "Insert"; param[1] = new SqlParameter("@DGA", SqlDbType.NVarChar); param[1].Value = this.TextBox1.Text; param[2] = new SqlParameter("@MERCANCIA", SqlDbType.NVarChar); param[2].Value = this.TextBox2.Text; param[3] = new SqlParameter("@PAQUETE", SqlDbType.NVarChar); param[3].Value = this.TextBox3.Text; param[4] = new SqlParameter("@PAQMEDIDA", SqlDbType.NVarChar); param[4].Value = this.TextBox4.Text; param[5] = new SqlParameter("@MEDIDA", SqlDbType.NVarChar); param[5].Value = this.TextBox5.Text; param[6] = new SqlParameter("@UNIDMEDIDA", SqlDbType.NVarChar); param[6].Value = this.TextBox6.Text; param[7] = new SqlParameter("@RNC", SqlDbType.NVarChar); param[7].Value = this.TextBox7.Text; param[8] = new SqlParameter("@CONSIGNATARIO", SqlDbType.NVarChar); param[8].Value = this.TextBox8.Text; if (this.lblMessage.Text == "Insert") { param[9] = new SqlParameter("@ID", SqlDbType.Int); param[9].Value = DBNull.Value; } else { param[9] = new SqlParameter("@ID", SqlDbType.Int); param[9].Value = Convert.ToInt32(this.lblIDUpdate.Text); } #endregion try { //Conectando con StoreProcedure SqlConConsignee.Open(); SqlCmdConsignee.Connection = SqlConConsignee; SqlCmdConsignee.Parameters.AddRange(param); SqlCmdConsignee.CommandType = CommandType.StoredProcedure; SqlCmdConsignee.CommandText = "sp_CargaGeneralSuelta"; SqlCmdConsignee.ExecuteNonQuery(); SqlConConsignee.Close(); if (this.lblMessage.Text == "Insert") { this.lblMessage.Visible = true; this.lblMessage.Text = "Register completed!"; Jalert.MessageBoxSuccess(this, "Register completed!"); } } catch (Exception ex) { this.Msg = ex.Message; //throw new Exception(ex.Message); this.lblMessage.Text = string.Concat(this.lblMessage.Text, " [ ", this.Mssg = this.Mssg + 1, " ] --> ", this.Msg, " <-- "); //ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Error!')", true); Jalert.MessageBoxError(this, this.Msg); } finally { //Inhabilitando TextBox InhabilitandoTextBox(); //Limpiar TextBox LimpiandoTextBox(); if (this.lblMessage.Text == "Update") { SqlConConsignee.Open(); string QueryEdit = "SELECT * FROM dbo.hit_carga_general_suelta WHERE ID = ('" + Convert.ToInt32(this.lblIDUpdate.Text) + "')"; SqlCommand CmdEdit = new SqlCommand(QueryEdit, SqlConConsignee); SqlDataAdapter SqlDataAdapterEdit = new SqlDataAdapter(CmdEdit); DataSet DataSetEdit = new DataSet(); SqlDataAdapterEdit.Fill(DataSetEdit); this.GridView1.DataSource = DataSetEdit; //this.GridView1.DataSource = DataSetEdit.Tables[0].DefaultView; this.GridView1.DataBind(); SqlConConsignee.Close(); this.lblMessage.Text = "Register Updated!"; Jalert.MessageBoxSuccess(this, "Register Updated!"); } } } //Boton Cancelar......... if (Menu1.SelectedItem.Text == "Cancel") { //Limpiando TextBox LimpiandoTextBox(); this.lblMessage.Text = "Canceled"; } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { bool isDelete = false; try { //int index = Convert.ToInt32(e.CommandArgument); //ImageButton boton = (ImageButton) this.GridView1.Rows[index].Cells[3].Controls[0]; int ID = Convert.ToInt32(e.CommandArgument.ToString()); string Comando = e.CommandName; if (Comando == "Delete") { #region "Obtener Pagina" //Int32 index = Convert.ToInt32(e.CommandArgument); //GridViewRow row; //if ( this.GridView1.PageIndex == 0) //{ // row = this.GridView1.Rows[index]; //} //else //{ // Int32 totalPag = Convert.ToInt32( this.GridView1.PageCount); // Int32 itemActl = (totalPag - (totalPag - Convert.ToInt32( this.GridView1.PageIndex))) * Convert.ToInt32( this.GridView1.PageSize); // row = this.GridView1.Rows[index - itemActl]; //} //DataKey key = this.GridView1.DataKeys[row.RowIndex]; #endregion //Procedimiento para eliminar. SqlConOEACustomers.Open(); string QueryDelete = "DELETE dbo.hit_oea_customers WHERE ID = ('" + ID + "')"; SqlCommand CmdDelete = new SqlCommand(QueryDelete, SqlConOEACustomers); SqlDataAdapter SqlDataAdapterDelete = new SqlDataAdapter(CmdDelete); DataSet DataSetDelete = new DataSet(); SqlDataAdapterDelete.Fill(DataSetDelete); this.GridView1.DataSource = DataSetDelete; //this. this.GridView1.DataBind(); SqlConOEACustomers.Close(); Jalert.MessageBoxSuccess(this, "Delete"); isDelete = true; } } catch (Exception ex) { this.Msg = ex.Message; //this.lblMessage.Text = string.Concat(this.lblMessage.Text, " [ ", this.Mssg = this.Mssg + 1, " ] --> ", this.Msg, " <-- "); //ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Error!')", true); Jalert.MessageBoxError(this, this.Msg); } finally { if (isDelete) { //Response.Redirect("~/Clientes.aspx?ID=" + (string)e.CommandArgument); string url = "~/OEACustomers.aspx?"; //url += "Msg=" + "Este registro ha sido actualizado"; Response.Redirect(url + (string)e.CommandArgument); lblMessage.Text = "Row deleted!"; } } }
protected void Button1_Click(object sender, EventArgs e) { Jalert.MessageBoxSuccess(this, "Esta es una prueba!!!"); }