Ejemplo n.º 1
0
 public static void CreatePharmacy(string name, string addr, string city, string state, string zip, string phone)
 {
     Pharmacies.Insert(new Pharmacy()
     {
         StoreName = name,
         Address   = addr,
         City      = city,
         State     = state,
         Zip       = zip,
         Phone     = phone,
     });
 }
Ejemplo n.º 2
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textStoreName.Text == "")
     {
         MessageBox.Show(Lan.g(this, "Store name cannot be blank."));
         return;
     }
     if (CultureInfo.CurrentCulture.Name == "en-US")
     {
         if (textPhone.Text != "" && TelephoneNumbers.FormatNumbersExactTen(textPhone.Text) == "")
         {
             MessageBox.Show(Lan.g(this, "Phone number must be in a 10-digit format."));
             return;
         }
         if (textFax.Text != "" && TelephoneNumbers.FormatNumbersExactTen(textFax.Text) == "")
         {
             MessageBox.Show(Lan.g(this, "Fax number must be in a 10-digit format."));
             return;
         }
     }
     PharmCur.StoreName = textStoreName.Text;
     PharmCur.PharmID   = "";
     PharmCur.Phone     = textPhone.Text;
     PharmCur.Fax       = textFax.Text;
     PharmCur.Address   = textAddress.Text;
     PharmCur.Address2  = textAddress2.Text;
     PharmCur.City      = textCity.Text;
     PharmCur.State     = textState.Text;
     PharmCur.Zip       = textZip.Text;
     PharmCur.Note      = textNote.Text;
     try{
         if (PharmCur.IsNew)
         {
             Pharmacies.Insert(PharmCur);
         }
         else
         {
             Pharmacies.Update(PharmCur);
         }
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
         return;
     }
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 3
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textStoreName.Text == "")
            {
                MessageBox.Show(Lan.g(this, "Store name cannot be blank."));
                return;
            }
            if (CultureInfo.CurrentCulture.Name == "en-US")
            {
                if (textPhone.Text != "" && TelephoneNumbers.FormatNumbersExactTen(textPhone.Text) == "")
                {
                    MessageBox.Show(Lan.g(this, "Phone number must be in a 10-digit format."));
                    return;
                }
                if (textFax.Text != "" && TelephoneNumbers.FormatNumbersExactTen(textFax.Text) == "")
                {
                    MessageBox.Show(Lan.g(this, "Fax number must be in a 10-digit format."));
                    return;
                }
            }
            PharmCur.StoreName = textStoreName.Text;
            PharmCur.PharmID   = "";
            PharmCur.Phone     = textPhone.Text;
            PharmCur.Fax       = textFax.Text;
            PharmCur.Address   = textAddress.Text;
            PharmCur.Address2  = textAddress2.Text;
            PharmCur.City      = textCity.Text;
            PharmCur.State     = textState.Text;
            PharmCur.Zip       = textZip.Text;
            PharmCur.Note      = textNote.Text;
            try{
                if (PharmCur.IsNew)
                {
                    Pharmacies.Insert(PharmCur);
                }
                else
                {
                    Pharmacies.Update(PharmCur);
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            //Update PharmClinic links
            List <PharmClinic> listPharmClinicOld = (List <PharmClinic>)comboClinic.Tag;
            List <PharmClinic> listPharmClinicNew = new List <PharmClinic>();

            //comboClinic.All might be selected, and would result in ListSelectedClinicNums containing only the clinics showing in the combobox, which very will not include clinics that user does not have permissions for.  "All" is not separately tested for.  Because the new list is synched against the old list, clinics that aren't showing are not affected one way or the other.
            foreach (long clinicNumNew in comboClinic.ListSelectedClinicNums)
            {
                if (listPharmClinicOld.Any(x => x.ClinicNum == clinicNumNew))               //if it existed before, add it to the list
                {
                    listPharmClinicNew.Add(listPharmClinicOld.First(x => x.ClinicNum == clinicNumNew));
                }
                else                  //otherwise, create a new link.
                {
                    listPharmClinicNew.Add(new PharmClinic(PharmCur.PharmacyNum, clinicNumNew));
                }
            }
            PharmClinics.Sync(listPharmClinicNew, listPharmClinicOld);
            DialogResult = DialogResult.OK;
        }