private void dataGridView1_RowValidated(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) { // Save row changes if any were made and release the edited // Customer object if there is one. if (e.RowIndex >= this.customers.Count && e.RowIndex != this.dataGridView1.Rows.Count - 1) { // Add the new Customer object to the data store. this.customers.Add(this.customerInEdit); this.customerInEdit = null; this.rowInEdit = -1; } else if (this.customerInEdit != null && e.RowIndex < this.customers.Count) { // Save the modified Customer object in the data store. this.customers[e.RowIndex] = this.customerInEdit; this.customerInEdit = null; this.rowInEdit = -1; } else if (this.dataGridView1.ContainsFocus) { this.customerInEdit = null; this.rowInEdit = -1; } }
private void dataGridView1_CellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e) { // If this is the row for new records, no values are needed. if (e.RowIndex == this.dataGridView1.RowCount - 1) { return; } ET_M19 customerTmp = null; // Store a reference to the Customer object for the row being painted. if (e.RowIndex == rowInEdit) { customerTmp = this.customerInEdit; } else { customerTmp = (ET_M19)this.customers[e.RowIndex]; } // Set the cell value to paint using the Customer object retrieved. switch (this.dataGridView1.Columns[e.ColumnIndex].Name) { case "Company Name": e.Value = customerTmp._TM19_DESCRIP1; break; case "Contact Name": e.Value = customerTmp._TM19_DESCRIP2; break; } }
public void Agregar_Et_m19(ET_M19 dato) { if (dato != null) { _et_m19 = dato; } }
public ET_M19 sel_001(string cliente) { _et_m19 = new ET_M19(); try { var where_lista = _lista_m19.Where(p => String.Equals(p._TM19_DESCRIP2, cliente.Trim(), StringComparison.CurrentCultureIgnoreCase)).ToList();// p._TM19_DESCRIP2 == cliente).ToList(); foreach (ET_M19 unique_row in where_lista) { _et_m19._TM19_ID = unique_row._TM19_ID; _et_m19._TM19_DESCRIP1 = unique_row._TM19_DESCRIP1; _et_m19._TM19_DESCRIP2 = unique_row._TM19_DESCRIP2; _et_m19._TM19_TM2_ID = unique_row._TM19_TM2_ID; } } catch (Exception ex) { } if (string.IsNullOrEmpty(_et_m19._TM19_ID)) { _entidad._hubo_error = true; _entidad._titulo_mensaje = "Alerta"; string msg = string.Format("El cliente ingresado no existe."); _entidad._contenido_mensaje = msg; Mensaje_Alerta_(_entidad); } return(_et_m19); }
private void dataGridView1_NewRowNeeded(object sender, System.Windows.Forms.DataGridViewRowEventArgs e) { // Create a new Customer object when the user edits // the row for new records. this.customerInEdit = new ET_M19(); this.rowInEdit = this.dataGridView1.Rows.Count - 1; }
private void dataGridView1_CancelRowEdit(object sender, System.Windows.Forms.QuestionEventArgs e) { if (this.rowInEdit == this.dataGridView1.Rows.Count - 2 && this.rowInEdit == this.customers.Count) { // If the user has canceled the edit of a newly created row, // replace the corresponding Customer object with a new, empty one. this.customerInEdit = new ET_M19(); } else { // If the user has canceled the edit of an existing row, // release the corresponding Customer object. this.customerInEdit = null; this.rowInEdit = -1; } }
private void dataGridView1_UserDeletingRow(object sender, System.Windows.Forms.DataGridViewRowCancelEventArgs e) { if (e.Row.Index < this.customers.Count) { // If the user has deleted an existing row, remove the // corresponding Customer object from the data store. this.customers.RemoveAt(e.Row.Index); } if (e.Row.Index == this.rowInEdit) { // If the user has deleted a newly created row, release // the corresponding Customer object. this.rowInEdit = -1; this.customerInEdit = null; } }
private void Obtener_Informacion_t_m19() { _et_m19 = new ET_M19(); _et_m19 = _lista_m19.FirstOrDefault(item => item._TM19_DESCRIP2.ToUpper() == autoCompleteTextBox_t_m19.Text.ToUpper().Trim()); if (_et_m19 != null) { ID_TM19 = _et_m19._TM19_ID; txt_ruc_cliente.Text = _et_m19._TM19_DESCRIP1; _nt_m27.Agregar_Et_m19(_et_m19); _nt_m27.Iniciar(Tarea.BUSCAR); } else { panel1.Visible = true; MessageBox.Show ( " La búsqueda de cliente no obtubo resultados. \n Intente de nuevo.", "Cotizador", MessageBoxButtons.OK, MessageBoxIcon.Information ); autoCompleteTextBox_t_m19.Focus(); } }
private void dataGridView1_CellValuePushed(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e) { ET_M19 customerTmp = null; // Store a reference to the Customer object for the row being edited. if (e.RowIndex < this.customers.Count) { // If the user is editing a new row, create a new Customer object. if (this.customerInEdit == null) { this.customerInEdit = new ET_M19( ((ET_M19)this.customers[e.RowIndex])._TM19_DESCRIP1, ((ET_M19)this.customers[e.RowIndex])._TM19_DESCRIP2); } customerTmp = this.customerInEdit; this.rowInEdit = e.RowIndex; } else { customerTmp = this.customerInEdit; } // Set the appropriate Customer property to the cell value entered. String newValue = e.Value as String; switch (this.dataGridView1.Columns[e.ColumnIndex].Name) { case "Company Name": customerTmp._TM19_DESCRIP1 = newValue; break; case "Contact Name": customerTmp._TM19_DESCRIP2 = newValue; break; } }
//OBTENER LISTA DE COTIZACIONES public ET_entidad get_001() { string Mensaje_error = ""; DataTable dt = new DataTable(); using (SqlConnection cn = new SqlConnection(_cnx.conexion)) { cn.Open(); SqlTransaction sqlTran = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("pa_tm39get_001", cn, sqlTran); cmd.CommandType = CommandType.StoredProcedure; try { cmd.Parameters.Add("@p_TM39_TM2_ID", SqlDbType.VarChar, 10).Value = _global._TM2_ID; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); _lista_m39.Clear(); foreach (DataRow fila in dt.Rows) { _etm39 = new ET_M39(); _et_m19 = new ET_M19(); _etm39._TM39_ID = fila["TM39_ID"].ToString(); _etm39._TM39_DESCRIP = fila["TM39_DESCRIP"].ToString(); _etm39._TM39_ST = Convert.ToInt32(fila["TM39_ST"].ToString()); _etm39._TM39_FLG_ELIMINADO = fila["TM39_FLG_ELIMINADO"].ToString(); _etm39._TM39_UCREA = fila["TM39_UCREA"].ToString(); _etm39._TM39_FCREA = Convert.ToDateTime(fila["TM39_FCREA"].ToString()); _etm39._TM39_UACTUALIZA = fila["TM39_UACTUALIZA"].ToString(); _etm39._TM39_FACTUALIZA = Convert.ToDateTime(fila["TM39_FACTUALIZA"].ToString()); _etm39._TM39_TM19_ID = fila["TM39_TM19_ID"].ToString(); _etm39._TM39_TM2_ID = fila["TM39_TM2_ID"].ToString(); _etm39._TM39_tm27_count = Convert.ToInt32(fila["_TM39_tm27_count"].ToString()); _et_m19._TM19_DESCRIP1 = fila["TM19_DESCRIP1"].ToString(); _et_m19._TM19_DESCRIP2 = fila["TM19_DESCRIP2"].ToString(); _et_m19._TM19_ID = fila["TM19_ID"].ToString(); _etm39._entity_et_m19 = _et_m19; _lista_m39.Add(_etm39); } _Entidad._lista_et_m39 = _lista_m39; _Entidad._hubo_error = false; } catch (SqlException exsql) { try { sqlTran.Rollback(); } catch (Exception exRollback) { } } catch (Exception ex) { Mensaje_error = string.Format("{1}{0}", Environment.NewLine, (Mensaje_error + ex.Message.ToString())); if (ex.InnerException != null) { Mensaje_error = string.Format("{1}{0}", Environment.NewLine, (Mensaje_error + "Inner exception: " + ex.InnerException.Message)); } Mensaje_error = string.Format("{1}{0}", Environment.NewLine, (Mensaje_error + "Stack trace: " + ex.StackTrace)); _Entidad._hubo_error = true; _Entidad._contenido_mensaje = Mensaje_error; _Entidad._titulo_mensaje = "Error!"; } finally { cn.Close(); } return(_Entidad); } }
//OBTENER LISTA DE COTIZACIONES DE ACUERDOA A UN FILTRO public ET_entidad get_002(ET_M39 _entity_m39) { DataTable dt = new DataTable(); using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["SGAP.Properties.Settings.ConectionString"].ToString())) { cn.Open(); SqlTransaction sqlTran = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("pa_tm39get_002", cn, sqlTran); cmd.CommandType = CommandType.StoredProcedure; try { cmd.Parameters.Add("@p_TM39_TM2_ID", SqlDbType.VarChar, 10).Value = _global._TM2_ID; cmd.Parameters.Add("@p_tm19_filtro", SqlDbType.VarChar, 50).Value = _entity_m39._filtro; cmd.Parameters.Add("@p_Fecha_Inicio", SqlDbType.DateTime).Value = _entity_m39._fecha_Inicio; cmd.Parameters.Add("@p_Fecha_Fin", SqlDbType.DateTime).Value = _entity_m39._fecha_Fin; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); _lista_m39.Clear(); foreach (DataRow fila in dt.Rows) { _etm39 = new ET_M39(); _et_m19 = new ET_M19(); _etm39._TM39_ID = fila["TM39_ID"].ToString(); _etm39._TM39_DESCRIP = fila["TM39_DESCRIP"].ToString(); _etm39._TM39_ST = Convert.ToInt16(fila["TM39_ST"].ToString()); _etm39._TM39_FLG_ELIMINADO = fila["TM39_FLG_ELIMINADO"].ToString(); _etm39._TM39_UCREA = fila["TM39_UCREA"].ToString(); _etm39._TM39_FCREA = Convert.ToDateTime(fila["TM39_FCREA"].ToString()); _etm39._TM39_UACTUALIZA = fila["TM39_UACTUALIZA"].ToString(); _etm39._TM39_FACTUALIZA = Convert.ToDateTime(fila["TM39_FACTUALIZA"].ToString()); _etm39._TM39_TM19_ID = fila["TM39_TM19_ID"].ToString(); _etm39._TM39_TM2_ID = fila["TM39_TM2_ID"].ToString(); _etm39._TM39_tm27_count = Convert.ToInt32(fila["_TM39_tm27_count"].ToString()); _et_m19._TM19_DESCRIP1 = fila["TM19_DESCRIP1"].ToString(); _et_m19._TM19_DESCRIP2 = fila["TM19_DESCRIP2"].ToString(); _et_m19._TM19_ID = fila["TM19_ID"].ToString(); _etm39._entity_et_m19 = _et_m19; _lista_m39.Add(_etm39); } _Entidad._lista_et_m39 = _lista_m39; _Entidad._hubo_error = false; } catch (SqlException exsql) { try { sqlTran.Rollback(); } catch (Exception exRollback) { } } catch (Exception ex) { _Entidad._hubo_error = true; _Entidad._contenido_mensaje = "Ocurrio un error al obetener Informacion de la base de datos.\n" + ex.ToString(); _Entidad._titulo_mensaje = "Alert!"; } finally { cn.Close(); } return(_Entidad); } }
//Obtener lista de locales que posee un cliente public ET_entidad sel_001(ET_M19 objEntity) { string Mensaje_error = ""; DataTable dt = new DataTable(); using (SqlConnection cn = new SqlConnection(_cnx.conexion)) { cn.Open(); SqlTransaction sqlTran = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("pa_tm27_sel_001", cn, sqlTran); cmd.CommandType = CommandType.StoredProcedure; try { cmd.Parameters.Add("@p_TM27_TM19_ID", SqlDbType.VarChar, 10).Value = objEntity._TM19_ID; cmd.Parameters.Add("@P_TM27_TM2_ID", SqlDbType.VarChar, 20).Value = _globales._TM2_ID; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); _lista = new List <ET_M27>(); _lista.Clear(); foreach (DataRow fila in dt.Rows) { _etm27 = new ET_M27(); _etm27._seleccionado = true; _etm27._TM27_ID = fila["TM27_ID"].ToString(); _etm27._TM27_TM19_ID = fila["TM27_TM19_ID"].ToString(); _etm27._TM27_TM2_ID = fila["TM27_TM2_ID"].ToString(); _etm27._TM27_NOMBRE = fila["TM27_NOMBRE"].ToString(); _etm27._TM27_DIRECCION = fila["TM27_DIRECCION"].ToString(); //_etm27._TM27_TM9_DIST_CODIGO = fila["TM27_TM9_DIST_CODIGO"].ToString(); //_etm27._TM27_TM28_ID = Convert.ToInt32(fila["TM27_TM28_ID"]); //_etm27._TM27_ST = Convert.ToInt32(fila["TM27_ST"].ToString()); //_etm27._TM27_FLG_ELIMINADO = Convert.ToInt32(fila["TM27_FLG_ELIMINADO"].ToString()); //_etm27._TM27_CODGREEM = fila["TM27_CODGREEM"].ToString(); //_etm27._TM27_UCREA = fila["TM27_UCREA"].ToString(); // _etm27._TM27_FCREA = Convert.ToDateTime(fila["TM27_FCREA"].ToString()); //_etm27._TM27_UACTUALIZA = fila["TM27_UACTUALIZA"].ToString(); //_etm27._TM27_FACTUALIZA = Convert.ToDateTime(fila["TM27_FACTUALIZA"].ToString()); _lista.Add(_etm27); } _Entidad._lista_et_m27 = _lista; _Entidad._hubo_error = false; } catch (SqlException exsql) { try { sqlTran.Rollback(); } catch (Exception exRollback) { } } catch (Exception ex) { Mensaje_error = string.Format("{1}{0}", Environment.NewLine, (Mensaje_error + ex.Message.ToString())); if (ex.InnerException != null) { Mensaje_error = string.Format("{1}{0}", Environment.NewLine, (Mensaje_error + "Inner exception: " + ex.InnerException.Message)); } Mensaje_error = string.Format("{1}{0}", Environment.NewLine, (Mensaje_error + "Stack trace: " + ex.StackTrace)); _Entidad._hubo_error = true; _Entidad._contenido_mensaje = Mensaje_error; _Entidad._titulo_mensaje = "Error!"; } finally { cn.Close(); } return(_Entidad); } }
public ET_entidad obtener_locales_por_cliente(ET_M19 objEntity) { return(_dtm27.sel_001(objEntity)); }