private void guarda_registro() { Guid guid_fempresa = Guid.NewGuid(); Guid id_fempresa = Guid.Parse("9A3C8442-2B53-45B7-9B5C-144BFA9C93BE"); string str_empresa = txt_tribunal.Text.ToUpper(); string str_telefono = txt_telefono.Text; string str_email = txt_email.Text; string str_callenum = txt_callenum.Text.ToUpper(); string str_cp = txt_cp.Text; int int_colony = Convert.ToInt32(ddl_colonia.SelectedValue); Guid guid_nusuario = Guid.NewGuid(); string str_nombres = txt_nombres.Text.ToUpper(); string str_apaterno = txt_apaterno.Text.ToUpper(); string str_amaterno = txt_amaterno.Text.ToUpper(); string str_usuairo = txt_usuario.Text.ToLower(); string str_password = mdl_encrypta.Encrypt(txt_clave.Text); using (var m_empresa = new db_transcriptEntities()) { var i_empresa = new inf_tribunal { id_tribunal = guid_fempresa, id_estatus = 1, nombre = str_empresa, telefono = str_telefono, email = str_email, calle_num = str_callenum, cp = str_cp, id_asenta_cpcons = int_colony, fecha_registro = DateTime.Now, id_empresa = id_fempresa }; m_empresa.inf_tribunal.Add(i_empresa); m_empresa.SaveChanges(); } using (var m_usuario = new db_transcriptEntities()) { var i_usuario = new inf_usuarios { id_usuario = guid_nusuario, id_estatus = 1, id_tipo_usuario = 1, nombres = str_nombres, a_paterno = str_apaterno, a_materno = str_amaterno, codigo_usuario = str_usuairo, clave = str_password, fecha_registro = DateTime.Now, id_tribunal = guid_fempresa }; m_usuario.inf_usuarios.Add(i_usuario); m_usuario.SaveChanges(); } limpiar_textbox(); lblModalTitle.Text = "transcript"; lblModalBody.Text = "Datos de administrador y tribunal actualizados con éxito"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true); upModal.Update(); }
protected void cmd_save_Click(object sender, EventArgs e) { if (rb_add.Checked == false & rb_edit.Checked == false & rb_del.Checked == false) { lblModalTitle.Text = "tranScript"; lblModalBody.Text = "Favor de seleccionar una acción"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true); upModal.Update(); } else { Guid str_idcentro = Guid.Parse(lbl_id_centerCP.Text); Guid str_iduser = Guid.NewGuid(); string str_nameuser = txt_name_user.Text.ToUpper(); string str_apater = txt_apater.Text.ToUpper(); string str_amater = txt_amater.Text.ToUpper(); string str_codeuser = txt_code_user.Text.ToLower(); string str_password = mdl_encrypta.Encrypt(txt_password.Text.ToLower()); Guid f_id_user; if (rb_add.Checked) { try { string str_filter_code; using (db_transcriptEntities data_user = new db_transcriptEntities()) { var items_user = (from c in data_user.inf_usuarios where c.codigo_usuario == str_codeuser select c).FirstOrDefault(); str_filter_code = items_user.codigo_usuario.ToString(); } if (str_codeuser == str_filter_code) { clean_data(); lblModalTitle.Text = "tranScript"; lblModalBody.Text = "Usuario ya existe en la base, agregar otro usuario"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true); upModal.Update(); } } catch { int save_user = (int)(Session["ss_save_user"]); using (var insert_user = new db_transcriptEntities()) { var items_user = new inf_usuarios { id_usuario = str_iduser, nombres = str_nameuser, a_paterno = str_apater, a_materno = str_amater, id_tipo_usuario = save_user, codigo_usuario = str_codeuser, clave = str_password, id_estatus = 1, fecha_registro = DateTime.Now, id_centro = str_idcentro }; insert_user.inf_usuarios.Add(items_user); insert_user.SaveChanges(); } clean_data(); lblModalTitle.Text = "tranScript"; lblModalBody.Text = "Datos de usuario guardados con éxito"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true); upModal.Update(); } } else if (rb_edit.Checked) { foreach (GridViewRow row in gv_usuarios.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox chkRow = (row.Cells[1].FindControl("chk_select") as CheckBox); if (chkRow.Checked) { string codeuser = row.Cells[1].Text; using (db_transcriptEntities data_user = new db_transcriptEntities()) { var items_user = (from c in data_user.inf_usuarios where c.codigo_usuario == codeuser select c).FirstOrDefault(); f_id_user = items_user.id_usuario; } using (var data_user = new db_transcriptEntities()) { var items_user = (from c in data_user.inf_usuarios where c.id_usuario == f_id_user select c).FirstOrDefault(); items_user.nombres = str_nameuser; items_user.a_paterno = str_apater; items_user.a_materno = str_amater; items_user.codigo_usuario = str_codeuser; items_user.clave = str_password; data_user.SaveChanges(); } clean_data(); rb_edit.Checked = false; gv_usuarios.Visible = false; txt_search.Visible = false; cmd_search.Visible = false; lblModalTitle.Text = "tranScript"; lblModalBody.Text = "Datos de usuario actualizados con éxito"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true); upModal.Update(); } } } } else if (rb_del.Checked) { foreach (GridViewRow row in gv_usuarios.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox chkRow = (row.Cells[0].FindControl("chk_select") as CheckBox); if (chkRow.Checked) { string codeuser = row.Cells[1].Text; using (db_transcriptEntities data_user = new db_transcriptEntities()) { var items_user = (from c in data_user.inf_usuarios where c.codigo_usuario == codeuser select c).FirstOrDefault(); f_id_user = items_user.id_usuario; } using (var data_user = new db_transcriptEntities()) { var items_user = (from c in data_user.inf_usuarios where c.id_usuario == f_id_user select c).FirstOrDefault(); items_user.id_estatus = 3; data_user.SaveChanges(); } clean_data(); rb_del.Checked = false; gv_usuarios.Visible = false; txt_search.Visible = false; cmd_search.Visible = false; lblModalTitle.Text = "tranScript"; lblModalBody.Text = "Datos de usuario eliminados con éxito"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true); upModal.Update(); } } } } } }
protected void cmd_save_Click(object sender, EventArgs e) { Guid id_fempresa = Guid.Parse("9A3C8442-2B53-45B7-9B5C-144BFA9C93BE"); Guid id_centro = Guid.NewGuid(); Guid str_iduser = Guid.NewGuid(); string str_nameuser = txt_name_user.Text.ToUpper(); string str_apater = txt_apater.Text.ToUpper(); string str_amater = txt_amater.Text.ToUpper(); string str_codeuser = txt_code_user.Text.ToLower(); string str_password = mdl_encrypta.Encrypt(txt_password.Text.ToLower()); string str_business_name = txt_business_name.Text.ToUpper(); int str_municipality = Convert.ToInt32(ddl_municipality.SelectedValue); string str_colony = txt_colony.Text.ToUpper(); string str_street = txt_street.Text.ToUpper(); string str_cp = txt_cp.Text; string str_phone = txt_phone.Text; string str_phonealt = txt_phone_alt.Text; using (var insert_fiscal = new db_transcriptEntities()) { var items_fiscal = new inf_centro { id_estatus = 1, fecha_registro = DateTime.Now, nombre = str_business_name, id_municipio = str_municipality, colonia = str_colony, calle_num = str_street, cp = str_cp, telefono = str_phone, telefono_alt = str_phonealt, id_centro = id_centro, id_empresa = id_fempresa, }; insert_fiscal.inf_centro.Add(items_fiscal); insert_fiscal.SaveChanges(); } using (var insert_user = new db_transcriptEntities()) { var items_user = new inf_usuarios { id_usuario = str_iduser, nombres = str_nameuser, a_paterno = str_apater, a_materno = str_amater, id_tipo_usuario = 2, codigo_usuario = str_codeuser, clave = str_password, id_estatus = 1, fecha_registro = DateTime.Now, id_centro = id_centro }; insert_user.inf_usuarios.Add(items_user); insert_user.SaveChanges(); } clean_text(); lblModalTitle.Text = "tranScript"; lblModalBody.Text = "Datos de administrador y juzgado guardados con éxito"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true); upModal.Update(); }