Example #1
0
 public void CheckPrice()
 {
     System.Data.DataRow row = ((System.Data.DataRowView)_colView.CurrentItem).Row;
     if (row.IsNull("amount") || double.Parse(row["amount"].ToString()) <= 0)
     {
         if (row.IsNull("pricing_opt") || int.Parse(row["pricing_opt"].ToString()) != 3)
         {
             row.SetColumnError("amount", "Enter price");
         }
         else
         {
             row.SetColumnError("amount", "");
         }
     }
     else
     {
         row.SetColumnError("amount", "");
     }
 }
Example #2
0
        protected override void DumpControls()
        {
/*
 *                      _row = sy_Usuarios.GetByPk(this._idUsuario);
 *                      string encriptada = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64( this._claveNueva2 );
 *                      _row.Clave = encriptada;
 *                      _data.sy_Usuarios.ImportRow(_row);
 *
 * */
            System.Data.DataTable tableUsuarios         = _data.Tables["sy_Usuarios"];
            System.Data.DataTable tableUsuariosPerfiles = _data.Tables["sy_PerfilesUsuariosEmpresas"];
            System.Data.DataRow   rowUsuarios           = tableUsuarios.Rows[0];
            rowUsuarios["IdUsuario"] = txtNombreUsuario.Text;


            //rowUsuarios["Clave"] = ultraTextEditor1.Text;
            string encriptada = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64(ultraTextEditor1.Text);

            rowUsuarios["Clave"] = encriptada;
            string IdPersona = Convert.ToString(mzCmbPersona.DataValue);

            if (IdPersona != null && !IdPersona.Equals(string.Empty))
            {
                rowUsuarios["IdPersona"] = IdPersona;
                System.Data.DataRow row = mz.erp.businessrules.tsh_Personas.GetByPk(IdPersona);
                if (row != null)
                {
                    rowUsuarios["Nombre"] = row["Nombre"];
                }
                else
                {
                    rowUsuarios["Nombre"] = txtNombreUsuario.Text;
                }
            }
            rowUsuarios["VencimientoClave"]   = mz.erp.businessrules.Sistema.DateTime.Now;
            rowUsuarios["HabilitacionCuenta"] = mz.erp.businessrules.Sistema.DateTime.Now;
            rowUsuarios["Expiracion"]         = mz.erp.businessrules.Sistema.DateTime.Now;
            rowUsuarios["Activo"]             = chkActivo.Checked;
            //Viviana
            rowUsuarios["Equipo"] = this.equipo.Value;
            if (!ultraTextEditor1.Text.Equals(uteConfirmaPassword.Text))
            {
                rowUsuarios.SetColumnError("Clave", "Las claves no coinciden");
            }

            //if(this.State.Equals("NEW"))
            //{
            for (int i = 0; i < perfiles.Count; i++)                  //por cada item
            {
                bool   ok = false;
                Perfil p  = (Perfil)perfiles[i];
                if (p.Tildado)                        //si esta tildado --> lo agrego (si no está)
                {
                    foreach (System.Data.DataRow row in tableUsuariosPerfiles.Rows)
                    {
                        if (row.RowState != System.Data.DataRowState.Deleted)
                        {
                            if ((long)row["IdPerfil"] == Convert.ToInt64(p.IdPerfil))
                            {
                                row["IdUsuario"] = txtNombreUsuario.Text;
                                ok = true;
                                break;
                            }
                        }
                    }
                    if (!ok)
                    {
                        System.Data.DataRow row = mz.erp.businessrules.sy_PerfilesUsuariosEmpresas.NewRow();
                        row["IdUsuario"] = txtNombreUsuario.Text;
                        row["IdPerfil"]  = p.IdPerfil;
                        row["IdEmpresa"] = Security.IdEmpresa;
                        tableUsuariosPerfiles.LoadDataRow(row.ItemArray, false);
                    }
                }
                else                                  //si no esta tildado
                {
                    if (p.Tildado != p.EstadoInicial) // y es distinto del estado anterior -->(borrarlo de la base)
                    {
                        foreach (System.Data.DataRow row in tableUsuariosPerfiles.Rows)
                        {
                            if (row.RowState != System.Data.DataRowState.Deleted)
                            {
                                string IdPerfil  = Convert.ToString(row["IdPerfil"]);
                                string IdUsuario = Convert.ToString(row["IdUsuario"]);
                                if (p.IdPerfil == IdPerfil && txtNombreUsuario.Text == IdUsuario)
                                {                                           //borro la tupla
                                    row.Delete();
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            //}

            //Modifico los responsables de las secciones
            sy_UsuariosExDataset.tlg_ResponsablesDepositosSeccionesDataTable tableResponsablesSecciones = (sy_UsuariosExDataset.tlg_ResponsablesDepositosSeccionesDataTable)_data.Tables["tlg_ResponsablesDepositosSecciones"];
            string IdUsu = (string)rowUsuarios["IdUsuario"];

            foreach (TreeNode nodeD in treeViewSecciones.Nodes)
            {
                string IdDeposito = (string)idsTree[nodeD];
                foreach (TreeNode nodeS in nodeD.Nodes)
                {
                    string IdSeccion = (string)idsTree[nodeS];
                    sy_UsuariosExDataset.tlg_ResponsablesDepositosSeccionesRow rowRS = tableResponsablesSecciones.FindByIdUsuarioIdDepositoIdSeccion(IdUsu, IdDeposito, IdSeccion);
                    if (nodeS.Checked)                   //si esta tildado --> lo agrego (si no está)
                    {
                        if (rowRS == null)
                        {
                            rowRS                    = tableResponsablesSecciones.Newtlg_ResponsablesDepositosSeccionesRow();
                            rowRS.IdUsuario          = IdUsu;
                            rowRS.IdDeposito         = IdDeposito;
                            rowRS.IdSeccion          = IdSeccion;
                            rowRS.Activo             = true;
                            rowRS.FechaCreacion      = DateTime.Now;
                            rowRS.IdConexionCreacion = Security.IdConexion;
                            tableResponsablesSecciones.LoadDataRow(rowRS.ItemArray, false);
                        }
                    }
                    else                    //si no esta tildado --> lo borro (si está)
                    {
                        if (rowRS != null)
                        {
                            rowRS.Delete();
                        }
                    }
                }
            }
        }