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

                time = time.Replace(" ", "P");
                string dir = "/img/empresa/empresa" + time + ".jpg";
                pb_empresa.Image.Save(@"" + Application.StartupPath + dir, ImageFormat.Jpeg);
                MEmpresa empresa = new MEmpresa(tb_nombre.Text, tb_nit.Text, dir, tb_direccion.Text, tb_telefono.Text, tb_sigla.Text, tb_propietario.Text);
                if (id != 0)
                {
                    if (CEmpresa.Editar(id, empresa, this))
                    {
                        btn_editar.Enabled  = true;
                        btn_guardar.Enabled = false;
                        habilitar(false);
                    }
                }
                else
                {
                    if (CEmpresa.Insertar(empresa, this))
                    {
                        btn_editar.Enabled  = true;
                        btn_guardar.Enabled = false;
                        habilitar(false);
                    }
                }
            }
        }