public void Validate()
        {
            System.Data.OleDb.OleDbConnection con = Db.Connection;
            OleDbCommand cmd = con.CreateCommand();

            if (IncomingNumber != null && IncomingNumber.Length != 0)
            {
                cmd.CommandText = @"select count(1) from documents where IncomingNumber=?  and id <> ?";
                cmd.Parameters.Clear();
                cmd.Parameters.Add(new OleDbParameter("IncomingNumber", IncomingNumber));
                cmd.Parameters.Add(new OleDbParameter("id", m_Id));
                bool exists = (bool)((int)cmd.ExecuteScalar() != 0);
                if (exists)
                {
                    cmd.Dispose();
                    throw new BipGenericException(BipResources.GetString("StrDocIncomingNumberIsNotUnique"));
                }
            }

            if (OutgoingNumber != null && OutgoingNumber.Length != 0)
            {
                cmd.CommandText = @"select count(1) from documents where OutgoingNumber=?  and id <> ?";
                cmd.Parameters.Clear();
                cmd.Parameters.Add(new OleDbParameter("OutgoingNumber", OutgoingNumber));
                cmd.Parameters.Add(new OleDbParameter("id", m_Id));
                bool exists = (bool)((int)cmd.ExecuteScalar() != 0);
                if (exists)
                {
                    cmd.Dispose();
                    throw new BipGenericException(BipResources.GetString("StrDocOutgoingNumberIsNotUnique"));
                }
            }
            cmd.Dispose();
        }
示例#2
0
        public static string FilterDateRange(string field, DateTime fromDate, DateTime toDate)
        {
            // fixed
            if (fromDate == DateTime.MinValue &&
                toDate == DateTime.MinValue)
            {
                return("");
            }

            if (toDate != DateTime.MinValue && fromDate > toDate)
            {
                throw new  BipGenericException(BipResources.GetString("StrInvalidDateRange"));
            }

            string filter = "";

            if (fromDate != DateTime.MinValue)
            {
                filter = GetDateDiffSqlExpression(field, fromDate) + " <= 0 ";
                if (toDate != DateTime.MinValue)
                {
                    filter += " AND ";
                }
            }

            if (toDate != DateTime.MinValue)
            {
                filter += GetDateDiffSqlExpression(field, toDate) + " >= 0 ";
            }

            return(" ( " + filter.ToString() + " ) ");
        }
示例#3
0
 public static string GetRoleName(string role)
 {
     for (int i = 0; i < m_UserRoles.Length; i++)
     {
         if (m_UserRoles[i] == role)
         {
             return(BipResources.GetString(m_UserRoleNames[i]));
         }
     }
     return(BipResources.GetString(m_UserRoleNames[m_UserRoleNames.Length - 1]));
 }
示例#4
0
        public static DataTable GetRoleTable()
        {
            DataTable roles = new DataTable();

            roles.Columns.Add("Id");
            roles.Columns.Add("Name");
            for (int i = 0; i < m_UserRoles.Length; i++)
            {
                roles.Rows.Add(new string[] { m_UserRoles[i], BipResources.GetString(m_UserRoleNames[i]) });
            }
            return(roles);
        }
示例#5
0
        protected void Validate()
        {
            if (m_Login.Length == 0 || m_Role.Length == 0)
            {
                throw new BipGenericException(BipResources.GetString("StrRequiredParameterNotSpecified"));
            }

            System.Data.OleDb.OleDbConnection con = Db.Connection;
            OleDbCommand cmd = con.CreateCommand();

            cmd.CommandText = @"select count(1) from users where Login=? and id <> ?";
            cmd.Parameters.Add(new OleDbParameter("Login", m_Login));
            cmd.Parameters.Add(new OleDbParameter("id", m_Id));
            bool LoginExists = (bool)((int)cmd.ExecuteScalar() != 0);

            cmd.Dispose();
            if (LoginExists)
            {
                throw new BipGenericException(BipResources.GetString("StrSpecifiedNameIsNotUnique"));
            }
        }
        protected void Validate()
        {
            if (m_Name.Length == 0)
            {
                throw new Exception("StrRequiredParameterNotSpecified");
            }

            System.Data.OleDb.OleDbConnection con = Db.Connection;
            OleDbCommand cmd = con.CreateCommand();

            cmd.CommandText = @"select count(1) from " + this.GetDbTableName() +
                              @" where name=? and id <> ?";

            cmd.Parameters.Add(new OleDbParameter("name", m_Name));
            cmd.Parameters.Add(new OleDbParameter("id", m_Id));
            bool nameExists = (bool)((int)cmd.ExecuteScalar() != 0);

            cmd.Dispose();
            if (nameExists)
            {
                throw new BipGenericException(BipResources.GetString("StrSpecifiedNameIsNotUnique"));
            }
        }
 public BipAccessDeniedException()
     : base(BipResources.GetString("StrAccessDeniedException"))
 {
 }
 public BipObjectNotFoundException()
     : base(BipResources.GetString("StrObjectNotFoundException"))
 {
 }