public void CarregarVisualizar() { hdf.Value = Session["value"].ToString(); usu_usuario usu = new usu_usuario(); mot_motorista mot = new mot_motorista(); pes_pessoa pes = new pes_pessoa(); mxc_motorista_tipo_contato mxc = new mxc_motorista_tipo_contato(); tpc_tipo_contato tpc = new tpc_tipo_contato(); DataSet ds = mot_motoristaDB.SelectDados(Convert.ToInt32(hdf.Value)); if (ds.Tables[0].Rows.Count == 1) { hdfID.Value = ds.Tables[0].Rows[0]["pes_id"].ToString(); txtNome.Text = ds.Tables[0].Rows[0]["pes_nome"].ToString(); txtEmail.Text = ds.Tables[0].Rows[0]["usu_email"].ToString(); txtCNPJ.Text = ds.Tables[0].Rows[0]["mot_cnpj"].ToString(); ddlSexo.SelectedItem.Text = ds.Tables[0].Rows[0]["pes_sexo"].ToString(); ddlCidade.SelectedItem.Text = ds.Tables[0].Rows[0]["pes_cidade"].ToString(); ddlEstado.SelectedItem.Text = ds.Tables[0].Rows[0]["pes_estado"].ToString(); ddl.SelectedItem.Text = ds.Tables[0].Rows[0]["tpc_descricao"].ToString(); txtTelefone.Text = ds.Tables[0].Rows[0]["mxc_descricao"].ToString(); txtData.Text = ds.Tables[0].Rows[0]["pes_nascimento"].ToString(); } }
public static int Insert(tpc_tipo_contato tpc) { int retorno = 0; try { //Correto IDbConnection objConexao; //Abrir a conexão IDbCommand objCommand; // Criar e executar os comandos string sql = "insert into tpc_tipo_contato "; sql += "(tpc_descricao)"; sql += "values "; sql += "(?tpc_descricao)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?tpc_descricao", tpc.Tpc_descricao)); objCommand.ExecuteNonQuery(); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); } catch (Exception) { //erro retorno = -2; } return(retorno); }
public static void Update(tpc_tipo_contato tpc) { //Correto IDbConnection objConexao; //Abrir a conexão IDbCommand objCommand; // Criar e executar os comandos string sql = "update tpc_tipo_contato set tpc_descricao = ?tpc_descricao where tpc_id = ?tpc_id"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("tpc_id", tpc.Tpc_id)); objCommand.Parameters.Add(Mapped.Parameter("tpc_descricao", tpc.Tpc_descricao)); objCommand.ExecuteNonQuery(); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); }
protected void btnSalvar_Click(object sender, EventArgs e) { mxc_motorista_tipo_contato mxc = new mxc_motorista_tipo_contato(); mot_motorista mot = new mot_motorista(); tpc_tipo_contato tpc = new tpc_tipo_contato(); DataSet ds = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value)); mot.Mot_id = Convert.ToInt32(ds.Tables[0].Rows[0][0]); mot.Mot_cnpj = txtCNPJ.Text; mot_motoristaDB.Update(mot); //tpc.Tpc_id = Convert.ToInt32(ddl.SelectedValue); //mxc.Tpc_id = tpc; //tpc_tipo_contatoDB.Update(tpc); mxc.Mxc_descricao = txtTelefone.Text; mxc_motorista_tipo_contatoDB.Update(mxc); pes_pessoa pes = new pes_pessoa(); pes.Pes_id = Convert.ToInt32(hdf.Value); pes.Pes_nome = txtNome.Text; pes.Pes_sexo = ddlSexo.SelectedValue; pes.Pes_cidade = ddlCidade.SelectedValue; pes.Pes_estado = ddlEstado.SelectedValue; pes.Pes_nascimento = Convert.ToDateTime(txtData.Text); switch (pes_pessoaDB.Update(pes)) { case 0: //Response.Write("OK"); Response.Write("<script>alert('Cadastrado com Sucesso');</script>"); break; case -2: //Response.Write("ERRO"); Response.Write("<script>alert('Ocorreu um Erro');</script>"); break; } }
protected void btnAdicionar_Click(object sender, EventArgs e) { hdf1.Value = Session["value"].ToString(); DataSet codigo = new DataSet(); codigo = con_condutorDB.SelectM(Convert.ToInt32(hdf1.Value)); mot_motorista mot = new mot_motorista(); mot.Mot_id = Convert.ToInt32(codigo.Tables[0].Rows[0][0]); con_condutor con = new con_condutor(); con.Con_cpf = txtCPF.Text; con.Con_nome = txtNome.Text; con.Mot_id = mot; string name = txtNome.Text; con_condutorDB.Insert(con); DataSet id = new DataSet(); id = con_condutorDB.SelectCon(name); con.Con_id = Convert.ToInt32(id.Tables[0].Rows[0][0]); tpc_tipo_contato tpc = new tpc_tipo_contato(); ctp_condutor_tipo_contato ctp = new ctp_condutor_tipo_contato(); if (ddl.SelectedValue == 1.ToString()) { ctp.Ctp_descricao = txtTelefone.Text; } else if (ddl.SelectedValue == 2.ToString()) { ctp.Ctp_descricao = txtCelular.Text; } else if (ddl.SelectedValue == 3.ToString()) { ctp.Ctp_descricao = txtWhatsapp.Text; } else if (ddl.SelectedValue == 4.ToString()) { ctp.Ctp_descricao = txtEmail.Text; } tpc.Tpc_id = Convert.ToInt32(ddl.SelectedValue); ctp.Con_id = con; ctp.Tpc_id = tpc; switch (ctp_condutor_tipo_contatoDB.Insert(ctp)) { case 0: ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSS();", true); txtNome.Text = null; txtCPF.Text = null; txtTelefone.Text = null; txtCelular.Text = null; txtWhatsapp.Text = null; break; case -2: ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSE();", true); break; } }
protected void btnEnviar_Click(object sender, EventArgs e) { hdf.Value = Session["value"].ToString(); DataSet ds = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value)); mot_motorista mot = new mot_motorista(); mot.Mot_id = Convert.ToInt32(ds.Tables[0].Rows[0]["mot_id"]); tpc_tipo_contato tpc = new tpc_tipo_contato(); tpc.Tpc_id = Convert.ToInt32(ddl.SelectedValue); mxc_motorista_tipo_contato mxc = new mxc_motorista_tipo_contato(); if (ddl.SelectedIndex == 1) { mxc.Mxc_descricao = txtTelefone.Text; } else if (ddl.SelectedIndex == 2) { mxc.Mxc_descricao = txtCelular.Text; } else if (ddl.SelectedIndex == 3) { mxc.Mxc_descricao = txtWhatsapp.Text; } else if (ddl.SelectedIndex == 4) { mxc.Mxc_descricao = txtEmailAlt.Text; } mxc.Mot_id = mot; mxc.Tpc_id = tpc; mxc_motorista_tipo_contatoDB.Insert(mxc); string dir = Request.PhysicalApplicationPath + "pg\\uploads\\"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } foreach (HttpPostedFile flp in fup.PostedFiles) { double mp = 2000; if (fup.HasFile) { string arq = Path.GetFileName(flp.FileName); string ext = Path.GetExtension(flp.FileName); ext = ext.ToLower(); double ta = flp.ContentLength / 1024; if (ext == ".jpg" || ext == ".png" || ext == ".gif") { if (ta <= mp) { arq = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ext; if (!File.Exists(dir + arq)) { flp.SaveAs(dir + arq); System.Drawing.Image imgOriginal = System.Drawing.Image.FromFile(Server.MapPath("~/pg/uploads/" + arq), true); System.Drawing.Image.GetThumbnailImageAbort miniatura = new System.Drawing.Image.GetThumbnailImageAbort(erro); System.Drawing.Image imgRedimensionada; int width, height; if (imgOriginal.Width > 200) { width = 200; height = (int)(width * imgOriginal.Height) / imgOriginal.Width; } else { width = imgOriginal.Width; height = imgOriginal.Height; } imgRedimensionada = imgOriginal.GetThumbnailImage(width, height, miniatura, IntPtr.Zero); imgRedimensionada.Dispose(); imgOriginal.Dispose(); //Atualizar tipo de conta if (rbMensal.Checked) { string kindOfPremium = "Premium M"; DataSet dsp = new DataSet(); tip_tipoconta tip = new tip_tipoconta(); dsp = tip_tipocontaDB.SelectID(kindOfPremium); tip.Tip_id = Convert.ToInt32(dsp.Tables[0].Rows[0][0]); mot.Tip_id = tip; mot_motoristaDB.UpdatePremium(mot); } else if (rbAnual.Checked) { string kindOfPremium = "Premium A"; DataSet dsp = new DataSet(); tip_tipoconta tip = new tip_tipoconta(); dsp = tip_tipocontaDB.SelectID(kindOfPremium); tip.Tip_id = Convert.ToInt32(dsp.Tables[0].Rows[0][0]); mot.Tip_id = tip; mot_motoristaDB.UpdatePremium(mot); } //Response.Write("<script>alert('Cadastrado com sucesso');</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalS();", true); tdo_tipodocumento tdo = new tdo_tipodocumento(); tdo.Tdo_image = arq; tdo_tipodocumentoDB.Insert(tdo); string img = arq; DataSet id = new DataSet(); id = tdo_tipodocumentoDB.SelectImage(img); tdo.Tdo_id = Convert.ToInt32(id.Tables[0].Rows[0][0]); doc_documento doc = new doc_documento(); doc.Mot_id = mot; doc.Tdo_id = tdo; doc_documentoDB.Insert(doc); pBefore.Visible = false; pAfter.Visible = true; } else { //Response.Write("<script>alert('Arquivo ja existe');</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalF();", true); } } else { //Response.Write("<script>alert('Tamanho maximo excedido - 500KB');</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalMS();", true); } } else { //Response.Write("<script>alert('Extensão invalida');</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalEI();", true); } } else { //Response.Write("<script>alert('Selecione um arquivo');</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSl();", true); } } }