protected void dtgTopes_Delete(Object sender, DataGridCommandEventArgs e)
        {
            ITope oTope = TopeFactory.GetTope();

            oTope.TopeID = Convert.ToInt32(dtgTopes.DataKeys[(int)e.Item.ItemIndex]);

            try
            {
                if (oTope.Eliminar())
                {
                    BindGrid();
                }
            }
            catch (Exception ex)
            {
                string mensaje = ex.Message;
                try
                {
                    mensaje = this.TraducirTexto(ex.Message);
                    if (mensaje == "" || mensaje == null)
                    {
                        mensaje = ex.Message;
                    }
                }
                catch (Exception)
                {
                    mensaje = ex.Message;
                }
                ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje);
            }
        }
示例#2
0
        private void Editar()
        {
            ITope tope = TopeFactory.GetTope();

            tope.UnidadNegocioID = this.UnidadNegocioID;
            tope.TopeID          = Convert.ToInt32(this.txtTopeID.Text);
            tope.Consultar();

            this.txtTopeKgHasta.Text = tope.TopeKgHasta.ToString();
        }
        private void BindGrid()
        {
            SisPackController.AdministrarGrillas.Configurar(dtgTopes, "TopeID", this.CantidadOpciones);

            ITope oTope = TopeFactory.GetTope();

            //oTope.TopeID = this.txtTopeID.Text == "" ? 0 : Convert.ToInt32(this.txtTopeID.Text);
            oTope.UnidadNegocioID = this.UnidadNegocioID;

            this.dtgTopes.DataSource = oTope.GetTopesConsultaDataSet();
            this.dtgTopes.DataBind();
        }
示例#4
0
        /// <summary>
        /// Guardar datos del tope
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void butGuardarTope_Click(object sender, System.EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            ITope tope = TopeFactory.GetTope();

            tope.TopeID          = this.txtTopeID.Text == "" ? 0 : Convert.ToInt32(this.txtTopeID.Text);
            tope.TopeKgHasta     = Convert.ToInt32(this.txtTopeKgHasta.Text);
            tope.UnidadNegocioID = this.UnidadNegocioID;

            try
            {
                if (tope.Guardar())
                {
                    string script = "<script language='javascript'>\n";
                    script += "alert('Los datos se guardaron correctamente.');\n";
                    script += "window.location.href = 'TopesConsul.aspx';\n";
                    script += "</script>";
                    Page.RegisterStartupScript("scriptOk", script);
                }
                else
                {
                    string script = "<script language='javascript'>\n";
                    script += "alert('Los datos no se guardaron debido a errores.');\n";
                    script += "</script>";

                    Page.RegisterStartupScript("scriptError", script);
                }
            }
            catch (Exception ex)
            {
                string mensaje = ex.Message;
                try
                {
                    mensaje = this.TraducirTexto(ex.Message);
                    if (mensaje == "" || mensaje == null)
                    {
                        mensaje = ex.Message;
                    }
                }
                catch (Exception)
                {
                    mensaje = ex.Message;
                }
                ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje);
            }
        }