Beispiel #1
0
        public static Common.Models.Office.Office GetOffice(DataRow row)
        {
            Common.Models.Office.Office office = new Common.Models.Office.Office();

            office.OfficeId = Conversion.TryCastInteger(ConversionHelper.GetColumnValue(row, "office_id"));
            office.OfficeCode = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "office_code"));
            office.OfficeName = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "office_name"));
            office.Nickname = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "nick_name"));
            office.RegistrationDate = Conversion.TryCastDate(ConversionHelper.GetColumnValue(row, "registration_date"));
            office.CurrencyCode = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "currency_code"));
            office.AddressLine1 = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "address_line_1"));
            office.AddressLine2 = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "address_line_2"));
            office.Street = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "street"));
            office.City = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "city"));
            office.State = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "state"));
            office.ZipCode = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "zip_code"));
            office.Country = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "country"));
            office.Phone = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "phone"));
            office.Fax = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "fax"));
            office.Email = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "email"));
            office.Url = new Uri(Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "url")), UriKind.RelativeOrAbsolute);
            office.RegistrationNumber = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "registration_number"));
            office.PanNumber = Conversion.TryCastString(ConversionHelper.GetColumnValue(row, "pan_number"));
            office.ParentOfficeId = Conversion.TryCastInteger(ConversionHelper.GetColumnValue(row, "parent_office_id"));
            office.ParentOffice = GetOffice(office.ParentOfficeId);

            return office;
        }
Beispiel #2
0
        public static Common.Models.Office.Office GetOffice(int? officeId)
        {
            Common.Models.Office.Office office = new Common.Models.Office.Office();

            if (officeId != null && officeId != 0)
            {
                const string sql = "SELECT * FROM office.offices WHERE office_id=@OfficeId;";
                using (NpgsqlCommand command = new NpgsqlCommand(sql))
                {
                    command.Parameters.AddWithValue("@OfficeId", officeId);
                    using (DataTable table = DbOperations.GetDataTable(command))
                    {
                        if (table != null)
                        {
                            if (table.Rows.Count.Equals(1))
                            {
                                office = GetOffice(table.Rows[0]);
                            }
                        }
                    }
                }
            }

            return office;
        }
Beispiel #3
0
        public static MixERP.Net.Common.Models.Office.Office GetOffice(int? officeId)
        {
            MixERP.Net.Common.Models.Office.Office office = new Common.Models.Office.Office();

            if (officeId != null || officeId != 0)
            {
                string sql = "SELECT * FROM office.offices WHERE office_id=@OfficeId;";
                using (NpgsqlCommand command = new NpgsqlCommand(sql))
                {
                    command.Parameters.Add("@OfficeId", officeId);
                    using (DataTable table = MixERP.Net.DBFactory.DBOperations.GetDataTable(command))
                    {
                        if (table != null)
                        {
                            if (table.Rows.Count.Equals(1))
                            {
                                office = GetOffice(table.Rows[0]);
                            }
                        }
                    }
                }
            }

            return office;
        }
Beispiel #4
0
        private static Common.Models.Office.Office GetOffice(DataRow row)
        {
            Common.Models.Office.Office office = new Common.Models.Office.Office();

            office.OfficeId         = Conversion.TryCastInteger(DataRowHelper.GetColumnValue(row, "office_id"));
            office.OfficeCode       = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "office_code"));
            office.OfficeName       = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "office_name"));
            office.Nickname         = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "nick_name"));
            office.RegistrationDate = Conversion.TryCastDate(DataRowHelper.GetColumnValue(row, "registration_date"));
            office.CurrencyCode     = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "currency_code"));
            office.AddressLine1     = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "address_line_1"));
            office.AddressLine2     = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "address_line_2"));
            office.Street           = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "street"));
            office.City             = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "city"));
            office.State            = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "state"));
            office.ZipCode          = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "zip_code"));
            office.Country          = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "country"));
            office.Phone            = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "phone"));
            office.Fax   = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "fax"));
            office.Email = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "email"));
            office.Url   = new Uri(Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "url")),
                                   UriKind.RelativeOrAbsolute);
            office.RegistrationNumber =
                Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "registration_number"));
            office.PanNumber      = Conversion.TryCastString(DataRowHelper.GetColumnValue(row, "pan_number"));
            office.ParentOfficeId = Conversion.TryCastInteger(DataRowHelper.GetColumnValue(row, "parent_office_id"));
            office.ParentOffice   = GetOffice(office.ParentOfficeId);

            return(office);
        }
Beispiel #5
0
        private static Common.Models.Office.Office GetOffice(int?officeId)
        {
            Common.Models.Office.Office office = new Common.Models.Office.Office();

            if (officeId != null && officeId != 0)
            {
                const string sql = "SELECT * FROM office.offices WHERE office_id=@OfficeId;";
                using (NpgsqlCommand command = new NpgsqlCommand(sql))
                {
                    command.Parameters.AddWithValue("@OfficeId", officeId);
                    using (DataTable table = DbOperations.GetDataTable(command))
                    {
                        if (table != null)
                        {
                            if (table.Rows.Count.Equals(1))
                            {
                                office = GetOffice(table.Rows[0]);
                            }
                        }
                    }
                }
            }

            return(office);
        }
Beispiel #6
0
        private static Collection <Common.Models.Office.Office> GetOffices(DataTable table)
        {
            Collection <Common.Models.Office.Office> officeCollection = new Collection <Common.Models.Office.Office>();

            if (table == null || table.Rows.Count.Equals(0))
            {
                return(officeCollection);
            }

            foreach (DataRow row in table.Rows)
            {
                if (row != null)
                {
                    Common.Models.Office.Office office = GetOffice(row);

                    officeCollection.Add(office);
                }
            }

            return(officeCollection);
        }