Beispiel #1
0
        public static MCountry Select(MCountry ent, ref int Val)
        {
            MCountry result = new MCountry();

            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_Country_Sel", con);
                    cmd.CommandTimeout = 0;
                    cmd.Parameters.Add("@ICountryId", SqlDbType.Int).Value = ent.CountryId;
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();

                    Val = 1;

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            result.CountryId   = Convert.ToInt32(reader["CountryId"]);
                            result.ContinentId = Convert.ToInt32(reader["ContinentId"]);
                            result.Description = Convert.ToString(reader["Description"]);
                            result.Flag        = Convert.ToString(reader["Flag"]);
                            result.Status      = Convert.ToInt32(reader["Status"]);
                            result.Prefix      = Convert.ToString(reader["Prefix"]);

                            Val = 0;
                        }
                    }
                    con.Close();
                }

                catch (Exception ex)
                {
                    Val = 2;
                }
            }
            return(result);
        }
Beispiel #2
0
 public static MCountry Select(MCountry ent, ref int Val)
 {
     return(DACountry.Select(ent, ref Val));
 }
Beispiel #3
0
        public CreateDonorResponse ResetPassword([FromBody] DonorRequest request)
        {
            CreateDonorResponse response = new CreateDonorResponse();
            MDonor donor = new MDonor();

            try
            {
                /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }
                /*************FIN DEL METODO*************/

                donor.Email = request.Donor.Email;

                int refval = 0;

                donor = BDonor.ValidateDonor(donor, ref refval);

                if (refval.Equals(0))
                {
                    donor.Password = UEncrypt.Encrypt(UCommon.RandomNumber(1000, 9999).ToString());
                    donor.Token    = UCommon.GetTokem();

                    MCountry countryBE = new MCountry();
                    countryBE.CountryId = donor.CountryId;
                    countryBE           = BCountry.Select(countryBE, ref refval);

                    if (BDonor.UpdateCode(donor) == 0)
                    {
                        if (!request.Donor.Email.Equals(""))
                        {
                            SendSES(donor.Password, donor.Email);
                        }

                        response.Code    = "0";
                        response.Message = Messages.Success;
                    }
                    else
                    {
                        response.Code    = "2";
                        response.Message = String.Format(Messages.ErrorInsert, "Donor");
                    }
                }
                else
                {
                    donor.Cellphone = request.Donor.Cellphone;
                    donor.Email     = request.Donor.Email;
                    response.Code   = "1";

                    if (!donor.Email.Equals(""))
                    {
                        response.Message = "The email entered is not registered";
                    }
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            response.Donor = donor;

            return(response);
        }
Beispiel #4
0
        }   //  getWarehouses

        /* HTML5 */

        /// <summary>
        /// Load Preferences into Context for selected client.
        /// <para>
        /// Sets Org info in context and loads relevant field from
        /// - AD_Client/Info,
        /// - C_AcctSchema,
        /// - C_AcctSchema_Elements
        /// - AD_Preference
        /// </para>
        /// Assumes that the context is set for #AD_Client_ID, ##AD_User_ID, #AD_Role_ID
        /// </summary>
        /// <param name="org">org information</param>
        /// <param name="warehouse">optional warehouse information</param>
        /// <param name="timestamp">optional date</param>
        /// <param name="printerName">optional printer info</param>
        /// <returns>AD_Message of error (NoValidAcctInfo) or ""</returns>
        public String LoadPreferences(string date, String printerName)
        {
            if (m_ctx.GetContext("#AD_Client_ID").Length == 0)
            {
                throw new Exception("Missing Context #AD_Client_ID");
            }
            if (m_ctx.GetContext("##AD_User_ID").Length == 0)
            {
                throw new Exception("Missing Context ##AD_User_ID");
            }
            if (m_ctx.GetContext("#AD_Role_ID").Length == 0)
            {
                throw new Exception("Missing Context #AD_Role_ID");
            }

            string dateS = m_ctx.GetContext("#Date");

            DateTime dt    = DateTime.Now;
            long     today = CommonFunctions.CurrentTimeMillis();

            if (DateTime.TryParse(dateS, out dt))
            {
                today = CommonFunctions.CurrentTimeMillis(dt);
            }

            m_ctx.SetContext("#Date", today.ToString());

            //	Load User/Role Infos
            MUser user = MUser.Get(m_ctx, m_ctx.GetAD_User_ID());

            MUserPreference preference = user.GetPreference();
            MRole           role       = MRole.GetDefault(m_ctx);

            //	Optional Printer
            if (printerName == null)
            {
                printerName = "";
            }
            if (printerName.Length == 0 && preference.GetPrinterName() != null)
            {
                printerName = preference.GetPrinterName();
            }
            m_ctx.SetPrinterName(printerName);
            if (preference.GetPrinterName() == null && printerName.Length > 0)
            {
                preference.SetPrinterName(printerName);
            }

            //	Other
            m_ctx.SetAutoCommit(preference.IsAutoCommit());
            m_ctx.SetAutoNew(Ini.IsPropertyBool(Ini.P_A_NEW));
            if (role.IsShowAcct())
            {
                m_ctx.SetContext("#ShowAcct", preference.IsShowAcct());
            }
            else
            {
                m_ctx.SetContext("#ShowAcct", "N");
            }
            m_ctx.SetContext("#ShowTrl", preference.IsShowTrl());
            m_ctx.SetContext("#ShowAdvanced", preference.IsShowAdvanced());

            String retValue     = "";
            int    AD_Client_ID = m_ctx.GetAD_Client_ID();
            //	int AD_Org_ID =  org.getKey();
            //	int AD_User_ID =  Env.getAD_User_ID (m_ctx);
            int AD_Role_ID = m_ctx.GetAD_Role_ID();

            //	Other Settings
            m_ctx.SetContext("#YYYY", "Y");

            //	AccountSchema Info (first)
            String sql = "SELECT a.C_AcctSchema_ID, a.C_Currency_ID, a.HasAlias, c.ISO_Code, c.StdPrecision "
                         + "FROM C_AcctSchema a"
                         + " INNER JOIN AD_ClientInfo ci ON (a.C_AcctSchema_ID=ci.C_AcctSchema1_ID)"
                         + " INNER JOIN C_Currency c ON (a.C_Currency_ID=c.C_Currency_ID) "
                         + "WHERE ci.AD_Client_ID='" + AD_Client_ID + "'";
            IDataReader dr = null;

            try
            {
                int C_AcctSchema_ID = 0;
                dr = DataBase.DB.ExecuteReader(sql);

                if (!dr.Read())
                {
                    //  No Warning for System
                    if (AD_Role_ID != 0)
                    {
                        retValue = "NoValidAcctInfo";
                    }
                }
                else
                {
                    //	Accounting Info
                    C_AcctSchema_ID = Utility.Util.GetValueOfInt(dr[0].ToString());
                    m_ctx.SetContext("$C_AcctSchema_ID", C_AcctSchema_ID);
                    m_ctx.SetContext("$C_Currency_ID", Utility.Util.GetValueOfInt(dr[1].ToString()));
                    m_ctx.SetContext("$HasAlias", dr[2].ToString());
                    m_ctx.SetContext("$CurrencyISO", dr[3].ToString());
                    m_ctx.SetStdPrecision(Utility.Util.GetValueOfInt(dr[4].ToString()));
                }
                dr.Close();

                //	Accounting Elements
                sql = "SELECT ElementType "
                      + "FROM C_AcctSchema_Element "
                      + "WHERE C_AcctSchema_ID='" + C_AcctSchema_ID + "'"
                      + " AND IsActive='Y'";

                dr = DataBase.DB.ExecuteReader(sql);
                while (dr.Read())
                {
                    m_ctx.SetContext("$Element_" + dr["ElementType"].ToString(), "Y");
                }
                dr.Close();


                //	This reads all relevant window neutral defaults
                //	overwriting superseeded ones.  Window specific is read in Maintain
                sql = "SELECT Attribute, Value, AD_Window_ID "
                      + "FROM AD_Preference "
                      + "WHERE AD_Client_ID IN (0, @#AD_Client_ID@)"
                      + " AND AD_Org_ID IN (0, @#AD_Org_ID@)"
                      + " AND (AD_User_ID IS NULL OR AD_User_ID=0 OR AD_User_ID=@##AD_User_ID@)"
                      + " AND IsActive='Y' "
                      + "ORDER BY Attribute, AD_Client_ID, AD_User_ID DESC, AD_Org_ID";
                //	the last one overwrites - System - Client - User - Org - Window
                sql = Utility.Env.ParseContext(m_ctx, 0, sql, false);
                if (sql.Length == 0)
                {
                }
                else
                {
                    dr = DataBase.DB.ExecuteReader(sql);
                    while (dr.Read())
                    {
                        string AD_Window_ID = dr[2].ToString();
                        String at           = "";
                        if (string.IsNullOrEmpty(AD_Window_ID))
                        {
                            at = "P|" + dr[0].ToString();
                        }
                        else
                        {
                            at = "P" + AD_Window_ID + "|" + dr[0].ToString();
                        }
                        String va = dr[1].ToString();
                        m_ctx.SetContext(at, va);
                    }
                    dr.Close();
                }

                //	Default Values
                sql = "SELECT t.TableName, c.ColumnName "
                      + "FROM AD_Column c "
                      + " INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID) "
                      + "WHERE c.IsKey='Y' AND t.IsActive='Y'"
                      + " AND EXISTS (SELECT * FROM AD_Column cc "
                      + " WHERE ColumnName = 'IsDefault' AND t.AD_Table_ID=cc.AD_Table_ID AND cc.IsActive='Y')";

                dr = DataBase.DB.ExecuteReader(sql);
                while (dr.Read())
                {
                    LoadDefault(dr[0].ToString(), dr[1].ToString());
                }
                dr.Close();
            }
            catch
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }

            //Ini.SaveProperties(Ini.IsClient());
            //	Country
            m_ctx.SetContext("#C_Country_ID", MCountry.GetDefault(m_ctx).GetC_Country_ID());

            m_ctx.SetShowClientOrg(Ini.IsShowClientOrg() ? "Y" : "N");
            m_ctx.SetShowMiniGrid(Ini.GetProperty(Ini.P_Show_Mini_Grid));
            return(retValue);
        }       //	loadPreferences