Example #1
0
        public CustomertypesViewModel()
        {
            CustomertypeModel ct = new CustomertypeModel();
            DataTable         CustomerTypesTable = ct.All();

            this.FillAllCustomerTypes(CustomerTypesTable);
        }
Example #2
0
        public void Create()
        {
            CustomertypeModel ct = new CustomertypeModel
            {
                Name = Type
            };

            ct = ct.SaveThis();
            MessageBox.Show("Customer Type Created", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Example #3
0
        public void BtnDelete(CustomertypeModel cm)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete customer type?", "Delete Customer Type", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                bool result = cm.Delete();
                if (result)
                {
                    MessageBox.Show("Customer Type Deleted");
                }
            }
        }
Example #4
0
        private void FillAllCustomerTypes(DataTable cts)
        {
            List <CustomertypeModel> output = new List <CustomertypeModel>();

            foreach (DataRow row in cts.Rows)
            {
                CustomertypeModel ctm = new CustomertypeModel
                {
                    Id   = System.Convert.ToInt32(row[0].ToString()),
                    Name = row[1].ToString(),
                };

                output.Add(ctm);
            }
            this.CustomerTypes = new BindableCollection <CustomertypeModel>(output);
        }
        public EditCustomerViewModel(CustomerModel cm)
        {
            Customer = cm;
            CustomertypeModel ctm = new CustomertypeModel();
            DataTable         cts = ctm.All();

            CustomerTypes = ctm.GetCollection(cts);
            Name          = cm.Name;
            Phone         = cm.Phone;
            Email         = cm.Email;
            CustomerType  = ctm.Get(cm.Type);
            for (int i = 0; i < cts.Rows.Count; i++)
            {
                string RowID      = cts.Rows[i][0].ToString();
                string CustomerId = CustomerType.Id.ToString();
                if (RowID == CustomerId)
                {
                    SelectedIndex = i;
                    break;
                }
            }
        }
Example #6
0
 public void BtnEdit(CustomertypeModel cm)
 {
     ActivateItem(new EditCustomerTypeViewModel(cm));
 }
        public CreateCustomerViewModel()
        {
            CustomertypeModel ctm = new CustomertypeModel();

            CustomerTypes = ctm.GetCollection(ctm.All());
        }
 public EditCustomerTypeViewModel(CustomertypeModel cm)
 {
     Customer = cm;
     Type     = cm.Name;
 }