public void SetValorEnDS(int posicion = 0) { string valor = "0"; try { if (CampoData == null) { CampoData = ""; } if ((DSData != null) && (CampoData.Trim() != "")) { if ((this.DataSource != null) && (this.ValueMember.Trim() != "") && (this.SelectedValue != null)) { valor = this.SelectedValue.ToString(); } else if ((this.Items.Count > 0) && (this.SelectedItem != null)) { valor = this.SelectedIndex.ToString(); } else if (this.Text.Trim() != "") { valor = this.Text.Trim(); } if (NombreTabla.Trim() == "") { DSData.Tables[0].Rows[posicion][CampoData] = valor; } else { DSData.Tables[NombreTabla].Rows[posicion][CampoData] = valor; } } } catch (Exception) { throw; } }
public void GetValorFromDS(bool esNuevo, int posicion = 0) { string valor = "0"; try { if (!esNuevo) { this.Enabled = EsEditable; } if (ValorPorDefecto.Trim() == "") { ValorPorDefecto = "0"; } LlenarCombo(); if (DSData != null) { if (esNuevo) { valor = ValorPorDefecto; } else if (NombreTabla.Trim() == "" && CampoData.Trim() != "") { if (DSData.Tables[0].Rows[posicion][CampoData] is DBNull) { valor = ValorPorDefecto; } else { valor = DSData.Tables[0].Rows[posicion][CampoData].ToString(); } } else if (CampoData.Trim() != "") { if (DSData.Tables[NombreTabla].Rows[posicion][CampoData] is DBNull) { valor = ValorPorDefecto; } else { valor = DSData.Tables[NombreTabla].Rows[posicion][CampoData].ToString(); } } if ((this.DataSource != null) && (this.ValueMember.Trim() != "")) { this.SelectedValue = valor; this.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; } else if (this.Items.Count > 0) { this.SelectedIndex = int.Parse(valor); this.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; } else { this.Text = valor; } } } catch (Exception) { throw; } }
public void SetValorEnDS(int posicion = 0) { ELRUtils util = new ELRUtils(); try { if (CampoData == null) { CampoData = ""; } if (EsAutoGenerado) { this.Enabled = false; } if ((DSData != null) && (CampoData.Trim() != "")) { if ((!EsAutoGenerado) && (NombreTabla.Trim() == "")) { if (CampoData.ToUpper().Contains("CEDULA")) { DSData.Tables[0].Rows[posicion][CampoData] = util.FormatearCedulaRNC(this.Text).Trim(); } else if (CampoData.ToUpper().Contains("RNC")) { DSData.Tables[0].Rows[posicion][CampoData] = util.FormatearCedulaRNC(this.Text).Trim(); } else if (CampoData.ToUpper().Contains("TELEFONO")) { DSData.Tables[0].Rows[posicion][CampoData] = util.FormatearTelefono(this.Text).Trim(); } else if (CampoData.ToUpper().Contains("CELULAR")) { DSData.Tables[0].Rows[posicion][CampoData] = util.FormatearTelefono(this.Text).Trim(); } else { DSData.Tables[0].Rows[posicion][CampoData] = this.Text.Trim(); } } else if (!EsAutoGenerado) { if (CampoData.ToUpper().Contains("CEDULA")) { DSData.Tables[NombreTabla].Rows[posicion][CampoData] = util.FormatearCedulaRNC(this.Text).Trim(); } else if (CampoData.ToUpper().Contains("RNC")) { DSData.Tables[NombreTabla].Rows[posicion][CampoData] = util.FormatearCedulaRNC(this.Text).Trim(); } else if (CampoData.ToUpper().Contains("TELEFONO")) { DSData.Tables[NombreTabla].Rows[posicion][CampoData] = util.FormatearTelefono(this.Text).Trim(); } else if (CampoData.ToUpper().Contains("CELULAR")) { DSData.Tables[NombreTabla].Rows[posicion][CampoData] = util.FormatearTelefono(this.Text).Trim(); } else { DSData.Tables[NombreTabla].Rows[posicion][CampoData] = this.Text.Trim(); } } } } catch (Exception) { throw; } }