Exemple #1
0
        public async Task <IActionResult> Puttaxes([FromRoute] int id, [FromBody] taxes taxes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != taxes.id)
            {
                return(BadRequest());
            }

            _context.Entry(taxes).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!taxesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
            //public taxes(string name, int id)
            //{
            //    Id = id;
            //    Name = name;
            //    // tapCommand = new Command<object>(OnTapped);
            //}

            private void OnTapped(object obj)
            {
                taxes myobj = obj as taxes;

                var itemToRemove = App.taxListRemove.Single(r => r.Name == myobj.Name);

                App.taxListRemove.Remove(itemToRemove);
            }
Exemple #3
0
        private void taxpickerListView_ItemTapped(object sender, ItemTappedEventArgs ea)
        {
            taxes masterItemObj = (taxes)ea.Item;

            MessagingCenter.Send <string, String>("MyApp", "taxPickerMsg", masterItemObj.Name);

            Navigation.PopPopupAsync();
            // Navigation.PushPopupAsync(new CrmLeadDetailWizard(masterItemObj, "Lead"));
        }
Exemple #4
0
        public async Task <IActionResult> Posttaxes([FromBody] taxes taxes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.taxes.Add(taxes);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Gettaxes", new { id = taxes.id }, taxes));
        }
Exemple #5
0
        async void ListviewcloseClicked(object sender, EventArgs e1)
        {
            var   args = (TappedEventArgs)e1;
            taxes t2   = args.Parameter as taxes;

            var itemToRemove = App.taxListRemove.Single(r => r.Name == t2.Name);

            App.taxListRemove.Remove(itemToRemove);
            taxListView.ItemsSource   = App.taxListRemove;
            taxListView.RowHeight     = 30;
            taxListView.HeightRequest = 30 * App.taxListRemove.Count;
        }
Exemple #6
0
        public void Taxes_Test1()
        {
            string[] errors  = new string[] { };
            taxes    t_taxes = null;

            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX1").ToArray());
            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX2").ToArray());

            t_taxes = new taxes()
            {
                //taxes_name = "XX1",
                taxes_rate = 20
            };
            Assert.IsFalse(_dentnedModel.Taxes.CanAdd(t_taxes));

            t_taxes = new taxes()
            {
                taxes_name = "XX1",
                taxes_rate = -20
            };
            Assert.IsFalse(_dentnedModel.Taxes.CanAdd(t_taxes));

            t_taxes = new taxes()
            {
                taxes_name = "XX1",
                taxes_rate = 20
            };
            Assert.IsTrue(_dentnedModel.Taxes.CanAdd(t_taxes));
            _dentnedModel.Taxes.Add(t_taxes);

            t_taxes = new taxes()
            {
                taxes_name = "XX1",
                taxes_rate = 20
            };
            Assert.IsFalse(_dentnedModel.Taxes.CanAdd(t_taxes));

            t_taxes = new taxes()
            {
                taxes_name = "XX2",
                taxes_rate = 20
            };
            _dentnedModel.Taxes.Add(t_taxes);

            t_taxes            = _dentnedModel.Taxes.FirstOrDefault(r => r.taxes_name == "XX1");
            t_taxes.taxes_name = "XX2";
            Assert.IsFalse(_dentnedModel.Taxes.CanUpdate(t_taxes));
            t_taxes.taxes_name = "XX3";
            Assert.IsTrue(_dentnedModel.Taxes.CanUpdate(t_taxes));

            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX1").ToArray());
            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX2").ToArray());
        }
        public void TreatmentsTypes_Test2()
        {
            string[]        errors            = new string[] { };
            taxes           t_taxes           = null;
            treatments      t_treatments      = null;
            treatmentstypes t_treatmentstypes = null;

            _dentnedModel.Treatments.Remove(_dentnedModel.Treatments.List(r => r.treatments_code == "XX1").ToArray());
            _dentnedModel.TreatmentsTypes.Remove(_dentnedModel.TreatmentsTypes.List(r => r.treatmentstypes_name == "XX1").ToArray());
            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX1").ToArray());

            t_taxes = new taxes()
            {
                taxes_name = "XX1",
                taxes_rate = 20
            };
            _dentnedModel.Taxes.Add(t_taxes);

            t_treatmentstypes = new treatmentstypes()
            {
                treatmentstypes_name = "XX1"
            };
            _dentnedModel.TreatmentsTypes.Add(t_treatmentstypes);

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                taxes_id           = t_taxes.taxes_id,
                treatments_code    = "XX1",
                treatments_name    = "XX1",
                treatments_price   = 10
            };
            _dentnedModel.Treatments.Add(t_treatments);

            Assert.IsFalse(_dentnedModel.TreatmentsTypes.CanRemove(_dentnedModel.TreatmentsTypes.List(r => r.treatmentstypes_name == "XX1").ToArray()));

            _dentnedModel.Treatments.Remove(_dentnedModel.Treatments.List(r => r.treatments_code == "XX1").ToArray());

            Assert.IsTrue(_dentnedModel.TreatmentsTypes.CanRemove(_dentnedModel.TreatmentsTypes.List(r => r.treatmentstypes_name == "XX1").ToArray()));

            _dentnedModel.TreatmentsTypes.Remove(_dentnedModel.TreatmentsTypes.List(r => r.treatmentstypes_name == "XX1").ToArray());
            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX1").ToArray());
        }
Exemple #8
0
        public void Listview_ol_closeClicked(object sender, EventArgs e1)
        {
            try
            {
                var   args = (TappedEventArgs)e1;
                taxes t2   = args.Parameter as taxes;

                //  var itemToRemove = App.taxListRemove.Single(r => r.Name == t2.Name);

                var itemToRemove = taxList_edit.Single(r => r.Name == t2.Name);

                taxList_edit.Remove(itemToRemove);


                taxListView_ol.ItemsSource = null;


                //  taxStackLayout.Padding = 0;

                taxListView_ol.ItemsSource   = taxList_edit;
                taxListView_ol.RowHeight     = 35;
                taxListView_ol.HeightRequest = 35 * taxList_edit.Count;



                if (taxList_edit.Count == 0)
                {
                    taxStackLayout_ol.BackgroundColor = Color.White;
                    taxListView_ol.BackgroundColor    = Color.White;
                    taxStackLayout_ol.CornerRadius    = 0;
                    taxStackLayout_ol.Padding         = 0;
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }
Exemple #9
0
        //   Dictionary<int, object> salesteamdict = new Dictionary<int, object>(


        public SalesQuotationCreationPage()
        {
            InitializeComponent();
            orderListview.HeightRequest = 0;
            //     App.tap_plusbtncheck = true;


            //  addorderline_Btn.Clicked += addorderline_Btn_clicked;

            if (App.NetAvailable == true)
            {
                //cuspicker1.ItemsSource = App.cusdict.Select(x => x.Value).ToList();
                //cuspicker1.SelectedIndex = 0;

                var dropdownImgRecognizer = new TapGestureRecognizer();
                dropdownImgRecognizer.Tapped += (s, e) =>
                {
                    Navigation.PushPopupAsync(new PickerSelectionPage());
                    searchprod.IsVisible = true;
                };
                pickerdropimg.GestureRecognizers.Add(dropdownImgRecognizer);


                var empimgImgRecognizer = new TapGestureRecognizer();
                empimgImgRecognizer.Tapped += (s, e) =>
                {
                    empimg1.IsVisible  = false;
                    fillimg1.IsVisible = true;
                    new_customer       = true;
                };
                empimg1.GestureRecognizers.Add(empimgImgRecognizer);

                var fillimgImgRecognizer = new TapGestureRecognizer();
                fillimgImgRecognizer.Tapped += (s, e) =>
                {
                    empimg1.IsVisible  = true;
                    fillimg1.IsVisible = false;
                    new_customer       = false;
                };
                fillimg1.GestureRecognizers.Add(fillimgImgRecognizer);


                //taxpicker.ItemsSource = App.taxList.Select(x => x.Name).ToList();
                //taxpicker.SelectedIndex = 0;

                ptpicker.ItemsSource   = App.paytermList.Select(x => x.name).ToList();
                ptpicker.SelectedIndex = 0;

                brand_picker.ItemsSource  = App.brandList.Select(x => x.name).ToList();
                brand_picker.SelectedItem = 0;

                category_picker.ItemsSource  = App.categoriesList.Select(x => x.display_name).ToList();
                category_picker.SelectedItem = 0;

                //comgroup_picker.ItemsSource = App.commisiongroupList.Select(x => x.name).ToList();
                //comgroup_picker.SelectedIndex = 0;
            }

            else if (App.NetAvailable == false)
            {
                int user_iddb    = 0;
                int partner_iddb = 0;

                JArray taxtlist_array = new JArray();

                foreach (var res in App.UserListDb)
                {
                    cusdictdb          = JsonConvert.DeserializeObject <Dictionary <int, string> >(res.customers_list);
                    taxtlist_array     = JsonConvert.DeserializeObject <JArray>(res.tax_list);
                    payment_termsdb    = JsonConvert.DeserializeObject <List <paytermList> >(res.payment_terms);
                    commission_groupdb = JsonConvert.DeserializeObject <List <commisiongroupList> >(res.commission_group);

                    user_iddb    = res.userid;
                    partner_iddb = res.partnerid;
                }

                foreach (JObject obj in taxtlist_array)
                {
                    taxes taxesdb = new taxes("");
                    taxesdb.Id   = obj["id"].ToObject <int>();
                    taxesdb.Name = obj["name"].ToString();
                    taxListdb.Add(taxesdb);
                }


                App.taxListdb = taxListdb;

                //cuspicker1.ItemsSource = cusdictdb.Select(x => x.Value).ToList();
                //cuspicker1.SelectedIndex = 0;

                var dropdownImgRecognizer = new TapGestureRecognizer();
                dropdownImgRecognizer.Tapped += (s, e) =>
                {
                    Navigation.PushPopupAsync(new PickerSelectionPage());
                };
                pickerdropimg.GestureRecognizers.Add(dropdownImgRecognizer);

                //taxpicker.ItemsSource = taxListdb.Select(x => x.Name).ToList();
                //taxpicker.SelectedIndex = 0;

                ptpicker.ItemsSource   = payment_termsdb.Select(x => x.name).ToList();
                ptpicker.SelectedIndex = 0;

                //comgroup_picker.ItemsSource = commission_groupdb.Select(x => x.name).ToList();
                //comgroup_picker.SelectedIndex = 0;
            }

            var AirConImgRecognizer = new TapGestureRecognizer();

            AirConImgRecognizer.Tapped += (s, e) => {
                // handle the tap
                //pd.ItemsSource = App.productList.Select(x => x.Name).ToList();
                //pd.SelectedIndex = 0;
                airconImg1.IsVisible    = true;
                AddAirCon.IsVisible     = false;
                orderLineGrid.IsVisible = true;
                discount_grid.IsVisible = true;
                //    orderLineGrid_1.IsVisible = true;

                taxname = "";

                taxlistviewGrid.IsVisible = true;

                Addtax_line.IsVisible = true;

                dis1.Text     = "";
                multidis.Text = "";
                //  addtaxGrid.IsVisible = true;

                //  taxpicker.SelectedIndex = 0;
                taxListView.ItemsSource = null;

                //taxStackLayout.BackgroundColor = Color.FromHex("#F0EEEF");
                //taxListView.HeightRequest = 0;
                //taxStackLayout.CornerRadius = 0;
                //taxListView.BackgroundColor = Color.FromHex("#FOEEF");
                taxStackLayout.IsVisible = false;

                App.taxListRemove.Clear();
                orderListview.ItemsSource = orderLineList1;
            };
            AddAirCon.GestureRecognizers.Add(AirConImgRecognizer);



            var Addtax_lineImgRecognizer = new TapGestureRecognizer();

            Addtax_lineImgRecognizer.Tapped += (s, e) => {
                // addtaxGrid.IsVisible = true;
                Addtax_line.IsVisible = false;

                Navigation.PushPopupAsync(new TaxSelectionPage());
            };
            Addtax_line.GestureRecognizers.Add(Addtax_lineImgRecognizer);



            var overallcloseImgRecognizer = new TapGestureRecognizer();

            overallcloseImgRecognizer.Tapped += (s, e) => {
                // handle the tap
                Navigation.PopAllPopupAsync();
            };
            overall_close.GestureRecognizers.Add(overallcloseImgRecognizer);
        }
Exemple #10
0
        //   Dictionary<int, object> salesteamdict = new Dictionary<int, object>(


        public SalesQuotationCreationPage()
        {
            InitializeComponent();
            orderListview.HeightRequest = 0;
            //     App.tap_plusbtncheck = true;


            //  addorderline_Btn.Clicked += addorderline_Btn_clicked;

            if (App.NetAvailable == true)
            {
                cuspicker1.ItemsSource   = App.cusdict.Select(x => x.Value).ToList();
                cuspicker1.SelectedIndex = 0;


                //var prostackRecognizer = new TapGestureRecognizer();
                //prostackRecognizer.Tapped += (s, e) =>
                //{
                //    Navigation.PushPopupAsync(new PickerSelectionPage());


                //};
                //searchprod.GestureRecognizers.Add(prostackRecognizer);



                var dropdownImgRecognizer = new TapGestureRecognizer();
                dropdownImgRecognizer.Tapped += (s, e) =>
                {
                    Navigation.PushPopupAsync(new PickerSelectionPage());


                    searchprod.IsVisible = true;
                    //product_listview.IsVisible = true;

                    //List<ProductsList> proesult = new List<ProductsList>();
                    //if (App.NetAvailable == true)
                    //{
                    //    proesult = App.productList;
                    //    product_listview.ItemsSource = proesult;
                    //}

                    //if (App.NetAvailable == false)
                    //{

                    //    proesult = App.ProductListDb;
                    //    product_listview.ItemsSource = proesult;
                    //}
                };
                pickerdropimg.GestureRecognizers.Add(dropdownImgRecognizer);

                //taxpicker.ItemsSource = App.taxList.Select(x => x.Name).ToList();
                //taxpicker.SelectedIndex = 0;

                ptpicker.ItemsSource   = App.paytermList.Select(x => x.name).ToList();
                ptpicker.SelectedIndex = 0;

                comgroup_picker.ItemsSource   = App.commisiongroupList.Select(x => x.name).ToList();
                comgroup_picker.SelectedIndex = 0;
            }

            else if (App.NetAvailable == false)
            {
                int user_iddb    = 0;
                int partner_iddb = 0;

                JArray taxtlist_array = new JArray();

                foreach (var res in App.UserListDb)
                {
                    cusdictdb          = JsonConvert.DeserializeObject <Dictionary <int, string> >(res.customers_list);
                    taxtlist_array     = JsonConvert.DeserializeObject <JArray>(res.tax_list);
                    payment_termsdb    = JsonConvert.DeserializeObject <List <paytermList> >(res.payment_terms);
                    commission_groupdb = JsonConvert.DeserializeObject <List <commisiongroupList> >(res.commission_group);

                    user_iddb    = res.userid;
                    partner_iddb = res.partnerid;
                }

                foreach (JObject obj in taxtlist_array)
                {
                    taxes taxesdb = new taxes("");
                    taxesdb.Id   = obj["id"].ToObject <int>();
                    taxesdb.Name = obj["name"].ToString();
                    taxListdb.Add(taxesdb);
                }


                App.taxListdb = taxListdb;

                cuspicker1.ItemsSource   = cusdictdb.Select(x => x.Value).ToList();
                cuspicker1.SelectedIndex = 0;

                var dropdownImgRecognizer = new TapGestureRecognizer();
                dropdownImgRecognizer.Tapped += (s, e) =>
                {
                    Navigation.PushPopupAsync(new PickerSelectionPage());
                };
                pickerdropimg.GestureRecognizers.Add(dropdownImgRecognizer);

                //taxpicker.ItemsSource = taxListdb.Select(x => x.Name).ToList();
                //taxpicker.SelectedIndex = 0;

                ptpicker.ItemsSource   = payment_termsdb.Select(x => x.name).ToList();
                ptpicker.SelectedIndex = 0;

                comgroup_picker.ItemsSource   = commission_groupdb.Select(x => x.name).ToList();
                comgroup_picker.SelectedIndex = 0;
            }

            var AirConImgRecognizer = new TapGestureRecognizer();

            AirConImgRecognizer.Tapped += (s, e) => {
                // handle the tap
                //pd.ItemsSource = App.productList.Select(x => x.Name).ToList();
                //pd.SelectedIndex = 0;
                airconImg1.IsVisible    = true;
                AddAirCon.IsVisible     = false;
                orderLineGrid.IsVisible = true;
                //    orderLineGrid_1.IsVisible = true;

                taxlistviewGrid.IsVisible = true;

                Addtax_line.IsVisible = true;
                //  addtaxGrid.IsVisible = true;

                //  taxpicker.SelectedIndex = 0;
                taxListView.ItemsSource   = null;
                orderListview.ItemsSource = orderLineList1;
            };
            AddAirCon.GestureRecognizers.Add(AirConImgRecognizer);

            //var AirConImgRecognizer1 = new TapGestureRecognizer();
            //AirConImgRecognizer1.Tapped += (s, e) => {
            //    // handle the tap

            //    airconImg1.IsVisible = false;
            //    taxlistviewGrid.IsVisible = false;
            //   // addtaxGrid.IsVisible = false;

            //    orderListview.ItemsSource = orderLineList2;
            //    Dictionary<string, dynamic> xyz = new Dictionary<string, dynamic>();

            //    if (up.Text == "" || oqty.Text == null)
            //    {
            //        DisplayAlert("Alert", "Please fill all the fields", "Ok");
            //        orderLineGrid.IsVisible = false;
            //      //  orderLineGrid_1.IsVisible = false;
            //        airconImg.IsVisible = true;
            //        AddAirCon.IsVisible = true;
            //    }
            //    else
            //    {
            //      //  xyz.Add("product", pd.SelectedItem.ToString());

            //        xyz.Add("product", searchprod.Text.ToString());
            //        xyz.Add("ordered_qty", Convert.ToDouble(oqty.Text));
            //        xyz.Add("unit_price", Convert.ToDouble(up.Text));
            //        xyz.Add("description", orderline_des.Text);

            //        orderLineList1.Add(new OrderLinesList(searchprod.Text, Convert.ToDouble(oqty.Text), Convert.ToDouble(up.Text), taxidList, orderline_des.Text ));
            //        //  abc.Add(new Dictionary<string, dynamic>(xyz));

            //        orderListview.ItemsSource = orderLineList1;
            //        orderListview.RowHeight = 40;
            //        orderListview.HeightRequest = 40 * orderLineList1.Count;

            //        orderLineGrid.IsVisible = false;
            //      //  orderLineGrid_1.IsVisible = false;
            //        airconImg.IsVisible = true;
            //        AddAirCon.IsVisible = true;

            //    }

            //};
            //AddAirCon1.GestureRecognizers.Add(AirConImgRecognizer1);

            //var taxImgRecognizer = new TapGestureRecognizer();
            //taxImgRecognizer.Tapped += (s, e) => {
            //    // handle the tap



            //    taxListView.ItemsSource = null;

            //    App.taxListRemove.Add(new taxes(taxpicker.SelectedItem.ToString()));

            //    App.taxListRemove =   App.taxListRemove.GroupBy(i => i.Name).Select(g => g.First()).ToList();
            //   // taxpicker.IsVisible = false;
            //    taxStackLayout.IsVisible = true;
            //    taxListView.ItemsSource = App.taxListRemove;

            //    taxListView.RowHeight = 35;
            //    taxListView.HeightRequest = 35 * App.taxListRemove.Count;

            //    taxStackLayout.BackgroundColor = Color.FromHex("#363E4B");
            //    taxListView.BackgroundColor = Color.FromHex("#363E4B");
            //    taxStackLayout.CornerRadius = 20;

            //    taxStackLayout.Padding = 5;

            //   // taxpickstringList.Add(taxpicker.SelectedItem.ToString());
            //    var taxesid =
            //   (
            //   from i in App.taxList
            //   where i.Name == taxpicker.SelectedItem.ToString()

            //   select new
            //   {
            //       i.Id,
            //   }
            //   ).ToList();

            //    foreach (var person in taxesid)
            //    {
            //        int selecttaxid = person.Id;
            //        taxidList.Add(selecttaxid);
            //        taxidList = taxidList.GroupBy(i => i).Select(g => g.First()).ToList();
            //    }
            //};
            //Addtax.GestureRecognizers.Add(taxImgRecognizer);


            var Addtax_lineImgRecognizer = new TapGestureRecognizer();

            Addtax_lineImgRecognizer.Tapped += (s, e) => {
                // addtaxGrid.IsVisible = true;
                Addtax_line.IsVisible = false;

                Navigation.PushPopupAsync(new TaxSelectionPage());
            };
            Addtax_line.GestureRecognizers.Add(Addtax_lineImgRecognizer);



            var overallcloseImgRecognizer = new TapGestureRecognizer();

            overallcloseImgRecognizer.Tapped += (s, e) => {
                // handle the tap
                Navigation.PopAllPopupAsync();
            };
            overall_close.GestureRecognizers.Add(overallcloseImgRecognizer);
        }
Exemple #11
0
        public DraftQuotationCreationPage()
        {
            InitializeComponent();
            orderListview.HeightRequest = 0;
            //     App.tap_plusbtncheck = true;


            //  addorderline_Btn.Clicked += addorderline_Btn_clicked;



            if (App.NetAvailable == true)
            {
                //cuspicker1.ItemsSource = App.cusList.Select(x => x.name).ToList();
                //cuspicker1.SelectedIndex = -1;

                pricelist_picker.ItemsSource   = App.product_PriceList.Select(x => x.name).ToList();
                pricelist_picker.SelectedIndex = -1;

                // var num = App.product_PriceList.Where(x => x.name == pricelist_picker.SelectedItem.ToString()).Select(x => x.id);

                // string  ids = num[0];

                tax_termPicker.Items.Add("Free tax");
                tax_termPicker.Items.Add("Pay via PT. LABORINDO SARANA");
                tax_termPicker.Items.Add("Pay via Customer");

                tax_termPicker.SelectedIndex = 0;



                var dropdownImgRecognizer = new TapGestureRecognizer();
                dropdownImgRecognizer.Tapped += (s, e) =>
                {
                    Navigation.PushPopupAsync(new PickerSelectionPage());

                    searchprod.IsVisible = true;
                };
                pickerdropimg.GestureRecognizers.Add(dropdownImgRecognizer);



                //taxpicker.ItemsSource = App.taxList.Select(x => x.Name).ToList();
                //taxpicker.SelectedIndex = 0;

                ptpicker.ItemsSource   = App.paytermList.Select(x => x.name).ToList();
                ptpicker.SelectedIndex = -1;

                comgroup_picker.ItemsSource   = App.commisiongroupList.Select(x => x.name).ToList();
                comgroup_picker.SelectedIndex = -1;

                delmethod_picker.ItemsSource   = App.all_delivery_method.Select(x => x.name).ToList();
                delmethod_picker.SelectedIndex = -1;

                if (salesperson_picker.SelectedItem == null)
                {
                    salesperson_picker.ItemsSource   = App.salespersons.Select(x => x.Value).ToList();
                    salesperson_picker.SelectedIndex = 0;
                }

                shipping_picker.Items.Clear();

                shipping_picker.Items.Add("Deliver each product when available");
                shipping_picker.Items.Add("Deliver all products at once");
                shipping_picker.SelectedIndex = 0;


                if (warehouse_picker.SelectedItem == null)
                {
                    warehouse_picker.ItemsSource   = App.warehousList.Select(x => x.name).ToList();
                    warehouse_picker.SelectedIndex = 0;
                }
            }

            else if (App.NetAvailable == false)
            {
                int user_iddb    = 0;
                int partner_iddb = 0;

                JArray taxtlist_array = new JArray();

                foreach (var res in App.UserListDb)
                {
                    // cusdictdb = JsonConvert.DeserializeObject<Dictionary<int, string>>(res.customers_list);
                    taxtlist_array     = JsonConvert.DeserializeObject <JArray>(res.tax_list);
                    payment_termsdb    = JsonConvert.DeserializeObject <List <paytermList> >(res.payment_terms);
                    commission_groupdb = JsonConvert.DeserializeObject <List <commisiongroupList> >(res.commission_group);

                    user_iddb    = res.userid;
                    partner_iddb = res.partnerid;
                }

                foreach (JObject obj in taxtlist_array)
                {
                    taxes taxesdb = new taxes("");
                    taxesdb.Id   = obj["id"].ToObject <int>();
                    taxesdb.Name = obj["name"].ToString();
                    taxListdb.Add(taxesdb);
                }


                App.taxListdb = taxListdb;

                //cuspicker1.ItemsSource = cusdictdb.Select(x => x.Value).ToList();
                //cuspicker1.SelectedIndex = 0;

                var dropdownImgRecognizer = new TapGestureRecognizer();
                dropdownImgRecognizer.Tapped += (s, e) =>
                {
                    Navigation.PushPopupAsync(new PickerSelectionPage());
                };
                pickerdropimg.GestureRecognizers.Add(dropdownImgRecognizer);

                //taxpicker.ItemsSource = taxListdb.Select(x => x.Name).ToList();
                //taxpicker.SelectedIndex = 0;

                ptpicker.ItemsSource   = payment_termsdb.Select(x => x.name).ToList();
                ptpicker.SelectedIndex = 0;

                comgroup_picker.ItemsSource   = commission_groupdb.Select(x => x.name).ToList();
                comgroup_picker.SelectedIndex = 0;
            }

            var AirConImgRecognizer = new TapGestureRecognizer();

            AirConImgRecognizer.Tapped += (s, e) => {
                // handle the tap
                //pd.ItemsSource = App.productList.Select(x => x.Name).ToList();
                //pd.SelectedIndex = 0;
                airconImg1.IsVisible    = true;
                AddAirCon.IsVisible     = false;
                orderLineGrid.IsVisible = true;
                discount_grid.IsVisible = true;
                //    orderLineGrid_1.IsVisible = true;

                taxname = "";

                taxlistviewGrid.IsVisible = true;
                taxStackLayout.IsVisible  = false;

                Addtax_line.IsVisible = true;
                oqty.Text             = "1";
                dis1.Text             = "";
                multidis.Text         = "";
                //  addtaxGrid.IsVisible = true;

                //  taxpicker.SelectedIndex = 0;
                taxListView.ItemsSource   = null;
                orderListview.ItemsSource = orderLineList1;
            };
            AddAirCon.GestureRecognizers.Add(AirConImgRecognizer);



            var Addtax_lineImgRecognizer = new TapGestureRecognizer();

            Addtax_lineImgRecognizer.Tapped += (s, e) => {
                // addtaxGrid.IsVisible = true;
                Addtax_line.IsVisible = false;

                Navigation.PushPopupAsync(new TaxSelectionPage());
            };
            Addtax_line.GestureRecognizers.Add(Addtax_lineImgRecognizer);



            var overallcloseImgRecognizer = new TapGestureRecognizer();

            overallcloseImgRecognizer.Tapped += (s, e) => {
                // handle the tap
                Navigation.PopAllPopupAsync();
            };
            overall_close.GestureRecognizers.Add(overallcloseImgRecognizer);
        }
Exemple #12
0
        public void ComputedLines_Test1()
        {
            string[]      errors          = new string[] { };
            taxes         t_taxes         = null;
            computedlines t_computedlines = null;

            _dentnedModel.ComputedLines.Remove(_dentnedModel.ComputedLines.List(r => r.computedlines_code == "XX1").ToArray());
            _dentnedModel.ComputedLines.Remove(_dentnedModel.ComputedLines.List(r => r.computedlines_code == "XX2").ToArray());
            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX1").ToArray());

            t_taxes = new taxes()
            {
                taxes_name = "XX1",
                taxes_rate = 20
            };
            _dentnedModel.Taxes.Add(t_taxes);

            t_computedlines = new computedlines()
            {
                //computedlines_code = "XX1",
                computedlines_name = "XX1",
                taxes_id           = t_taxes.taxes_id,
                computedlines_rate = 20
            };
            Assert.IsFalse(_dentnedModel.ComputedLines.CanAdd(t_computedlines));

            t_computedlines = new computedlines()
            {
                computedlines_code = "XX1",
                //computedlines_name = "XX1",
                taxes_id           = t_taxes.taxes_id,
                computedlines_rate = 20
            };
            Assert.IsFalse(_dentnedModel.ComputedLines.CanAdd(t_computedlines));

            t_computedlines = new computedlines()
            {
                computedlines_code = "XX1",
                computedlines_name = "XX1",
                //taxes_id = t_taxes.taxes_id,
                computedlines_rate = 20
            };
            Assert.IsTrue(_dentnedModel.ComputedLines.CanAdd(t_computedlines));

            t_computedlines = new computedlines()
            {
                computedlines_code = "XX1",
                computedlines_name = "XX1",
                taxes_id           = -999,
                computedlines_rate = 20
            };
            Assert.IsFalse(_dentnedModel.ComputedLines.CanAdd(t_computedlines));

            t_computedlines = new computedlines()
            {
                computedlines_code = "XX1",
                computedlines_name = "XX1",
                taxes_id           = t_taxes.taxes_id,
                computedlines_rate = 20
            };
            Assert.IsTrue(_dentnedModel.ComputedLines.CanAdd(t_computedlines));
            _dentnedModel.ComputedLines.Add(t_computedlines);

            t_computedlines = new computedlines()
            {
                computedlines_code = "XX1",
                computedlines_name = "XX1",
                computedlines_rate = 20
            };
            Assert.IsFalse(_dentnedModel.ComputedLines.CanAdd(t_computedlines));

            t_computedlines = new computedlines()
            {
                computedlines_code = "XX2",
                computedlines_name = "XX2",
                computedlines_rate = 20
            };
            _dentnedModel.ComputedLines.Add(t_computedlines);

            t_computedlines = _dentnedModel.ComputedLines.FirstOrDefault(r => r.computedlines_code == "XX1");
            t_computedlines.computedlines_code = "XX2";
            Assert.IsFalse(_dentnedModel.ComputedLines.CanUpdate(t_computedlines));
            t_computedlines.computedlines_code = "XX3";
            Assert.IsTrue(_dentnedModel.ComputedLines.CanUpdate(t_computedlines));

            _dentnedModel.ComputedLines.Remove(_dentnedModel.ComputedLines.List(r => r.computedlines_code == "XX1").ToArray());
            _dentnedModel.ComputedLines.Remove(_dentnedModel.ComputedLines.List(r => r.computedlines_code == "XX2").ToArray());
            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX1").ToArray());
        }
Exemple #13
0
        public void Treatments_Test1()
        {
            string[]        errors            = new string[] { };
            taxes           t_taxes           = null;
            treatments      t_treatments      = null;
            treatmentstypes t_treatmentstypes = null;

            _dentnedModel.Treatments.Remove(_dentnedModel.Treatments.List(r => r.treatments_code == "XX1").ToArray());
            _dentnedModel.Treatments.Remove(_dentnedModel.Treatments.List(r => r.treatments_code == "XX2").ToArray());
            _dentnedModel.TreatmentsTypes.Remove(_dentnedModel.TreatmentsTypes.List(r => r.treatmentstypes_name == "XX1").ToArray());
            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX1").ToArray());

            t_taxes = new taxes()
            {
                taxes_name = "XX1",
                taxes_rate = 20
            };
            _dentnedModel.Taxes.Add(t_taxes);

            t_treatmentstypes = new treatmentstypes()
            {
                treatmentstypes_name = "XX1"
            };
            _dentnedModel.TreatmentsTypes.Add(t_treatmentstypes);

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                taxes_id           = t_taxes.taxes_id,
                //treatments_code = "XX1",
                treatments_name        = "XX1",
                treatments_mexpiration = 1,
                treatments_price       = 10
            };
            Assert.IsFalse(_dentnedModel.Treatments.CanAdd(t_treatments));

            t_treatments = new treatments()
            {
                //treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                taxes_id               = t_taxes.taxes_id,
                treatments_code        = "XX1",
                treatments_name        = "XX1",
                treatments_mexpiration = 1,
                treatments_price       = 10
            };
            Assert.IsFalse(_dentnedModel.Treatments.CanAdd(t_treatments));

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                taxes_id           = t_taxes.taxes_id,
                treatments_code    = "XX1",
                //treatments_name = "XX1",
                treatments_mexpiration = 1,
                treatments_price       = 10
            };
            Assert.IsFalse(_dentnedModel.Treatments.CanAdd(t_treatments));

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                taxes_id           = t_taxes.taxes_id,
                treatments_code    = "XX1",
                treatments_name    = "XX1",
                //treatments_mexpiration = 1,
                treatments_price = 10
            };
            Assert.IsTrue(_dentnedModel.Treatments.CanAdd(t_treatments));

            t_treatments = new treatments()
            {
                treatmentstypes_id     = t_treatmentstypes.treatmentstypes_id,
                taxes_id               = t_taxes.taxes_id,
                treatments_code        = "XX1",
                treatments_name        = "XX1",
                treatments_mexpiration = 0,
                treatments_price       = 10
            };
            Assert.IsFalse(_dentnedModel.Treatments.CanAdd(t_treatments));

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                //taxes_id = t_taxes.taxes_id,
                treatments_code  = "XX1",
                treatments_name  = "XX1",
                treatments_price = 10
            };
            Assert.IsTrue(_dentnedModel.Treatments.CanAdd(t_treatments));

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                taxes_id           = -999,
                treatments_code    = "XX1",
                treatments_name    = "XX1",
                treatments_price   = 10
            };
            Assert.IsFalse(_dentnedModel.Treatments.CanAdd(t_treatments));

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                taxes_id           = t_taxes.taxes_id,
                treatments_code    = "XX1",
                treatments_name    = "XX1",
                treatments_price   = 10
            };
            Assert.IsTrue(_dentnedModel.Treatments.CanAdd(t_treatments));
            _dentnedModel.Treatments.Add(t_treatments);

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                treatments_code    = "XX1",
                treatments_name    = "XX1",
                treatments_price   = 10
            };
            Assert.IsFalse(_dentnedModel.Treatments.CanAdd(t_treatments));

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                treatments_code    = "XX2",
                treatments_name    = "XX2",
                treatments_price   = 20
            };
            Assert.IsTrue(_dentnedModel.Treatments.CanAdd(t_treatments));
            _dentnedModel.Treatments.Add(t_treatments);

            t_treatments = new treatments()
            {
                treatmentstypes_id = t_treatmentstypes.treatmentstypes_id,
                treatments_code    = "XX-",
                treatments_name    = "XX-",
                treatments_price   = 20
            };
            Assert.IsTrue(_dentnedModel.Treatments.CanAdd(t_treatments));

            t_treatments = _dentnedModel.Treatments.FirstOrDefault(r => r.treatments_code == "XX1");
            t_treatments.treatments_code = "XX2";
            Assert.IsFalse(_dentnedModel.Treatments.CanUpdate(t_treatments));
            t_treatments.treatments_code = "XX3";
            Assert.IsTrue(_dentnedModel.Treatments.CanUpdate(t_treatments));

            _dentnedModel.Treatments.Remove(_dentnedModel.Treatments.List(r => r.treatments_code == "XX1").ToArray());
            _dentnedModel.Treatments.Remove(_dentnedModel.Treatments.List(r => r.treatments_code == "XX2").ToArray());
            _dentnedModel.TreatmentsTypes.Remove(_dentnedModel.TreatmentsTypes.List(r => r.treatmentstypes_name == "XX1").ToArray());
            _dentnedModel.Taxes.Remove(_dentnedModel.Taxes.List(r => r.taxes_name == "XX1").ToArray());
        }
        public void Populate()
        {
            int      medicalrecordstypesNum = 10;
            int      roomsNum = 3;
            int      patientsattachmentstypesNum = 3;
            int      treatmentstypesNum          = 3;
            int      treatmentspriceslistsNum    = 2;
            int      treatmentsNum     = 100;
            bool     generatedatafiles = true;
            DateTime now = DateTime.Now;

            Console.WriteLine("Add AddressesTypes...");
            addressestypes addressestypesHome = new addressestypes()
            {
                addressestypes_name = "Home"
            };

            _dentnedModel.AddressesTypes.Add(addressestypesHome);

            Console.WriteLine("Add ContactsTypes...");
            contactstypes contactstypesEMail = new contactstypes()
            {
                contactstypes_name = ContactsTypesRepository.SystemAttributes.EMail.ToString(),
            };

            _dentnedModel.ContactsTypes.Add(contactstypesEMail);
            contactstypes contactstypesMobile = new contactstypes()
            {
                contactstypes_name = "Telephone"
            };

            _dentnedModel.ContactsTypes.Add(contactstypesMobile);

            Console.WriteLine("Add MedicalrecordsTypes...");
            medicalrecordstypes[] medicalrecordstypes = new medicalrecordstypes[] { };
            for (int i = 0; i < medicalrecordstypesNum; i++)
            {
                medicalrecordstypes medicalrecordstypestmp = new medicalrecordstypes()
                {
                    medicalrecordstypes_name = "MedicalrecordsT " + (i + 1),
                };
                _dentnedModel.MedicalrecordsTypes.Add(medicalrecordstypestmp);
                medicalrecordstypes = medicalrecordstypes.Concat(new medicalrecordstypes[] { medicalrecordstypestmp }).ToArray();
            }

            Console.WriteLine("Add Taxes...");
            taxes taxesT22 = new taxes()
            {
                taxes_name = "Tax 22%",
                taxes_rate = 22
            };

            _dentnedModel.Taxes.Add(taxesT22);
            taxes taxesT04 = new taxes()
            {
                taxes_name = "Tax 4%",
                taxes_rate = 4
            };

            _dentnedModel.Taxes.Add(taxesT04);

            Console.WriteLine("Add TaxesDeductions...");
            taxesdeductions taxesdeductionsTD1 = new taxesdeductions()
            {
                taxesdeductions_name = "Ded Tax 01",
                taxesdeductions_rate = 20
            };

            _dentnedModel.TaxesDeductions.Add(taxesdeductionsTD1);

            Console.WriteLine("Add ComputedLines...");
            _dentnedModel.ComputedLines.Add(new computedlines()
            {
                computedlines_code = "DS1",
                computedlines_name = "Discount 01",
                taxes_id           = taxesT22.taxes_id,
                computedlines_rate = -10
            });
            _dentnedModel.ComputedLines.Add(new computedlines()
            {
                computedlines_code = "AD1",
                computedlines_name = "Addition 01",
                taxes_id           = taxesT22.taxes_id,
                computedlines_rate = 20
            });

            Console.WriteLine("Add Doctors...");
            doctors doctorsTest = new doctors()
            {
                doctors_name     = "John",
                doctors_surname  = "Doe",
                doctors_doctext  = "Dr. John Doe\r\n123 Main Street\r\nTown, CA\r\nVAT 0123456789",
                doctors_username = "******",
                doctors_password = "******"
            };

            _dentnedModel.Doctors.Add(doctorsTest);

            Console.WriteLine("Add Rooms...");
            rooms[] rooms = new rooms[] { };
            for (int i = 0; i < roomsNum; i++)
            {
                rooms roomstmp = new rooms()
                {
                    rooms_name = "Room " + (i + 1),
                };
                _dentnedModel.Rooms.Add(roomstmp);
                rooms = rooms.Concat(new rooms[] { roomstmp }).ToArray();
            }

            Console.WriteLine("Add InvoicesFooters...");
            invoicesfooters invoicesfooters01 = new invoicesfooters()
            {
                invoicesfooters_name    = "Footer 01",
                invoicesfooters_doctext = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
            };

            _dentnedModel.InvoicesFooters.Add(invoicesfooters01);

            Console.WriteLine("Add EstimatesFooters...");
            estimatesfooters estimatesfooters01 = new estimatesfooters()
            {
                estimatesfooters_name    = "Footer 01",
                estimatesfooters_doctext = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
            };

            _dentnedModel.EstimatesFooters.Add(estimatesfooters01);

            Console.WriteLine("Add PaymentsTypes...");
            paymentstypes paymentstypesCash = new paymentstypes()
            {
                paymentstypes_name    = "Cash",
                paymentstypes_doctext = "Pay by cash"
            };

            _dentnedModel.PaymentsTypes.Add(paymentstypesCash);

            Console.WriteLine("Add PatientsAttachmentsTypes...");
            patientsattachmentstypes[] patientsattachmentstypes = new patientsattachmentstypes[] { };
            for (int i = 0; i < patientsattachmentstypesNum; i++)
            {
                patientsattachmentstypes patientsattachmentstypestmp = new patientsattachmentstypes()
                {
                    patientsattachmentstypes_name          = "AttachmentsT " + (i + 1),
                    patientsattachmentstypes_valueautofunc = PatientsAttachmentsTypesRepository.ValueAutoFuncCode.NUL.ToString()
                };
                _dentnedModel.PatientsAttachmentsTypes.Add(patientsattachmentstypestmp);
                patientsattachmentstypes = patientsattachmentstypes.Concat(new patientsattachmentstypes[] { patientsattachmentstypestmp }).ToArray();
            }

            Console.WriteLine("Add PatientsAttributesTypes...");
            patientsattributestypes patientsattributestypesSendAppointmentsReminder = new patientsattributestypes()
            {
                patientsattributestypes_name = PatientsAttributesTypesRepository.SystemAttributes.SendAppointmentsReminder.ToString(),
            };

            _dentnedModel.PatientsAttributesTypes.Add(patientsattributestypesSendAppointmentsReminder);
            patientsattributestypes patientsattributestypesAge = new patientsattributestypes()
            {
                patientsattributestypes_name = "Age",
            };

            _dentnedModel.PatientsAttributesTypes.Add(patientsattributestypesAge);

            Console.WriteLine("Add TreatmentsTypes...");
            treatmentstypes[] treatmentstypes = new treatmentstypes[] { };
            for (int i = 0; i < treatmentstypesNum; i++)
            {
                treatmentstypes treatmentstypestmp = new treatmentstypes()
                {
                    treatmentstypes_name = "TreatmentsT " + (i + 1),
                };
                _dentnedModel.TreatmentsTypes.Add(treatmentstypestmp);
                treatmentstypes = treatmentstypes.Concat(new treatmentstypes[] { treatmentstypestmp }).ToArray();
            }

            Console.WriteLine("Add TreatmentsPricesLists...");
            treatmentspriceslists[] treatmentspriceslists = new treatmentspriceslists[] { };
            for (int i = 0; i < treatmentspriceslistsNum; i++)
            {
                treatmentspriceslists treatmentspricesliststmp = new treatmentspriceslists()
                {
                    treatmentspriceslists_name       = "TreatmentsT " + (i + 1),
                    treatmentspriceslists_multiplier = (decimal)(_r.NextDouble() * (2 - 1) + 1)
                };
                _dentnedModel.TreatmentsPricesLists.Add(treatmentspricesliststmp);
                treatmentspriceslists = treatmentspriceslists.Concat(new treatmentspriceslists[] { treatmentspricesliststmp }).ToArray();
            }

            Console.WriteLine("Add Treatments...");
            treatments[] treatments = new treatments[] { };
            for (int i = 0; i < treatmentsNum; i++)
            {
                treatments treatmentstmp = new treatments()
                {
                    treatmentstypes_id     = treatmentstypes[_r.Next(treatmentstypes.Count())].treatmentstypes_id,
                    treatments_code        = (i + 1).ToString().PadLeft(3, '0'),
                    treatments_name        = "Treatments " + (i + 1).ToString().PadLeft(3, '0'),
                    treatments_mexpiration = (_r.Next(0, 100) >= 80 ? (Nullable <byte>)_r.Next(1, 12) : null),
                    treatments_price       = (decimal)(_r.NextDouble() * (300 - 1) + 300),
                    taxes_id = taxesT22.taxes_id,
                    treatments_isunitprice = (_r.Next(0, 100) >= 50 ? true : false)
                };
                _dentnedModel.Treatments.Add(treatmentstmp);
                treatments = treatments.Concat(new treatments[] { treatmentstmp }).ToArray();
            }

            Console.WriteLine("Add TreatmentsPrices...");
            treatmentsprices[] treatmentsprices = new treatmentsprices[] { };
            foreach (treatments treatment in treatments)
            {
                if (_r.Next(0, 100) >= 30)
                {
                    treatmentspriceslists treatmentspriceslist = treatmentspriceslists[_r.Next(treatmentspriceslists.Count())];
                    treatmentsprices      treatmentspricestmp  = new treatmentsprices()
                    {
                        treatments_id            = treatment.treatments_id,
                        treatmentspriceslists_id = treatmentspriceslist.treatmentspriceslists_id,
                        treatmentsprices_price   = treatment.treatments_price + treatment.treatments_price * treatmentspriceslist.treatmentspriceslists_multiplier
                    };
                    _dentnedModel.TreatmentsPrices.Add(treatmentspricestmp);
                    treatmentsprices = treatmentsprices.Concat(new treatmentsprices[] { treatmentspricestmp }).ToArray();
                }
            }

            Console.WriteLine("Add Patients...");
            patients[] patients = new patients[] { };
            for (int i = 0; i < _patientsNum; i++)
            {
                patients patientstmp = new patients()
                {
                    patients_name            = "Name " + (i + 1).ToString(),
                    patients_surname         = "Surname " + (i + 1).ToString(),
                    patients_birthdate       = GetRandomDate(new DateTime(1950, 1, 1), new DateTime(2010, 12, 31)),
                    patients_birthcity       = BuildRandomString(_r.Next(5, 20)),
                    patients_doctext         = "Name " + (i + 1).ToString() + " " + "Surname " + (i + 1).ToString() + "\r\n" + "Street " + BuildRandomString(_r.Next(5, 30)) + ", " + _r.Next(1, 100) + "\r\n" + BuildRandomString(_r.Next(5, 20)) + (_r.Next(0, 100) > 50 ? "\r\n" + "VAT " + BuildRandomString(10) : ""),
                    patients_sex             = (_r.Next(0, 100) > 50 ? "M" : "F"),
                    patients_username        = (i + 1).ToString().PadLeft(8, '0'),
                    patients_password        = (i + 1).ToString().PadLeft(6, '0'),
                    patients_isarchived      = (_r.Next(0, 100) > 5 ? false : true),
                    treatmentspriceslists_id = (_r.Next(0, 100) > 20 ? (Nullable <int>)treatmentspriceslists[_r.Next(treatmentspriceslists.Count())].treatmentspriceslists_id : null)
                };
                _dentnedModel.Patients.Add(patientstmp);
                patients = patients.Concat(new patients[] { patientstmp }).ToArray();

                if (generatedatafiles)
                {
                    if (_r.Next(0, 100) > 50)
                    {
                        if (!Directory.Exists(_patientsDatadir + "\\" + patientstmp.patients_id))
                        {
                            Directory.CreateDirectory(_patientsDatadir + "\\" + patientstmp.patients_id);
                        }
                        GenerateImage(_patientsDatadir + "\\" + patientstmp.patients_id + "\\" + BuildRandomString(12) + ".png");
                    }
                }
            }

            Console.WriteLine("Add PatientsAddresses...");
            foreach (patients patient in patients)
            {
                do
                {
                    _dentnedModel.PatientsAddresses.Add(new patientsaddresses()
                    {
                        patients_id               = patient.patients_id,
                        addressestypes_id         = addressestypesHome.addressestypes_id,
                        patientsaddresses_state   = BuildRandomString(2),
                        patientsaddresses_city    = BuildRandomString(_r.Next(5, 10)),
                        patientsaddresses_street  = BuildRandomString(_r.Next(5, 30)),
                        patientsaddresses_zipcode = _r.Next(1, 99999).ToString().PadLeft(5, '0')
                    });
                } while (_r.Next(0, 100) > 80);
            }

            Console.WriteLine("Add PatientsAttributes...");
            foreach (patients patient in patients)
            {
                do
                {
                    _dentnedModel.PatientsAttributes.Add(new patientsattributes()
                    {
                        patients_id = patient.patients_id,
                        patientsattributestypes_id = patientsattributestypesAge.patientsattributestypes_id,
                        patientsattributes_value   = _r.Next(10, 100).ToString()
                    });
                } while (_r.Next(0, 100) > 80);
            }

            Console.WriteLine("Add PatientsContacts...");
            foreach (patients patient in patients)
            {
                do
                {
                    _dentnedModel.PatientsContacts.Add(new patientscontacts()
                    {
                        patients_id            = patient.patients_id,
                        contactstypes_id       = contactstypesMobile.contactstypes_id,
                        patientscontacts_value = _r.Next(1, 999).ToString().PadLeft(3, '0') + "/" + _r.Next(1, 999).ToString().PadLeft(3, '0') + _r.Next(1, 999).ToString().PadLeft(3, '0')
                    });
                } while (_r.Next(0, 100) > 80);
            }

            Console.WriteLine("Add PatientsMedicalrecords...");
            foreach (patients patient in patients)
            {
                do
                {
                    _dentnedModel.PatientsMedicalrecords.Add(new patientsmedicalrecords()
                    {
                        patients_id                  = patient.patients_id,
                        medicalrecordstypes_id       = medicalrecordstypes[_r.Next(medicalrecordstypes.Count())].medicalrecordstypes_id,
                        patientsmedicalrecords_value = BuildRandomString(_r.Next(10, 50))
                    });
                } while (_r.Next(0, 100) > 50);
            }

            Console.WriteLine("Add PatientsNotes...");
            foreach (patients patient in patients)
            {
                if (_r.Next(0, 100) > 50)
                {
                    do
                    {
                        _dentnedModel.PatientsNotes.Add(new patientsnotes()
                        {
                            patients_id        = patient.patients_id,
                            patientsnotes_date = GetRandomDate(new DateTime(now.AddYears(-1).Year, 1, 1), now),
                            patientsnotes_text = BuildRandomString(_r.Next(10, 200))
                        });
                    } while (_r.Next(0, 100) > 50);
                }
            }

            Console.WriteLine("Add PatientsAttachments...");
            foreach (patients patient in patients)
            {
                if (_r.Next(0, 100) > 50)
                {
                    do
                    {
                        string filename = null;

                        if (generatedatafiles)
                        {
                            if (_r.Next(0, 100) > 50)
                            {
                                filename = BuildRandomString(12) + ".png";
                                if (!Directory.Exists(_patientsAttachmentsdir + "\\" + patient.patients_id))
                                {
                                    Directory.CreateDirectory(_patientsAttachmentsdir + "\\" + patient.patients_id);
                                }
                                GenerateImage(_patientsAttachmentsdir + "\\" + patient.patients_id + "\\" + filename);
                            }
                        }

                        _dentnedModel.PatientsAttachments.Add(new patientsattachments()
                        {
                            patients_id = patient.patients_id,
                            patientsattachmentstypes_id  = patientsattachmentstypes[_r.Next(patientsattachmentstypes.Count())].patientsattachmentstypes_id,
                            patientsattachments_value    = BuildRandomString(_r.Next(10, 50)),
                            patientsattachments_date     = GetRandomDate(new DateTime(now.AddYears(-1).Year, 1, 1), now),
                            patientsattachments_filename = filename
                        });
                    } while (_r.Next(0, 100) > 50);
                }
            }

            Console.WriteLine("Add Appointments...");
            foreach (patients patient in patients)
            {
                do
                {
                    DateTime from = GetRandomDate(new DateTime(now.AddYears(-1).Year, 1, 1), now);
                    from = new DateTime(from.Year, from.Month, from.Day, _r.Next(8, 19), (_r.Next(0, 100) > 50 ? 0 : 30), 0);
                    DateTime to = (_r.Next(0, 100) > 50 ? from.AddMinutes(30) : from.AddHours(_r.Next(1, 2)));
                    _dentnedModel.Appointments.Add(new appointments()
                    {
                        patients_id        = patient.patients_id,
                        doctors_id         = doctorsTest.doctors_id,
                        rooms_id           = rooms[_r.Next(rooms.Count())].rooms_id,
                        appointments_title = BuildRandomString(_r.Next(5, 25)),
                        appointments_from  = from,
                        appointments_to    = to
                    });
                } while (_r.Next(0, 100) > 3);
            }

            Console.WriteLine("Add PatientsTreatments...");
            foreach (patients patient in patients)
            {
                do
                {
                    treatments treatment    = treatments[_r.Next(treatments.Count())];
                    DateTime   creationdate = GetRandomDate(new DateTime(now.AddYears(-1).Year, 1, 1), now);
                    _dentnedModel.PatientsTreatments.Add(new patientstreatments()
                    {
                        doctors_id                        = doctorsTest.doctors_id,
                        patients_id                       = patient.patients_id,
                        treatments_id                     = treatment.treatments_id,
                        patientstreatments_id             = treatment.treatments_id,
                        patientstreatments_creationdate   = creationdate,
                        patientstreatments_price          = treatment.treatments_price,
                        patientstreatments_taxrate        = taxesT22.taxes_rate,
                        patientstreatments_description    = treatment.treatments_code + " " + treatment.treatments_name,
                        patientstreatments_notes          = (_r.Next(0, 100) > 50 ? BuildRandomString(50) : null),
                        patientstreatments_fulfilldate    = (_r.Next(0, 100) > 50 ? (Nullable <DateTime>)creationdate.AddDays(_r.Next(0, 10)) : null),
                        patientstreatments_expirationdate = (treatment.treatments_mexpiration != null ? (Nullable <DateTime>)creationdate.AddMonths((byte)treatment.treatments_mexpiration) : null),
                        patientstreatments_ispaid         = (_r.Next(0, 100) > 20 ? true : false),
                        patientstreatments_isunitprice    = treatment.treatments_isunitprice,
                        patientstreatments_t11            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t12            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t13            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t14            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t15            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t16            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t17            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t18            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t21            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t22            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t23            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t24            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t25            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t26            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t27            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t28            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t31            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t32            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t33            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t34            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t35            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t36            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t37            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t38            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t41            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t42            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t43            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t44            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t45            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t46            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t47            = (_r.Next(0, 100) > 90 ? true : false),
                        patientstreatments_t48            = (_r.Next(0, 100) > 90 ? true : false)
                    });
                } while (_r.Next(0, 100) > 30);
            }

            Console.WriteLine("Add Payments...");
            foreach (patientstreatments patientstreatment in _dentnedModel.PatientsTreatments.List())
            {
                if (patientstreatment.patientstreatments_fulfilldate != null)
                {
                    if (_r.Next(0, 100) > 20)
                    {
                        int quantity = 1;
                        if (patientstreatment.patientstreatments_isunitprice)
                        {
                            quantity = _dentnedModel.PatientsTreatments.GetNumberOfTooths(patientstreatment);
                            if (quantity == 0)
                            {
                                quantity = 1;
                            }
                        }

                        _dentnedModel.Payments.Add(new payments()
                        {
                            payments_amount = quantity * (patientstreatment.patientstreatments_price + (patientstreatment.patientstreatments_price * patientstreatment.patientstreatments_taxrate / 100)) + (_r.Next(0, 100) > 50 ? (decimal)(_r.NextDouble() * 2) : 0),
                            payments_date   = ((DateTime)patientstreatment.patientstreatments_fulfilldate).AddDays(_r.Next(1, 30)),
                            patients_id     = patientstreatment.patients_id
                        });
                    }
                }
            }

            Console.WriteLine("Add Estimates and EstimatesLines...");
            foreach (patients patient in patients)
            {
                do
                {
                    DateTime  date     = GetRandomDate(new DateTime(now.AddYears(-1).Year, 1, 1), now);
                    estimates estimate = new estimates()
                    {
                        estimates_date             = date,
                        estimates_number           = (_dentnedModel.Estimates.List(r => r.estimates_date.Year == date.Year).Count + 1).ToString(),
                        doctors_id                 = doctorsTest.doctors_id,
                        patients_id                = patient.patients_id,
                        estimates_doctor           = doctorsTest.doctors_doctext,
                        estimates_patient          = patient.patients_doctext,
                        estimates_footer           = estimatesfooters01.estimatesfooters_doctext,
                        estimates_payment          = paymentstypesCash.paymentstypes_doctext,
                        estimates_totalnet         = 0,
                        estimates_totalgross       = 0,
                        estimates_totaldue         = 0,
                        estimates_deductiontaxrate = ((_r.Next(0, 100) > 50) ? taxesdeductionsTD1.taxesdeductions_rate : 0)
                    };
                    _dentnedModel.Estimates.Add(estimate);

                    do
                    {
                        treatments         treatment         = null;
                        patientstreatments patientstreatment = null;
                        int quantity = _r.Next(1, 3);
                        if (_r.Next(0, 100) > 80)
                        {
                            patientstreatment = _dentnedModel.PatientsTreatments.FirstOrDefault(r => r.patients_id == patient.patients_id);
                            if (patientstreatment != null)
                            {
                                treatment = _dentnedModel.Treatments.Find(patientstreatment.treatments_id);
                                if (patientstreatment.patientstreatments_isunitprice)
                                {
                                    quantity = _dentnedModel.PatientsTreatments.GetNumberOfTooths(patientstreatment);
                                    if (quantity == 0)
                                    {
                                        quantity = 1;
                                    }
                                }
                            }
                        }
                        if (treatment == null)
                        {
                            treatment = treatments[_r.Next(treatments.Count())];
                        }

                        _dentnedModel.EstimatesLines.Add(new estimateslines()
                        {
                            estimates_id                         = estimate.estimates_id,
                            estimateslines_code                  = treatment.treatments_code,
                            estimateslines_description           = treatment.treatments_code + " " + treatment.treatments_name,
                            estimateslines_quantity              = quantity,
                            estimateslines_unitprice             = treatment.treatments_price,
                            estimateslines_taxrate               = (_r.Next(0, 100) > 50 ? 0 : (_r.Next(0, 100) > 50 ? taxesT22.taxes_rate : taxesT04.taxes_rate)),
                            estimateslines_istaxesdeductionsable = true,
                            patientstreatments_id                = (patientstreatment != null ? (Nullable <int>)patientstreatment.patientstreatments_id : null),
                        });
                    } while (_r.Next(0, 100) > 30);
                } while (_r.Next(0, 100) > 30);
            }

            Console.WriteLine("Add Invoices and InvoicesLines...");
            foreach (patients patient in patients)
            {
                do
                {
                    DateTime date    = GetRandomDate(new DateTime(now.AddYears(-1).Year, 1, 1), now);
                    invoices invoice = new invoices()
                    {
                        invoices_date             = date,
                        invoices_number           = (_dentnedModel.Invoices.List(r => r.invoices_date.Year == date.Year).Count + 1).ToString(),
                        doctors_id                = doctorsTest.doctors_id,
                        patients_id               = patient.patients_id,
                        invoices_doctor           = doctorsTest.doctors_doctext,
                        invoices_patient          = patient.patients_doctext,
                        invoices_footer           = invoicesfooters01.invoicesfooters_doctext,
                        invoices_payment          = paymentstypesCash.paymentstypes_doctext,
                        invoices_totalnet         = 0,
                        invoices_totalgross       = 0,
                        invoices_totaldue         = 0,
                        invoices_deductiontaxrate = ((_r.Next(0, 100) > 50) ? taxesdeductionsTD1.taxesdeductions_rate : 0),
                        invoices_ispaid           = ((_r.Next(0, 100) > 20) ? false : true)
                    };
                    _dentnedModel.Invoices.Add(invoice);

                    do
                    {
                        treatments         treatment         = null;
                        patientstreatments patientstreatment = null;
                        int quantity = _r.Next(1, 3);
                        if (_r.Next(0, 100) > 80)
                        {
                            patientstreatment = _dentnedModel.PatientsTreatments.FirstOrDefault(r => r.patients_id == patient.patients_id);
                            if (patientstreatment != null)
                            {
                                if (patientstreatment.patientstreatments_isunitprice)
                                {
                                    quantity = _dentnedModel.PatientsTreatments.GetNumberOfTooths(patientstreatment);
                                    if (quantity == 0)
                                    {
                                        quantity = 1;
                                    }
                                }
                                treatment = _dentnedModel.Treatments.Find(patientstreatment.treatments_id);
                            }
                        }
                        if (treatment == null)
                        {
                            treatment = treatments[_r.Next(treatments.Count())];
                        }

                        _dentnedModel.InvoicesLines.Add(new invoiceslines()
                        {
                            invoices_id                         = invoice.invoices_id,
                            invoiceslines_code                  = treatment.treatments_code,
                            invoiceslines_description           = treatment.treatments_code + " " + treatment.treatments_name,
                            invoiceslines_quantity              = quantity,
                            invoiceslines_unitprice             = treatment.treatments_price,
                            invoiceslines_taxrate               = (_r.Next(0, 100) > 50 ? 0 : (_r.Next(0, 100) > 50 ? taxesT22.taxes_rate : taxesT04.taxes_rate)),
                            invoiceslines_istaxesdeductionsable = true,
                            patientstreatments_id               = (patientstreatment != null ? (Nullable <int>)patientstreatment.patientstreatments_id : null),
                        });
                    } while (_r.Next(0, 100) > 30);
                } while (_r.Next(0, 100) > 30);
            }
        }
Exemple #15
0
        private void OnMenuItemTapped(object sender, ItemTappedEventArgs ea)
        {
            orderLineGrid_ol.IsVisible   = false;
            discount_grid_ol.IsVisible   = false;
            taxlistviewGrid_ol.IsVisible = false;
            addbtn_orderline.IsVisible   = false;

            taxList_edit.Clear();


            if (editbtn_clicked == true)
            {
                updatebtn.IsVisible = false;

                OrderLine masterItemObj = (OrderLine)ea.Item;

                listview_editlayout.IsVisible = true;
                discount_grid.IsVisible       = true;
                taxlistviewGrid.IsVisible     = true;
                OrderLineList1.IsVisible      = false;

                searchprod.Text    = masterItemObj.product_name;
                orderline_des.Text = masterItemObj.product_name;
                oqty.Text          = masterItemObj.product_uom_qty;
                up.Text            = masterItemObj.price_unit;
                dis1.Text          = masterItemObj.discount;
                multidis.Text      = masterItemObj.multi_discount;
                orderline_id       = masterItemObj.id;

                taxlistviewGrid.IsVisible = true;

                taxes taxname = new taxes("");

                //for (int i = 0; i < masterItemObj.taxes.Count(); i++)
                //{


                //     //   var taxesfinname = final_listview[i].taxes;

                //    if (masterItemObj.taxes[i] != null)
                //        {

                //        taxList_edit.Add(new taxes(masterItemObj.taxes[i].ToString()));
                //        }

                //}


                for (int i = 0; i < masterItemObj.taxes_id.Count(); i++)
                {
                    string taname = masterItemObj.taxes_id[i].ToString();
                    int    taid   = Int32.Parse(taname);

                    //  var name = App.taxList.Select(x => x.Id == 4 );

                    var tax_list = from tx in App.taxList
                                   where tx.Id == taid
                                   select tx;



                    string name = "";
                    foreach (var tax in tax_list)
                    {
                        name = tax.Name;
                    }

                    //  var taxesfinname = final_listview[i].taxes;

                    if (masterItemObj.taxes_id[i] != null)
                    {
                        taxList_edit.Add(new taxes(name));
                    }
                }



                taxListView.ItemsSource        = taxList_edit;
                taxListView.RowHeight          = 35;
                taxListView.HeightRequest      = 35 * taxList_edit.Count;
                taxStackLayout.BackgroundColor = Color.FromHex("#363E4B");
                taxListView.BackgroundColor    = Color.FromHex("#363E4B");

                if (taxList_edit.Count == 0)
                {
                    taxStackLayout.BackgroundColor = Color.FromHex("#F0EEEF");
                    taxListView.BackgroundColor    = Color.FromHex("#F0EEEF");
                    taxlistviewGrid.Padding        = new Thickness(15, 0, 0, 0);
                    taxStackLayout.Padding         = new Thickness(0, 0, 0, 0);
                }
            }

            savebtn_layout.IsVisible = true;
        }