Пример #1
0
 public void GetValorFromDS(bool esNuevo, int posicion = 0)
 {
     try
     {
         if (DSData != null)
         {
             if (esNuevo)
             {
                 this.Text = ValorPorDefecto;
             }
             if (NombreTabla.Trim() == "")
             {
                 this.Text = DSData.Tables[0].Rows[posicion][CampoData].ToString();
             }
             else
             {
                 this.Text = DSData.Tables[NombreTabla].Rows[posicion][CampoData].ToString();
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
        public void GetValorFromDS(bool esNuevo, int posicion = 0)
        {
            DateTime valor;
            TimeSpan hora;
            DateTime fechaActual = DateTime.Now.Date;

            try
            {
                if (DSData != null)
                {
                    if (esNuevo)
                    {
                        this.Value = ValorPorDefecto;
                    }
                    else if (NombreTabla.Trim() == "")
                    {
                        if (DSData.Tables[0].Rows[posicion][CampoData] is DBNull)
                        {
                            valor = DateTime.Now;
                        }
                        else
                        {
                            if (DSData.Tables[0].Rows[posicion][CampoData] is TimeSpan)
                            {
                                hora  = (TimeSpan)DSData.Tables[0].Rows[posicion][CampoData];
                                valor = new DateTime(fechaActual.Year, fechaActual.Month, fechaActual.Day, hora.Hours, hora.Minutes, hora.Seconds);
                            }
                            else
                            {
                                valor = (DateTime)DSData.Tables[0].Rows[posicion][CampoData];
                            }
                        }

                        this.Value = valor;
                    }
                    else
                    {
                        if (DSData.Tables[NombreTabla].Rows[posicion][CampoData] is DBNull)
                        {
                            valor = DateTime.Now;
                        }
                        else
                        {
                            if (DSData.Tables[NombreTabla].Rows[posicion][CampoData] is TimeSpan)
                            {
                                hora  = (TimeSpan)DSData.Tables[NombreTabla].Rows[posicion][CampoData];
                                valor = new DateTime(fechaActual.Year, fechaActual.Month, fechaActual.Day, hora.Hours, hora.Minutes, hora.Seconds);
                            }
                            valor = (DateTime)DSData.Tables[NombreTabla].Rows[posicion][CampoData];
                        }

                        this.Value = valor;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            NombreTabla nombretabla = db.NombreTabla.Find(id);

            db.NombreTabla.Remove(nombretabla);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
        //
        // GET: /Titulo/Delete/5

        public ActionResult Delete(int id = 0)
        {
            NombreTabla nombretabla = db.NombreTabla.Find(id);

            if (nombretabla == null)
            {
                return(HttpNotFound());
            }
            return(View(nombretabla));
        }
Пример #5
0
 public ActionResult Edit(NombreTabla nombretabla)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nombretabla).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(nombretabla));
 }
Пример #6
0
        public ActionResult Create(NombreTabla nombretabla)
        {
            if (ModelState.IsValid)
            {
                db.NombreTabla.Add(nombretabla);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nombretabla));
        }
Пример #7
0
        public void SetValor(string valor, int posicion = 0)
        {
            this.Text = valor;

            if (DSData != null)
            {
                if (NombreTabla.Trim() == "")
                {
                    DSData.Tables[0].Rows[posicion][CampoData] = this.Text;
                }
                else
                {
                    DSData.Tables[NombreTabla].Rows[posicion][CampoData] = this.Text;
                }
            }
        }
        public void SetValor(decimal valor, int posicion = 0)
        {
            this.Value = valor;

            if (DSData != null)
            {
                if (NombreTabla.Trim() == "")
                {
                    DSData.Tables[0].Rows[posicion][CampoData] = this.Value;
                }
                else
                {
                    DSData.Tables[NombreTabla].Rows[posicion][CampoData] = this.Value;
                }
            }
        }
        public void GetValorFromDS(bool esNuevo, int posicion = 0)
        {
            try
            {
                if (DSData != null)
                {
                    if (esNuevo)
                    {
                        this.Value = ValorPorDefecto;
                    }
                    else if (NombreTabla.Trim() == "")
                    {
                        if (DSData.Tables[0].Rows[posicion][CampoData] is DBNull)
                        {
                            this.Value = ValorPorDefecto;
                        }
                        else
                        {
                            this.Value = decimal.Parse(DSData.Tables[0].Rows[posicion][CampoData].ToString());
                        }
                    }
                    else
                    {
                        if (DSData.Tables[NombreTabla].Rows[posicion][CampoData] is DBNull)
                        {
                            this.Value = ValorPorDefecto;
                        }
                        else
                        {
                            this.Value = decimal.Parse(DSData.Tables[NombreTabla].Rows[posicion][CampoData].ToString());
                        }
                    }
                }


                if ((!esNuevo) && (this.Enabled))
                {
                    this.Enabled = EsEditable;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #10
0
        public void SetValorEnDS(int posicion = 0)
        {
            TimeSpan hora;
            DateTime valor;

            try
            {
                if (DSData != null)
                {
                    if (NombreTabla.Trim() == "")
                    {
                        if ((DSData.Tables[0].Rows[posicion][CampoData] is TimeSpan) || (this.Format == System.Windows.Forms.DateTimePickerFormat.Time))
                        {
                            valor = this.Value;

                            hora = new TimeSpan(valor.Hour, valor.Minute, valor.Second);
                            DSData.Tables[0].Rows[posicion][CampoData] = hora;
                        }
                        else
                        {
                            DSData.Tables[0].Rows[posicion][CampoData] = this.Value;
                        }
                    }
                    else
                    {
                        if ((DSData.Tables[NombreTabla].Rows[posicion][CampoData] is TimeSpan) || (this.Format == System.Windows.Forms.DateTimePickerFormat.Time))
                        {
                            valor = this.Value;

                            hora = new TimeSpan(valor.Hour, valor.Minute, valor.Second);
                            DSData.Tables[NombreTabla].Rows[posicion][CampoData] = hora;
                        }
                        else
                        {
                            DSData.Tables[NombreTabla].Rows[posicion][CampoData] = this.Value;
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #11
0
        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;
            }
        }
Пример #12
0
 public void SetValorEnDS(int posicion = 0)
 {
     try
     {
         if (DSData != null)
         {
             if (NombreTabla.Trim() == "")
             {
                 DSData.Tables[0].Rows[posicion][CampoData] = this.Text;
             }
             else
             {
                 DSData.Tables[NombreTabla].Rows[posicion][CampoData] = this.Text;
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #13
0
        public void GetValorFromDS(bool esNuevo, int posicion = 0)
        {
            try
            {
                if (DSData != null)
                {
                    if (esNuevo)
                    {
                        this.Checked = ValorPorDefecto;
                    }
                    else if (NombreTabla.Trim() == "")
                    {
                        if (DSData.Tables[0].Rows[posicion][CampoData] is DBNull)
                        {
                            this.Checked = false;
                        }
                        else
                        {
                            this.Checked = (bool)DSData.Tables[0].Rows[posicion][CampoData];
                        }
                    }

                    else
                    {
                        if (DSData.Tables[NombreTabla].Rows[posicion][CampoData] is DBNull)
                        {
                            this.Checked = false;
                        }
                        else
                        {
                            this.Checked = (bool)DSData.Tables[NombreTabla].Rows[posicion][CampoData];
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #14
0
        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;
            }
        }
Пример #15
0
        public void GetValorFromDS(bool esNuevo, int posicion = 0)
        {
            DataColumn MyColumna;
            DataRow    MyFila;
            ELRUtils   util   = new ELRUtils();
            string     NDecim = "N";

            string valor = "";

            try
            {
                valor = ValorPorDefecto;

                if (DSData != null)
                {
                    if (NombreTabla.Trim() == "")
                    {
                        if (!DSData.Tables[0].Columns.Contains(CampoData))
                        {
                            throw new Exception("El Campo [" + CampoData + "] No Existe!!");
                        }

                        MyColumna = DSData.Tables[0].Columns[CampoData];
                        MyFila    = DSData.Tables[0].Rows[posicion];
                    }
                    else
                    {
                        if (!DSData.Tables[NombreTabla].Columns.Contains(CampoData))
                        {
                            throw new Exception("El Campo [" + CampoData + "] No Existe!!");
                        }

                        MyColumna = DSData.Tables[NombreTabla].Columns[CampoData];
                        MyFila    = DSData.Tables[NombreTabla].Rows[posicion];
                    }

                    if (MyColumna.MaxLength > 0)
                    {
                        MaxLength = MyColumna.MaxLength;
                    }

                    //APLICAMOS FORMATO DECIMAL
                    if ((MyColumna.DataType == typeof(Decimal)) || (MyColumna.DataType == typeof(Double)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0.0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.DecimalPositivo;
                            if (Decimales <= 0)
                            {
                                Decimales = 2;
                            }
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        NDecim   += Decimales.ToString();
                        this.Text = util.ConvertirANumero(valor).ToString(NDecim);
                    }
                    else if ((MyColumna.DataType == typeof(Int16)) || (MyColumna.DataType == typeof(Int32)) || (MyColumna.DataType == typeof(Int64)) || (MyColumna.DataType == typeof(Single)) || (MyColumna.DataType == typeof(SByte)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.NumerosEnteros;
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        this.Text = valor;
                    }
                    else if ((MyColumna.DataType == typeof(UInt16)) || (MyColumna.DataType == typeof(UInt32)) || (MyColumna.DataType == typeof(UInt64)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.NumerosEnterosPositivos;
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        this.Text = valor;
                    }
                    else
                    {
                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila);
                        }

                        if (CampoData.ToUpper().Contains("CEDULA"))
                        {
                            valor = util.FormatearCedulaRNC(valor);
                        }
                        else if (CampoData.ToUpper().Contains("RNC"))
                        {
                            valor = util.FormatearCedulaRNC(valor);
                        }
                        else if (CampoData.ToUpper().Contains("TELEFONO"))
                        {
                            valor = util.FormatearTelefono(valor);
                        }
                        else if (CampoData.ToUpper().Contains("CELULAR"))
                        {
                            valor = util.FormatearTelefono(valor);
                        }


                        this.Text = valor.Trim();
                    }
                }

                if (EsAutoGenerado)
                {
                    this.Enabled = false;
                }
                if ((!esNuevo) && (this.Enabled))
                {
                    this.Enabled = EsEditable;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #16
0
        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;
            }
        }