private List <Representantes> GetList() { try { List <Representantes> List = new List <Representantes>(); CN_CatRepresentantes clsCatRepresentantes = new CN_CatRepresentantes(); Sesion session2 = new Sesion(); session2 = (Sesion)Session["Sesion" + Session.SessionID]; Representantes representante = new Representantes(); representante.Id_Emp = session2.Id_Emp; representante.Id_Cd = session2.Id_Cd_Ver; clsCatRepresentantes.ConsultarRepresentantes(representante, session2.Emp_Cnx, ref List); return(List); } catch (Exception ex) { throw ex; } }
private void Guardar() { try { if (lbUen.CheckedItems.Count == 0) { Alerta("No es posible tener representantes sin UEN asignada"); return; } Sesion session = new Sesion(); session = (Sesion)Session["Sesion" + Session.SessionID]; Representantes representante = new Representantes(); representante.Nombre = txtNombre.Text; representante.Id_Emp = session.Id_Emp; representante.Id_Cd = session.Id_Cd_Ver; representante.Calle = txtCalle.Text; representante.Colonia = txtColonia.Text; representante.Compensacion = txtCompensacion.Text == string.Empty ? 0 : Convert.ToDouble(txtCompensacion.Text); representante.Contribucion = txtContribucion.Text == string.Empty ? 0 : Convert.ToDouble(txtContribucion.Text); representante.Fecha_Alta = dpFecha.SelectedDate == null ? DateTime.MinValue : dpFecha.SelectedDate.Value; //representante.Gte = Convert.ToInt32(cmbGte.SelectedValue); representante.Numero = txtNumero.Text == string.Empty ? 0 : Convert.ToInt32(txtNumero.Text); representante.Pertenece = chkPertenece.Checked; representante.Telefono = txtTelefono.Text; representante.Estatus = chkActivo.Checked; CN_CatRepresentantes clsCatRepresentantes = new CN_CatRepresentantes(); int verificador = -1; List <Comun> lc = new List <Comun>(); Comun c = default(Comun); foreach (RadListBoxItem rlbi in lbUen.CheckedItems) { c = new Comun(); c.Id = Convert.ToInt32(rlbi.Value); c.Descripcion = rlbi.Text; lc.Add(c); } if (HF_ID.Value == "") { if (!_PermisoGuardar) { Alerta("No tiene permisos para grabar"); return; } representante.Id_Rik = Convert.ToInt32(txtClave.Text); clsCatRepresentantes.InsertarRepresentantes(representante, session.Emp_Cnx, ref verificador); if (verificador == 1) { clsCatRepresentantes.InsertarRepresentantesDet(representante, lc, session.Emp_Cnx, ref verificador); Nuevo(); Alerta("Los datos se guardaron correctamente"); } else { Alerta("La clave ya existe"); } } else { if (!_PermisoModificar) { Alerta("No tiene permisos para modificar"); return; } representante.Id_Rik = Convert.ToInt32(HF_ID.Value); clsCatRepresentantes.ModificarRepresentantes(representante, session.Emp_Cnx, ref verificador); if (verificador == 1) { clsCatRepresentantes.InsertarRepresentantesDet(representante, lc, session.Emp_Cnx, ref verificador); Alerta("Los datos se modificaron correctamente"); } else { Alerta("Ocurrió un error al intentar guardar los cambios"); } } rg1.Rebind(); } catch (Exception ex) { throw ex; } }
protected void rg1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { try { ErrorManager(); if (e.CommandName.ToString() == "Modificar") { Nuevo(); Sesion Sesion = new Sesion(); Sesion = (Sesion)Session["Sesion" + Session.SessionID]; Int32 item = default(Int32); item = e.Item.ItemIndex; if (item >= 0) { CN__Comun.RemoverValidadores(Validators); HF_ID.Value = rg1.Items[item]["Id_Rik"].Text; txtClave.Text = rg1.Items[item]["Id_Rik"].Text; txtClave.Enabled = false; txtNombre.Text = rg1.Items[item]["Nombre"].Text; txtCalle.Text = rg1.Items[item]["Calle"].Text.Replace(" ", string.Empty); txtNumero.Text = rg1.Items[item]["Numero"].Text == "0" ? string.Empty : rg1.Items[item]["Numero"].Text; txtColonia.Text = rg1.Items[item]["Colonia"].Text.Replace(" ", string.Empty);; txtTelefono.Text = rg1.Items[item]["Telefono"].Text.Replace(" ", string.Empty);; if (Convert.ToDateTime(rg1.Items[item]["Fecha_Alta"].Text) == DateTime.MinValue) { dpFecha.DateInput.Text = string.Empty; dpFecha.SelectedDate = null; } else { dpFecha.SelectedDate = Convert.ToDateTime(rg1.Items[item]["Fecha_Alta"].Text); } txtContribucion.Text = rg1.Items[item]["Contribucion"].Text; txtCompensacion.Text = rg1.Items[item]["Compensacion"].Text; //txtGte.Text = rg1.Items[item]["Gte"].Text; //cmbGte.SelectedIndex = cmbGte.FindItemIndexByValue(rg1.Items[item]["Gte"].Text); chkPertenece.Checked = Convert.ToBoolean(rg1.Items[item]["Pertenece"].Text); chkActivo.Checked = Convert.ToBoolean(rg1.Items[item]["Estatus"].Text); //txtClave.Enabled = false; List <RikUen> lc = new List <RikUen>(); CN_CatRepresentantes clsCatRepresentantes = new CN_CatRepresentantes(); RikUen representante = new RikUen(); representante.Id_Emp = Sesion.Id_Emp; representante.Id_Cd = Sesion.Id_Cd_Ver; representante.Id_Rik = Convert.ToInt32(rg1.Items[item]["Id_Rik"].Text); clsCatRepresentantes.ConsultarRepresentantesDet(representante, Sesion.Emp_Cnx, ref lc); //lbUen.Items.FindChildByValue<ControlItem>(lc[0].Id_Uen.ToString(), true).; foreach (RikUen rikuen in lc) { lbUen.FindItemByValue(rikuen.Id_Uen.ToString()).Checked = true; } } } } catch (Exception ex) { ErrorManager(ex, "rg1_ItemCommand"); } }
protected void btnImportar_Click(object sender, EventArgs e) { OleDbConnection con = default(OleDbConnection); try { Sesion Sesion = new Sesion(); Sesion = (Sesion)Session["Sesion" + Session.SessionID]; List <Representantes> List = new List <Representantes>(); CN_CatRepresentantes cn_re = new CN_CatRepresentantes(); string path = Server.MapPath("~/App_Data/RadUploadTemp") + "\\" + NombreArchivo; foreach (UploadedFile f in RadUpload1.UploadedFiles) { if (File.Exists(path)) { File.Delete(path); } f.SaveAs(path, true); } string strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + path + "';Extended Properties=\"Excel 12.0 xml;HDR=YES;IMEX=1;\""; con = new OleDbConnection(strConn); //lblMensaje.Text = "abriendo conexion"; con.Close(); con.Open(); //lblMensaje.Text = "conexion abierta"; DataTable dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); string hoja = dt.Rows[1].ItemArray[2].ToString().Replace("'", ""); //lblMensaje.Text = "hoja" + hoja; OleDbCommand cmd = new OleDbCommand("select * from [" + hoja + "]", con); OleDbDataAdapter dad = new OleDbDataAdapter(); dad.SelectCommand = cmd; DataSet ds = new DataSet(); dad.Fill(ds); Representantes r; foreach (DataRow dr in ds.Tables[0].Rows) { r = new Representantes(); if (dr[0].ToString() != "") { r.Id_Empl = Convert.ToInt32(dr[0]); r.Id_Rik = Convert.ToInt32(dr[1]); r.RE_FechaA = dr[2].ToString() == "" ? (DateTime?)null : Convert.ToDateTime(dr[2]); r.RE_FechaB = dr[3].ToString() == "" ? (DateTime?)null : Convert.ToDateTime(dr[3]); List.Add(r); } } //lblMensaje.Text = "lleno dataset"; con.Close(); int Verificador = 0; cn_re.ActualizaDatosRik(List, ref Verificador, Sesion.Emp_Cnx); if (Verificador == -1) { Alerta("Se actualizo la información de manera exitosa"); con.Close(); } else { Alerta("Ocurrio un error al tratar de actualizar la infromación"); con.Close(); } try { File.Delete(path); } catch { } } catch (Exception ex) { con.Close(); Alerta(ex.Message.Replace("'", "")); //this.DisplayMensajeAlerta(ex.Message); } }