protected void adicionarnovo() { try { //string message = "Do you want to submit?"; //ClientScript.RegisterOnSubmitStatement(this.GetType(), "confirm", "return confirm('" + message + "');"); string a = Guid.NewGuid().ToString(); int contar = si.Cartas_tb.Count(); var pedidonumero = "UCM710" + "0" + contar.ToString() + "C"; Cartas_tb dp = new Models.Cartas_tb(); dp.NomeRequerente = txtNomeCliente.Text; dp.idCurso = int.Parse(txtCurso.SelectedValue); dp.Periodo = DropDownListPeriodo.Text; dp.CodigoCarta = pedidonumero; dp.ContactoCelular = txtContacto.Text; dp.AnoLectivo = DropDownList2.Text; dp.DataCarta = DateTime.Now; dp.Descricao = txtDescr.Text; dp.idPedido = int.Parse(txtPedido.SelectedValue); dp.idUsuario = idu; dp.idPastaDepartamento = int.Parse(txtPasta.SelectedValue); dp.Estado = "Enviado"; dp.GuidMap = a; si.Cartas_tb.Add(dp); si.SaveChanges(); idcart = dp.idCarta; foreach (HttpPostedFile upFile in FileUpload2.PostedFiles) { if (upFile.ContentLength == 0) { } else { SaveFiles(upFile); } } HttpContext.Current.Response.Redirect("~/WebFormSucessoCartas.aspx?index=" + dp.GuidMap + "&CodExp=" + dp.CodigoCarta + "&Cell=" + txtContacto.Text, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (Exception) { throw; } }
protected void adicionarnovo() { try { string message = "Do you want to submit?"; ClientScript.RegisterOnSubmitStatement(this.GetType(), "confirm", "return confirm('" + message + "');"); string a = Guid.NewGuid().ToString(); int contar = si.Cartas_tb.Count(); var pedidonumero = "UCM710" + "0" + contar.ToString(); Cartas_tb dp = new Models.Cartas_tb(); dp.NomeRequerente = txtNomeCliente.Text; dp.idCurso = int.Parse(txtCurso.SelectedValue); dp.Periodo = DropDownListPeriodo.Text; dp.CodigoCarta = pedidonumero; dp.DataCarta = DateTime.Now; dp.idPedido = int.Parse(txtPedido.SelectedValue); dp.idUsuario = idu; dp.idPastaDepartamento = int.Parse(txtPasta.SelectedValue); dp.Estado = "Enviado"; dp.GuidMap = a; dp.Documento1 = ReadFileBite(FileUpload1.PostedFile); dp.Documento2 = ReadFileBite(FileUpload2.PostedFile); si.Cartas_tb.Add(dp); si.SaveChanges(); //string message = "Dados Salvo com Sucesso!"; //string script = "window.onload = function(){ alert('"; //script += message; //script += "')};"; //ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true); //Response.Redirect("WebFormInicio.aspx"); ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Form submitted.');", true); // ScriptManager.RegisterStartupScript(this, this.GetType(), "err_msg", "alert('" + "abe" + "');window.location='WebFormInicio.aspx';", true); } catch (Exception) { throw; } }