Example #1
0
        private void btnAdd_Update_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text == "")
            {
                return;
            }

            // build and populate flavorWPF object
            FlavorWPF flav = new FlavorWPF();

            flav.Name        = txtName.Text;
            flav.Description = txtDescription.Text;
            flav.NotAflavor  = (bool)chkNotAFlavor.IsChecked;
            flav.CakeFlavor  = (bool)chkCakeFlavor.IsChecked;
            flav.Invisible   = (bool)chkInvisible.IsChecked;

            if (btnAdd_Update.Content.ToString() == "Add")
            {
                lck_comm.AddFlavor(flav);
            }
            else if (btnAdd_Update.Content.ToString() == "Update")
            {
                if (lvwFlavors.SelectedItem == null)
                {
                    return;
                }

                flav.ID = (lvwFlavors.SelectedItem as FlavorWPF).ID;
                lck_comm.UpdateFlavor(flav.ID, flav);
            }

            ClearUI();
            RefreshFlavors();
        }
        public int FlavorTable()
        {
            int count = 0;

            try
            {
                // read from old db
                old_Access.Open();
                string          strCmd = @"SELECT * from Flavors";
                OleDbCommand    cmd    = new OleDbCommand(strCmd, old_Access);
                OleDbDataReader rdr    = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    FlavorWPF itm_WPF = new FlavorWPF();
                    itm_WPF.ID          = int.Parse(rdr["ID"].ToString());
                    itm_WPF.Name        = rdr["Flavor_Name"].ToString();
                    itm_WPF.Description = rdr["Description"].ToString();

                    new_WCF.AddFlavor(itm_WPF);
                    count++;
                }
                rdr.Close();
                old_Access.Close();
            }
            catch (Exception ex)
            {
                return(-1);
            }

            return(count);
        }
Example #3
0
 private void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     LCK_WPFclient.Views.FlavorsPreviewWindow win = new Views.FlavorsPreviewWindow(CakeOnly);
     win.Top  = System.Windows.Forms.Control.MousePosition.Y;
     win.Left = System.Windows.Forms.Control.MousePosition.X - this.Width;
     if (ItemsSource != null)
     {
         // use ItemsSource list if one is provided, otherwise use full list
         List <FlavorWPF> tmp = ItemsSource.Cast <FlavorWPF>().ToList();
         win.Flavors = tmp;
     }
     win.ShowDialog();
     SelectedItem = win.SelectedFlavor;
 }
        public int SO_BatchTable()
        {
            int count = 0;
            // will be used to link flavor in new db entry
            List <FlavorWPF> AllFlavors = new_WCF.GetAllFlavors();

            try
            {
                // read from old db
                old_Access.Open();
                string          strCmd = @"SELECT * from SpecialOrder_Batch";
                OleDbCommand    cmd    = new OleDbCommand(strCmd, old_Access);
                OleDbDataReader rdr    = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    SO_BatchWPF itm_WPF = new SO_BatchWPF();
                    itm_WPF.So_id      = int.Parse(rdr["SO_Number"].ToString());
                    itm_WPF.Day_number = rdr["Day_Number"].ToString();

                    // using flavor name, find flavor in new db to make foreign key link
                    string    tmp  = rdr["Flavor"].ToString();
                    FlavorWPF flav = AllFlavors.Find(x => x.Name.Contains(tmp));
                    itm_WPF.Flavor = flav;

                    itm_WPF.Quantity            = int.Parse(rdr["Quantity"].ToString());
                    itm_WPF.IsMini              = rdr["Mini"].ToString() == "Yes" ? true : false;
                    itm_WPF.SpecialInstructions = rdr["Special_Instructions"].ToString();

                    new_WCF.AddSpecialOrderBatch(itm_WPF.Id, itm_WPF);
                    count++;
                }
                rdr.Close();
                old_Access.Close();
            }
            catch (Exception ex)
            {
                return(-1);
            }

            return(count);
        }
        public int BatchTable()
        {
            int count = 0;
            // will be used to link flavor in new db entry
            List <FlavorWPF> AllFlavors = new_WCF.GetAllFlavors();

            try
            {
                // read from old db
                old_Access.Open();
                string          strCmd = @"SELECT * from Batch";
                OleDbCommand    cmd    = new OleDbCommand(strCmd, old_Access);
                OleDbDataReader rdr    = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    BatchWPF itm_WPF = new BatchWPF();
                    itm_WPF.Day_number = rdr["Day_Number"].ToString();

                    // using flavor name, find flavor in new db to make foreign key link
                    string    tmp  = rdr["Flavor"].ToString();
                    FlavorWPF flav = AllFlavors.Find(x => x.Name.Contains(tmp));
                    itm_WPF.Flavor = flav;

                    itm_WPF.Requested = rdr["Requested"].ToString() == "Yes" ? true : false;
                    itm_WPF.Quantity  = 0;
                    itm_WPF.Store     = new_WCF.GetStoreInfo(2); // ID=>2 is Vista by default

                    new_WCF.AddBatch(itm_WPF);
                    count++;
                }
                rdr.Close();
                old_Access.Close();
            }
            catch (Exception ex)
            {
                return(-1);
            }

            return(count);
        }