Exemple #1
0
        /// <summary>
        /// DropDownForClient
        /// Calls [usp_dropdown_Division_for_Client]
        /// </summary>
        public override List <DivisionDetails> DropDownForClient(System.Int32?clientId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_dropdown_Division_for_Client", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
                cn.Open();
                DbDataReader           reader = ExecuteReader(cmd);
                List <DivisionDetails> lst    = new List <DivisionDetails>();
                while (reader.Read())
                {
                    DivisionDetails obj = new DivisionDetails();
                    obj.DivisionId   = GetReaderValue_Int32(reader, "DivisionId", 0);
                    obj.DivisionName = GetReaderValue_String(reader, "DivisionName", "");
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Divisions", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Exemple #2
0
        /// <summary>
        /// GetHasDocumentHeader
        /// Calls [usp_select_Division_HasDocumentHeader]
        /// </summary>
        public override DivisionDetails GetHasDocumentHeader(System.Int32?divisionId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_Division_HasDocumentHeader", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@DivisionId", SqlDbType.Int).Value = divisionId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetDivisionFromReader(reader);
                    DivisionDetails obj = new DivisionDetails();
                    obj.HasDocumentHeaderImage     = GetReaderValue_Boolean(reader, "HasDocumentHeaderImage", false);
                    obj.UseCompanyHeaderForInvoice = GetReaderValue_Boolean(reader, "UseCompanyHeaderForInvoice", false);
                    return(obj);
                }
                else
                {
                    return(null);
                }
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Division", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Exemple #3
0
        /// <summary>
        /// Get
        /// Calls [usp_select_Division]
        /// </summary>
        public override DivisionDetails Get(System.Int32?divisionId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_Division", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@DivisionId", SqlDbType.Int).Value = divisionId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetDivisionFromReader(reader);
                    DivisionDetails obj = new DivisionDetails();
                    obj.DivisionId                 = GetReaderValue_Int32(reader, "DivisionId", 0);
                    obj.ClientNo                   = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.DivisionName               = GetReaderValue_String(reader, "DivisionName", "");
                    obj.AddressNo                  = GetReaderValue_NullableInt32(reader, "AddressNo", null);
                    obj.Manager                    = GetReaderValue_NullableInt32(reader, "Manager", null);
                    obj.Budget                     = GetReaderValue_NullableDouble(reader, "Budget", null);
                    obj.Telephone                  = GetReaderValue_String(reader, "Telephone", "");
                    obj.Fax                        = GetReaderValue_String(reader, "Fax", "");
                    obj.EMail                      = GetReaderValue_String(reader, "EMail", "");
                    obj.Notes                      = GetReaderValue_String(reader, "Notes", "");
                    obj.URL                        = GetReaderValue_String(reader, "URL", "");
                    obj.Inactive                   = GetReaderValue_Boolean(reader, "Inactive", false);
                    obj.HasDocumentHeaderImage     = GetReaderValue_Boolean(reader, "HasDocumentHeaderImage", false);
                    obj.UseCompanyHeaderForInvoice = GetReaderValue_Boolean(reader, "UseCompanyHeaderForInvoice", false);
                    obj.UpdatedBy                  = GetReaderValue_NullableInt32(reader, "UpdatedBy", null);
                    obj.DLUP                       = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue);
                    obj.ManagerName                = GetReaderValue_String(reader, "ManagerName", "");
                    obj.Agency                     = GetReaderValue_NullableBoolean(reader, "Agency", false);
                    return(obj);
                }
                else
                {
                    return(null);
                }
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Division", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Exemple #4
0
        /// <summary>
        /// GetListForClient
        /// Calls [usp_selectAll_Division_for_Client]
        /// </summary>
        public override List <DivisionDetails> GetListForClient(System.Int32?clientId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_selectAll_Division_for_Client", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
                cn.Open();
                DbDataReader           reader = ExecuteReader(cmd);
                List <DivisionDetails> lst    = new List <DivisionDetails>();
                while (reader.Read())
                {
                    DivisionDetails obj = new DivisionDetails();
                    obj.DivisionId      = GetReaderValue_Int32(reader, "DivisionId", 0);
                    obj.ClientNo        = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.DivisionName    = GetReaderValue_String(reader, "DivisionName", "");
                    obj.Manager         = GetReaderValue_NullableInt32(reader, "Manager", null);
                    obj.Budget          = GetReaderValue_NullableDouble(reader, "Budget", null);
                    obj.Telephone       = GetReaderValue_String(reader, "Telephone", "");
                    obj.Fax             = GetReaderValue_String(reader, "Fax", "");
                    obj.EMail           = GetReaderValue_String(reader, "EMail", "");
                    obj.Notes           = GetReaderValue_String(reader, "Notes", "");
                    obj.URL             = GetReaderValue_String(reader, "URL", "");
                    obj.Inactive        = GetReaderValue_Boolean(reader, "Inactive", false);
                    obj.UpdatedBy       = GetReaderValue_NullableInt32(reader, "UpdatedBy", null);
                    obj.DLUP            = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue);
                    obj.ManagerName     = GetReaderValue_String(reader, "ManagerName", "");
                    obj.NumberOfMembers = GetReaderValue_NullableInt32(reader, "NumberOfMembers", null);
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Divisions", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Exemple #5
0
        private static Division PopulateFromDBDetailsObject(DivisionDetails obj)
        {
            Division objNew = new Division();

            objNew.DivisionId                 = obj.DivisionId;
            objNew.ClientNo                   = obj.ClientNo;
            objNew.DivisionName               = obj.DivisionName;
            objNew.AddressNo                  = obj.AddressNo;
            objNew.Manager                    = obj.Manager;
            objNew.Budget                     = obj.Budget;
            objNew.Telephone                  = obj.Telephone;
            objNew.Fax                        = obj.Fax;
            objNew.EMail                      = obj.EMail;
            objNew.Notes                      = obj.Notes;
            objNew.URL                        = obj.URL;
            objNew.Inactive                   = obj.Inactive;
            objNew.HasDocumentHeaderImage     = obj.HasDocumentHeaderImage;
            objNew.UseCompanyHeaderForInvoice = obj.UseCompanyHeaderForInvoice;
            objNew.UpdatedBy                  = obj.UpdatedBy;
            objNew.DLUP                       = obj.DLUP;
            objNew.ManagerName                = obj.ManagerName;
            objNew.NumberOfMembers            = obj.NumberOfMembers;
            return(objNew);
        }