Пример #1
0
        public bool UpdateCarrier(int id, string name, string contactFirstName, string contactLastName, string address, string city, string state, string postal, string phone, string email, string fax, string note)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ApplicationException("You must provide a Carrier Name.");
            }

            SPG.CarriersDataTable carriers = Adapter.GetCarrierByID(id);

            if (carriers.Count() == 0)
            {
                //It is a new carriers
                return(InsertCarrier(id, name, contactFirstName, contactLastName, address, city, state, postal, phone, email, fax, note));
            }

            SPG.CarriersRow carrier = carriers[0];

            object[] originalRecord = carrier.ItemArray;

            SetCarrierFields(name, contactFirstName, contactLastName, address, city, state, postal, phone, email, fax, note, carrier);

            if (!(originalRecord == null))
            {
                UpdateAuditTrail(carrier, originalRecord);
            }

            int rowsAffected = Adapter.Update(carrier);

            return(rowsAffected == 1);
        }
Пример #2
0
        public bool DeleteCarrier(int id)
        {
            SPG.CarriersDataTable carriers = Adapter.GetCarrierByID(id);
            int rowsAffected = 0;

            if (carriers.Count() == 1)
            {
                SPG.CarriersRow carrier = (SPG.CarriersRow)carriers.Rows[0];
                rowsAffected = Adapter.Delete(id, carrier.ts);
            }

            //Return true if precisely one row was deleted, otherwise return false.
            return(rowsAffected == 1);
        }
Пример #3
0
        public bool InsertCarrier(int id, string name, string contactFirstName, string contactLastName, string address, string city, string state, string postal, string phone, string email, string fax, string note)
        {
            SPG.CarriersDataTable carriers = new SPG.CarriersDataTable();
            SPG.CarriersRow       carrier  = carriers.NewCarriersRow();

            carrier.CarrierID = id;
            SetCarrierFields(name, contactFirstName, contactLastName, address, city, state, postal, phone, email, fax, note, carrier);
            carrier.EnteredBy = Properties.Settings.Default.UserName;
            carrier.EnteredOn = DateTime.Now;

            carriers.AddCarriersRow(carrier);
            int rowsAffected = Adapter.Update(carriers);

            return(rowsAffected == 1);
        }
Пример #4
0
        public void BindCarrierControls(int carrierID)
        {
            SPG.CarriersRow carrier = (SPG.CarriersRow)(m_Carriers.GetCarrierByID(carrierID).Rows[0]);

            m_CurrentCarrierID     = carrier.CarrierID;
            nameTextEdit.Text      = carrier.CarrierName;
            firstNameTextEdit.Text = carrier.ContactFirstName;
            lastNameTextEdit.Text  = carrier.ContactLastName;
            addressTextEdit.Text   = carrier.Address;
            cityTextEdit.Text      = carrier.City;
            stateTextEdit.Text     = carrier.State;
            postalTextEdit.Text    = carrier.Postal;
            phoneTextEdit.Text     = carrier.Phone;
            emailTextEdit.Text     = carrier.Email;
            faxTextEdit.Text       = carrier.Fax;
            noteMemoEdit.Text      = carrier.Note;
        }
Пример #5
0
        private void UpdateAuditTrail(SPG.CarriersRow ModifiedRecord, object[] originalRecord)
        {
            StringBuilder builder      = new StringBuilder(string.Empty);
            int           recordFields = (ModifiedRecord.ItemArray.Length - 1);
            int           i            = 0;

            while (i <= recordFields)
            {
                try
                {
                    if (Convert.IsDBNull(originalRecord[i]))
                    {
                        if (!Convert.IsDBNull(ModifiedRecord[i]))
                        {
                            builder.Append(string.Format("{0}:{1}({2}); ", ModifiedRecord.Table.Columns[i].ColumnName, "NULL", ModifiedRecord[i]));
                        }
                    }
                    else if (Convert.IsDBNull(ModifiedRecord[i]))
                    {
                        if (!Convert.IsDBNull(originalRecord[i]))
                        {
                            builder.Append(string.Format("{0}:{1}({2}); ", ModifiedRecord.Table.Columns[i].ColumnName, originalRecord[i], "NULL"));
                        }
                    }
                    else if (ModifiedRecord[i] != originalRecord[i])
                    {
                        builder.Append(string.Format("{0}:{1}({2}); ", ModifiedRecord.Table.Columns[i].ColumnName, originalRecord[i], ModifiedRecord[i]));
                    }
                }
                catch
                {
                }
                i += 1;
            }
            if (builder.Length > 2)
            {
                builder.Length = (builder.Length - 2);
                AuditTrailBLL.AddTrailEntry(Properties.Settings.Default.UserName, Convert.ToInt32(ModifiedRecord[0]), "Carriers", builder.ToString());
            }
        }
Пример #6
0
 private static void SetCarrierFields(string name, string contactFirstName, string contactLastName, string address, string city, string state, string postal, string phone, string email, string fax, string note, SPG.CarriersRow carrier)
 {
     carrier.CarrierName = name;
     if (string.IsNullOrEmpty(contactFirstName))
     {
         carrier.SetContactFirstNameNull();
     }
     else
     {
         carrier.ContactFirstName = contactFirstName;
     }
     if (string.IsNullOrEmpty(contactLastName))
     {
         carrier.SetContactLastNameNull();
     }
     else
     {
         carrier.ContactLastName = contactLastName;
     }
     if (string.IsNullOrEmpty(address))
     {
         carrier.SetAddressNull();
     }
     else
     {
         carrier.Address = address;
     }
     if (string.IsNullOrEmpty(city))
     {
         carrier.SetCityNull();
     }
     else
     {
         carrier.City = city;
     }
     if (string.IsNullOrEmpty(state))
     {
         carrier.SetStateNull();
     }
     else
     {
         carrier.State = state;
     }
     if (string.IsNullOrEmpty(postal))
     {
         carrier.SetPostalNull();
     }
     else
     {
         carrier.Postal = postal;
     }
     if (string.IsNullOrEmpty(phone))
     {
         carrier.SetPhoneNull();
     }
     else
     {
         carrier.Phone = phone;
     }
     if (string.IsNullOrEmpty(email))
     {
         carrier.SetEmailNull();
     }
     else
     {
         carrier.Email = email;
     }
     if (string.IsNullOrEmpty(fax))
     {
         carrier.SetFaxNull();
     }
     else
     {
         carrier.Fax = fax;
     }
     if (string.IsNullOrEmpty(note))
     {
         carrier.SetNoteNull();
     }
     else
     {
         carrier.Note = note;
     }
 }