public ActionResult DebitoDetalle(FormCollection f, HttpPostedFileBase imagen) { try { DebitoDAL deb = new DebitoDAL(); Debito debito = new Debito(); if (imagen != null) { debito.N_img = imagen.ContentType; debito.Imagen = new byte[imagen.ContentLength]; imagen.InputStream.Read(debito.Imagen, 0, imagen.ContentLength); } int deposito = Int32.Parse(f["Cod_deposito"]); debito.Id_ventas = Int32.Parse(f["Id_ventas"]); debito.Cod_deposito = deposito; debito.Num_cuenta = f["Num_cuenta"]; debito.Fecha_deposito = f["Fecha_deposito"]; //var id_user = ctx.Ventas.Where(c => c.Id_ventas == debito.Id_ventas).Select(c => c.id_user).SingleOrDefault(); //int Id_user =id_user; bool validar = deb.Modificar(debito); if (validar == true) { ViewBag.Estado = "Datos ingresados exitosamente."; return(RedirectToAction("Vestado", "Home", new { estado = "1" })); } else { ViewBag.Estado = "Los datos ingresados contienen errores."; return(RedirectToAction("Vestado", "Home", new { estado = "0" })); } } catch (Exception) { ViewBag.Estado = "Los datos ingresados contienen errores."; return(PartialView("Error", "Home")); } }
protected void btPrint_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(RAZAOSOCIAL.Text)) { lblMsg.Text = "Selecione uma empresa para imprimir"; } else { lblMsg.Text = ""; List <DEmpStruct> aLista = new List <DEmpStruct>(); DebitoDAL obj = new DebitoDAL(); Int32 SID = obj.GetSID(); DEmpStruct reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Inscrição Municipal"; reg.Valor = IM.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Razão Social"; reg.Valor = RAZAOSOCIAL.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "CNPJ/CPF"; reg.Valor = CNPJ.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Data de Abertura"; reg.Valor = DATAABERTURA.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Data de Encerramento"; reg.Valor = DATAENCERRAMENTO.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Inscrição Estadual"; reg.Valor = IE.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Situação"; reg.Valor = SITUACAO.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Email"; reg.Valor = EMAIL.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Telefone"; reg.Valor = TELEFONE.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Regime de ISS"; reg.Valor = REGIMEISS.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Vigilância Sanitária"; reg.Valor = VIGSANIT.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Taxa de Licença"; reg.Valor = TAXALICENCA.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Optante do Simples"; reg.Valor = SIMPLES.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Micro Emp. Individual"; reg.Valor = MEI.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Área"; reg.Valor = AREA.Text; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Proprietário"; reg.Valor = sSocio2; aLista.Add(reg); reg = new DEmpStruct(); reg.nSid = SID; reg.Nome = "Atividades"; reg.Valor = sCnae2; aLista.Add(reg); SqlConnection cn = new SqlConnection(); cn.ConnectionString = Dados.StringDeConexao; cn.Open(); int nPos = 1; foreach (DEmpStruct registro in aLista) { try { SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; String Sql = "insert into DEmp(sid,nome,valor,seq) values(@sid,@nome,@valor,@seq)"; cmd.CommandText = Sql; cmd.Parameters.AddWithValue("@sid", SID); cmd.Parameters.AddWithValue("@nome", registro.Nome); cmd.Parameters.AddWithValue("@valor", registro.Valor == null?"":registro.Valor); cmd.Parameters.AddWithValue("@seq", nPos); cmd.ExecuteScalar(); nPos++; } catch (SqlException ex) { throw new Exception(ex.Message); } catch (Exception ex) { throw new Exception(ex.Message); } } cn.Close(); DataTable tabela = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("select * from DEmp where sid=" + SID, Dados.StringDeConexao); da.Fill(tabela); ReportDocument crystalReport = new ReportDocument(); crystalReport.Load(Server.MapPath("~/Report/DEmpresa.rpt")); crystalReport.SetDataSource(tabela); DeleteSID(SID); HttpContext.Current.Response.Buffer = false; HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ClearHeaders(); try { crystalReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, HttpContext.Current.Response, true, "DEmp"); } catch { } finally { crystalReport.Close(); crystalReport.Dispose(); } } }