Beispiel #1
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            if (CValidar.ValidarProducto(tb_nombre, tb_codigo, tb_precio, errorIcono, this))
            {
                string time = DateTime.Now.ToString("yyyy_mm_dd hh_mm_ss");

                time = time.Replace(" ", "P");
                string dir = "/img/producto/" + tb_nombre.Text + time + ".jpg";

                pb_imagen.Image.Save(@"" + Application.StartupPath + dir, ImageFormat.Jpeg);
                MProducto pro = new MProducto(0, tb_nombre.Text, tb_codigo.Text, tb_unidad.Text, Double.Parse(tb_precio.Text), tb_descripcion.Text, dir, "enable");
                if (id == 0)
                {
                    if (CProducto.Insertar(pro, this))
                    {
                        botones(false, false, false, true, true);
                        mostrar();
                        habilitar(true);
                        limpiar();
                        id = 0;
                    }
                }
                else
                {
                    if (CProducto.Editar(id, pro, this))
                    {
                        botones(true, false, false, false, true);
                        mostrar();
                        habilitar(true);
                        limpiar();
                        id = 0;
                    }
                }
            }
        }