Пример #1
0
        async Task getSettings()
        {
            var settings = await SandoghcheController.GetConnection().Table <SandoghcheSetting>().FirstOrDefaultAsync();

            if (settings == null)
            {
                txtCompanyName.Text             = "";
                txtQuote.Text                   = "";
                txtTax1.Value                   = 0.0;
                txtTax2.Value                   = 0.0;
                txtReceiptNumberStartFrom.Value = 100;
            }
            else
            {
                txtCompanyName.Text = settings.CompanyName;
                txtQuote.Text       = settings.QuoteText;
                txtTax1.Value       = (decimal)settings.Tax1;
                txtTax2.Value       = (decimal)settings.Tax2;

                startFrom = Convert.ToInt32(txtReceiptNumberStartFrom.Value);
                txtReceiptNumberStartFrom.Value = Convert.ToInt32(txtReceiptNumberStartFrom.Value);

                pkrResetReceiptNumberTime.Time = settings.ResetReceiptTime;
            }
        }
Пример #2
0
        async Task getProducts(string Searchtext = null, string SortBy = null)
        {
            //var products = await SandoghcheController._connection.Table<Product>().Where(p => p.IsDeleted != true).ToListAsync();

            var query = "select Products.ProductId,Products.ProductText,Products.ProductPrice,Products.isDeleted,Products.IsActive,Products.ProductAmount,Categories.CategoryText from Products LEFT JOIN Categories on Products.CategoryId = Categories.CategoryId WHERE Products.isDeleted !=1";

            switch (SortBy)
            {
            case "ProductASC":
                query += " ORDER BY Products.ProductText ASC";
                break;

            case "ProductDESC":
                query += " ORDER BY Products.ProductText DESC";
                break;

            case "CategoryASC":
                query += " ORDER BY CategoryText ASC";
                break;

            case "CategoryDESC":
                query += " ORDER BY CategoryText DESC";
                break;

            case "AmountASC":
                query += " ORDER BY Products.ProductAmount ASC";
                break;

            case "AmountDESC":
                query += " ORDER BY Products.ProductAmount DESC";
                break;

            case "PriceASC":
                query += " ORDER BY Products.ProductPrice ASC";
                break;

            case "PriceDESC":
                query += " ORDER BY Products.ProductPrice DESC";
                break;

            default:
                query += " ";
                break;
            }

            var products = await SandoghcheController.GetConnection().QueryAsync <ProductCategoryPriceViewModel>(query);

            var result = new List <ProductCategoryPriceViewModel>();

            if (String.IsNullOrWhiteSpace(Searchtext))
            {
                result = products.ToList();
            }
            else
            {
                result = products.Where(p => p.ProductText.Contains(Searchtext) && p.isDeleted != true).ToList();
            }

            ProductslistView.ItemsSource = result;
        }
Пример #3
0
        async private void btnEditItem_Clicked(object sender, EventArgs e)
        {
            var button           = sender as Button;
            var productViewModel = button.CommandParameter as ProductCategoryPriceViewModel;
            var product          = await SandoghcheController.GetConnection().Table <Product>().FirstOrDefaultAsync(p => p.ProductId == productViewModel.ProductId);

            ProductId = product.ProductId;
            var category = await SandoghcheController.GetConnection().Table <Category>().FirstOrDefaultAsync(c => c.CategoryId == product.CategoryId);

            TabProduct.IsSelected = true;

            int index = 0;

            foreach (var item in pkrCategory.Items)
            {
                if (item == category.CategoryText)
                {
                    break;
                }
                index++;
            }
            pkrCategory.SelectedIndex = index;

            txtItem.Text             = product.ProductText;
            txtProductAmount.Value   = product.ProductAmount;
            txtProductPrice.Value    = product.ProductPrice;
            swchItemStatus.IsToggled = product.IsActive;

            btnAddItem.IsVisible    = false;
            btnUpdateItem.IsVisible = true;
            btnCancelItem.IsVisible = true;
        }
Пример #4
0
        async private void btnDeleteItem_Clicked(object sender, EventArgs e)
        {
            var button           = sender as Button;
            var productViewModel = button.CommandParameter as ProductCategoryPriceViewModel;
            var product          = await SandoghcheController.GetConnection().Table <Product>().FirstOrDefaultAsync(p => p.ProductId == productViewModel.ProductId);

            bool action = await DisplayAlert("اخطار", "آیا از حذف این محصول اطمینان دارید ؟", "بله", "خیر");

            if (action)
            {
                product.IsDeleted = true;
                await SandoghcheController._connection.UpdateAsync(product);

                await getProducts();

                //swchItemStatus.IsToggled = true;
                //btnAddItem.IsVisible = true;
                //btnCancelItem.IsVisible = false;
                // btnUpdateItem.IsVisible = false;
                //btnDeleteItem.IsVisible = false;
                //txtItem.Text = "";
                //txtProductPrice.Text = "";
                // txtProductAmount.Text = "0";
                //srchProduct.Text = "";
            }
        }
Пример #5
0
        async private void btnClientUpdate_Clicked(object sender, EventArgs e)
        {
            var client = await SandoghcheController.GetConnection().Table <Client>().FirstOrDefaultAsync(c => c.ClientId == clientId);

            if (String.IsNullOrWhiteSpace(txtClientFullName.Text))
            {
                await DisplayAlert("خطا", "نام مشترک نمیتواند خالی باشد", "باشه");
            }
            else
            {
                client.ClientName   = txtClientFullName.Text;
                client.PhoneNumber  = txtClientPhoneNumber.Text;
                client.MobileNumber = txtClientMobileNumber.Text;
                client.Email        = txtClientEmail.Text;
                client.Address      = txtClientAddress.Text;
                client.IsActive     = swtClientIsActive.IsToggled;

                await SandoghcheController._connection.UpdateAsync(client);

                txtClientFullName.Text      = "";
                txtClientPhoneNumber.Text   = "";
                txtClientMobileNumber.Text  = "";
                txtClientEmail.Text         = "";
                txtClientAddress.Text       = "";
                btnClientCancel.IsVisible   = false;
                btnClientUpdate.IsVisible   = false;
                btnClientRegister.IsVisible = true;
                await GetClients();

                TabClientsList.IsSelected = true;
                await DisplayAlert("ثبت", "بروز رسانی با موفقیت انجام شد", "باشه");
            }
        }
Пример #6
0
        async protected override void OnAppearing()
        {
            await SandoghcheController.GetConnection().CreateTableAsync <User>();

            await SandoghcheController.GetConnection().CreateTableAsync <Roll>();

            await SandoghcheController.GetConnection().CreateTableAsync <Category>();

            await SandoghcheController.GetConnection().CreateTableAsync <Client>();

            await SandoghcheController.GetConnection().CreateTableAsync <Product>();

            await SandoghcheController.GetConnection().CreateTableAsync <Order>();

            await SandoghcheController.GetConnection().CreateTableAsync <OrderDetail>();

            await SandoghcheController.GetConnection().CreateTableAsync <EditedOrdersLogs>();

            await SandoghcheController.GetConnection().CreateTableAsync <EditedOrderDetailsLogs>();

            await SandoghcheController.GetConnection().CreateTableAsync <SandoghcheSetting>();

            await SandoghcheController.GetConnection().CreateTableAsync <Accounting>();

            await SandoghcheController.GetConnection().CreateTableAsync <UserRoll>();

            lblQuote.Text = await SandoghcheController.GetQuote();


            lblQuote.Text = await SandoghcheController.GetQuote();

            base.OnAppearing();
        }
Пример #7
0
        async private void btnClientDelete_Clicked(object sender, EventArgs e)
        {
            var client = (Client)ClientDataGrid.SelectedItems[0];

            var action = await DisplayAlert("اخطار", "آیا میخواید این مشترک حذف شود", "بله", "خیر");

            if (action)
            {
                // var query = "select (sum(DebtorAmount)-sum(CreditorAmount)) as 'Amount' from Accounting WHERE ClientId=" + Convert.ToInt32(client.ClientId);
                var query  = "select Count(OrderId) as 'Amount' from Orders WHERE ClientId=" + Convert.ToInt32(client.ClientId);
                var amount = await SandoghcheController.GetConnection().QueryAsync <ClientCreditViewModel>(query);

                if (amount[0].Amount > 0)
                {
                    await DisplayAlert("اخطار", "امکان حذف به دلیل سابقه خرید در سیستم وجود ندارد ", "باشه");

                    return;
                }

                client.IsDeleted = true;
                await SandoghcheController._connection.UpdateAsync(client);

                txtClientFullName.Text      = "";
                txtClientPhoneNumber.Text   = "";
                txtClientMobileNumber.Text  = "";
                txtClientEmail.Text         = "";
                txtClientAddress.Text       = "";
                btnClientCancel.IsVisible   = false;
                btnClientDelete.IsVisible   = false;
                btnClientUpdate.IsVisible   = false;
                btnClientRegister.IsVisible = true;

                await GetClients();
            }
        }
Пример #8
0
        async Task getEditedOrders(int orderId)
        {
            var query        = "SELECT EditedOrdersLogs.OrderId,EditedOrdersLogs.ReceiptNumber,EditedOrdersLogs.EditedLogId,EditedOrdersLogs.FinalPayment,date(EditedOrdersLogs.DateCreated),Clients.ClientName from EditedOrdersLogs LEFT  JOIN Clients ON EditedOrdersLogs.ClientId = Clients.ClientId where EditedOrdersLogs.OrderId = " + orderId;
            var OrderHistory = await SandoghcheController.GetConnection().QueryAsync <OrderHistoryViewModel>(query);

            OrdersDataGrid.ItemsSource = OrderHistory;
        }
Пример #9
0
        async private void btnPayCredit_Clicked(object sender, EventArgs e)
        {
            var client = await SandoghcheController.GetConnection().Table <Client>().FirstOrDefaultAsync(c => c.ClientId == clientId);

            Accounting accounting = new Accounting();

            accounting.ClientId = client.ClientId;

            accounting.CreditorAmount = Convert.ToDouble(txtCreditAmount.Value);
            accounting.DebtorAmount   = 0;

            //if (Convert.ToDouble(txtCreditAmount.Value) > Convert.ToDouble(txtDebtAmount.Text))
            //{
            //    await DisplayAlert("خطا", "مبلغ پرداختی از مبلغ بدهی بیشتر است", "باشه");
            //    return;
            //}
            await SandoghcheController._connection.InsertAsync(accounting);

            txtCreditAmount.Value           = null;
            txtDebtAmount.Text              = "0";
            srchClients.Text                = null;
            lblClientCreditStatus.Text      = "وضعیت حساب";
            lblClientCreditStatus.TextColor = Color.Black;

            //await ClientCreditStatus(client.ClientId);
        }
Пример #10
0
        async Task GetClients()
        {
            var query   = "select  Clients.ClientId,Clients.ClientName from Clients where Clients.IsDeleted!=1 AND Clients.IsActive=1";
            var clients = await SandoghcheController.GetConnection().QueryAsync <Client>(query);

            srchClients.ItemsSource = clients.ToList();
            srchClients.Filter      = new ClientAutoCompleteViewFilter();
        }
Пример #11
0
        public ItemsPage()
        {
            InitializeComponent();
            NavigationPage.SetHasBackButton(this, false);

            lblPersianDate.Text = SandoghcheController.GetPersianDate(null);
            lblUser.Text        = Application.Current.Properties["userRollName"].ToString() + " : " + Application.Current.Properties["FullName"].ToString();
        }
Пример #12
0
        public ReportPage()
        {
            InitializeComponent();

            NavigationPage.SetHasBackButton(this, false);

            lblPersianDate.Text = SandoghcheController.GetPersianDate(null);
            lblUser.Text        = Application.Current.Properties["userRollName"].ToString() + " : " + Application.Current.Properties["FullName"].ToString();
            pkrReceiptType.Items.Add("روش پرداخت : همه");
            pkrReceiptType.Items.Add("نقدی");
            pkrReceiptType.Items.Add("اعتباری");
            pkrReceiptType.SelectedIndex = 0;



            userRoll = Application.Current.Properties["userRollName"].ToString();
            switch (userRoll)
            {
            case "مدیر ارشد":
            {
                isEdited.IsVisible     = true;
                isDeleted.IsVisible    = true;
                lblIsEdited.IsVisible  = true;
                lblIsDeleted.IsVisible = true;
            }
            break;

            case "مدیر":
            {
                isEdited.IsVisible     = true;
                isDeleted.IsVisible    = true;
                lblIsEdited.IsVisible  = true;
                lblIsDeleted.IsVisible = true;
            }
            break;

            case "صندوقدار":
            {
                isEdited.IsVisible     = false;
                isDeleted.IsVisible    = false;
                lblIsEdited.IsVisible  = false;
                lblIsDeleted.IsVisible = false;
            }
            break;

            case "میزبان":
            {
                isEdited.IsVisible     = false;
                isDeleted.IsVisible    = false;
                lblIsEdited.IsVisible  = false;
                lblIsDeleted.IsVisible = false;
            }
            break;

            default:
                break;
            }
        }
Пример #13
0
        async private Task ClientCreditStatus(int ClientId)
        {
            var query  = "select (sum(DebtorAmount)-sum(CreditorAmount)) as 'Amount' from Accounting WHERE ClientId=" + ClientId;
            var amount = await SandoghcheController.GetConnection().QueryAsync <ClientCreditViewModel>(query);



            lblCreditStatus.Text = "مانده : " + amount.FirstOrDefault()?.Amount.ToString() ?? 0.ToString();
        }
Пример #14
0
 public InvoicePage(int ClientId, string ClientName)
 {
     InitializeComponent();
     NavigationPage.SetHasBackButton(this, false);
     lblPersianDate.Text = SandoghcheController.GetPersianDate(null);
     lblClient.Text      = "انتخاب مشتری : " + ClientName;
     lblClientId.Text    = ClientId.ToString();
     clientName          = ClientName;
     order = new Order();
 }
Пример #15
0
        async Task GetClient()
        {
            var client = await SandoghcheController.GetConnection().Table <Client>().FirstOrDefaultAsync(c => c.ClientId == ClientId);

            //srchClients.ItemsSource = clients.ToList();
            //srchClients.Filter = new ClientAutoCompleteViewFilter();
            ClientId              = client.ClientId;
            srchClients.Text      = client.ClientName;
            srchClients.IsEnabled = false;
        }
Пример #16
0
        async private Task UpdateProductsAmount(bool forDelate = false)
        {
            var products = await SandoghcheController.GetConnection().Table <Product>().Where(p => p.IsDeleted != true).ToListAsync();

            if (forDelate)
            {
                var AddedOfNewProduct = order.OrderDetails;

                foreach (var product in products)
                {
                    foreach (var item in AddedOfNewProduct)
                    {
                        if (product.ProductId == item.ProductId)
                        {
                            product.ProductAmount = product.ProductAmount + item.Number;
                        }
                    }
                }

                await SandoghcheController._connection.UpdateAllAsync(products);
            }
            else
            {
                var ListOfeditedProduct = edited.EditedOrderDetailsLogs;
                foreach (var product in products)
                {
                    foreach (var item in ListOfeditedProduct)
                    {
                        if (product.ProductId == item.ProductId)
                        {
                            product.ProductAmount = product.ProductAmount + item.Number;
                        }
                    }
                }

                await SandoghcheController._connection.UpdateAllAsync(products);

                var AddedOfNewProduct = order.OrderDetails;

                foreach (var product in products)
                {
                    foreach (var item in AddedOfNewProduct)
                    {
                        if (product.ProductId == item.ProductId)
                        {
                            product.ProductAmount = product.ProductAmount - item.Number;
                        }
                    }
                }

                await SandoghcheController._connection.UpdateAllAsync(products);
            }
        }
Пример #17
0
        async protected override void OnAppearing()
        {
            //lblTotalNumberOfItem.Text = "سبد " + "( " + 0.ToString() + " )";
            TotalNumberOfItem = 0;
            order             = await SandoghcheController.GetConnection().Table <Order>().FirstOrDefaultAsync(o => o.OrderId == OrderId);

            var orderdetails = await SandoghcheController.GetConnection().Table <OrderDetail>().Where(od => od.OrderId == order.OrderId).ToListAsync();

            order.OrderDetails = orderdetails;

            var products = await SandoghcheController.GetConnection().Table <Product>().ToListAsync();

            int rowNumber = 1;

            foreach (var item in order.OrderDetails)
            {
                item.ProductText = products.FirstOrDefault(p => p.ProductId == item.ProductId).ProductText;
                item.RowNumber   = rowNumber;

                rowNumber++;
            }



            ClientId = order.ClientId;
            foreach (var item in orderdetails)
            {
                TotalNumberOfItem = TotalNumberOfItem + item.Number;
            }

            lblTotalNumberOfItem.Text = "سبد " + "( " + TotalNumberOfItem.ToString() + " )";

            // ProductsDataGrid.ItemsSource = orderdetails;

            TabBasket.IsSelected = true;

            await GetClient();
            await getCategories();
            await getSetting();

            lblFinalPayment.Text = order.FinalPayment.ToString();
            lblDelivery.Text     = order.DeliveryFee.ToString();
            lblDiscount.Text     = order.TotalDiscount.ToString();
            lblService.Text      = order.TotalServiceFee.ToString();
            lblTax.Text          = (order.Tax1 + order.Tax2).ToString();
            lblTotalPrice.Text   = order.TotalPrice.ToString();

            base.OnAppearing();
        }
Пример #18
0
        async private Task ClientCreditStatus(string ClientId)
        {
            var query  = "select (sum(DebtorAmount)-sum(CreditorAmount)) as 'Amount' from Accounting WHERE ClientId=" + Convert.ToInt32(ClientId);
            var amount = await SandoghcheController.GetConnection().QueryAsync <ClientCreditViewModel>(query);

            if (amount[0].Amount > 0)
            {
                txtDebtAmount.Text     = amount.FirstOrDefault()?.Amount.ToString() ?? 0.ToString();;
                btnPayCredit.IsEnabled = true;
            }
            else
            {
                btnPayCredit.IsEnabled = false;
            }
        }
Пример #19
0
        async protected override void OnAppearing()
        {
            var settings = await SandoghcheController.GetConnection().Table <SandoghcheSetting>().FirstOrDefaultAsync();

            if (settings == null)
            {
                await DisplayAlert("خطا", "تنظیمات سیستم هنوز اعمال نشده است", "باشه");

                await Navigation.PushAsync(new SettingsPage());
            }
            lblQuote.Text = await SandoghcheController.GetQuote();


            base.OnAppearing();
        }
Пример #20
0
        async Task GetUsers(string Searchtext = null)
        {
            var users = await SandoghcheController.GetConnection().Table <User>().Where(u => u.IsDeleted != true).ToListAsync();

            var result = new List <User>();

            if (String.IsNullOrWhiteSpace(Searchtext))
            {
                result = users;
            }
            else
            {
                result = users.Where(c => c.Email.Contains(Searchtext) && c.IsDeleted != true).ToList();
            }
            UserDataGrid.ItemsSource = result;
        }
Пример #21
0
        async private Task UpdateProductsAmount()
        {
            var products = await SandoghcheController.GetConnection().Table <Product>().Where(p => p.IsDeleted != true).ToListAsync();

            foreach (var item in order.OrderDetails)
            {
                foreach (var product in products)
                {
                    if (product.ProductId == item.ProductId)
                    {
                        product.ProductAmount = product.ProductAmount - item.Number;
                    }
                }
            }
            await SandoghcheController._connection.UpdateAllAsync(products);
        }
Пример #22
0
        async Task getCategories(string Searchtext = null)
        {
            var categories = await SandoghcheController.GetConnection().Table <Category>().Where(c => c.IsDeleted != true).ToListAsync();

            var result = new List <Category>();

            if (String.IsNullOrWhiteSpace(Searchtext))
            {
                result = categories;
            }
            else
            {
                result = categories.Where(c => c.CategoryText.Contains(Searchtext) && c.IsDeleted != true).ToList();
            }

            lstCategory.ItemsSource = result;
        }
Пример #23
0
        async Task getOrders(DateTime?createdDate, int orderId, int receiptId)
        {
            //var query = "SELECT Orders.OrderId,Orders.ReceiptNumber,Orders.FinalPayment,date(Orders.DateCreated),Orders.isDeleted,Orders.isEditedClients.ClientName from Orders LEFT  JOIN Clients ON Orders.ClientId = Clients.ClientId where Orders.isDeleted <>1";
            var query = "SELECT Orders.OrderId,Orders.ReceiptNumber,Orders.FinalPayment,date(Orders.DateCreated),Orders.isDeleted,Orders.isEdited,Clients.ClientName from Orders LEFT  JOIN Clients ON Orders.ClientId = Clients.ClientId where 1 ";

            if (createdDate != null)
            {
                query += string.Concat("and (date(Orders.DateCreated) = date('", createdDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), "'))");
            }

            //if (createdDate == null)
            //    query += query.Substring(0, query.Length - 5);
            ////str = str.Substring(0, str.Length - 2);

            if (orderId != 0)
            {
                query += "  and Orders.OrderId=" + orderId;
            }



            if (receiptId != 0)
            {
                query += "  and Orders.ReceiptNumber=" + receiptId;
            }


            if (!(userRoll == "مدیر ارشد" || userRoll == "مدیر"))
            {
                query += (" and Orders.isDeleted = " + 0);
            }



            var Orders = await SandoghcheController.GetConnection().QueryAsync <OrderDetailForSearchViewModel>(query);

            foreach (var order in Orders)
            {
                order.IsEditedDeleted = order.isDeleted + "#" + order.isEdited;
            }

            OrdersDataGrid.ItemsSource = Orders;
        }
Пример #24
0
        async Task GetClients(string Searchtext = null)
        {
            var clients = await SandoghcheController.GetConnection().Table <Client>().Where(c => c.IsDeleted != true).ToListAsync();

            var result = new List <Client>();

            if (String.IsNullOrWhiteSpace(Searchtext))
            {
                result = clients;
            }
            else
            {
                result = clients.Where(c => c.ClientName.Contains(Searchtext) && c.IsDeleted != true).ToList();
            }


            //var result = new List<Client>() { new Client { ClientId=1,ClientName="Test1",Address="hgflashdfgasjdhgfalskjhdfgsajhdf",Email="*****@*****.**",MobileNumber="09173842445",PhoneNumber="712331615" }, new Client { ClientId = 2, ClientName = "Test2", Address = "hgflashdfgasjdhgfalskjhdfgsajhdf", Email = "*****@*****.**", MobileNumber = "09173842445", PhoneNumber = "712331615" }, new Client { ClientId = 3, ClientName = "Test3", Address = "hgflashdfgasjdhgfalskjhdfgsajhdf", Email = "*****@*****.**", MobileNumber = "09173842445", PhoneNumber = "712331615" } };

            ClientDataGrid.ItemsSource = result;
        }
Пример #25
0
        async private void btnEditClient_Clicked(object sender, EventArgs e)
        {
            var button          = sender as Button;
            var clientViewModel = button.CommandParameter as ClientCreditViewModel;
            var client          = await SandoghcheController.GetConnection().Table <Client>().FirstOrDefaultAsync(c => c.ClientId == clientViewModel.ClientId);

            clientId = client.ClientId;

            TabAddClient.IsSelected     = true;
            txtClientFullName.Text      = client.ClientName;
            txtClientPhoneNumber.Text   = client.PhoneNumber;
            txtClientMobileNumber.Text  = client.MobileNumber;
            txtClientEmail.Text         = client.Email;
            txtClientAddress.Text       = client.Address;
            btnClientRegister.IsVisible = false;
            btnClientCancel.IsVisible   = true;
            btnClientUpdate.IsVisible   = true;
            //txtDebtAmount.Text = "0";
            //txtCreditAmount.Value = null;
            //await ClientCreditStatus(client.ClientId.ToString());
        }
Пример #26
0
        public SettingsPage()
        {
            InitializeComponent();

            NavigationPage.SetHasBackButton(this, false);

            lblPersianDate.Text = SandoghcheController.GetPersianDate(null);
            lblUser.Text        = Application.Current.Properties["userRollName"].ToString() + " : " + Application.Current.Properties["FullName"].ToString();
            var userRoll = Application.Current.Properties["userRollName"].ToString();

            switch (userRoll)
            {
            case "مدیر ارشد":
            {
                UserSettings.Content.IsVisible = true;
            }
            break;

            case "مدیر":
            {
                UserSettings.Content.IsVisible = true;
            }
            break;

            case "صندوقدار":
            {
                UserSettings.Content.IsVisible = false;
            }
            break;

            case "میزبان":
            {
                UserSettings.Content.IsVisible = false;
            }
            break;

            default:
                break;
            }
        }
Пример #27
0
        async private Task ClientCreditStatus(int ClientId)
        {
            var query  = "select (sum(DebtorAmount)-sum(CreditorAmount)) as 'Amount' from Accounting WHERE ClientId=" + ClientId;
            var amount = await SandoghcheController.GetConnection().QueryAsync <ClientCreditViewModel>(query);

            txtDebtAmount.Text = amount.FirstOrDefault()?.Amount.ToString() ?? 0.ToString();;

            if (Convert.ToDouble(txtDebtAmount.Text) > 0)
            {
                lblClientCreditStatus.Text      = "وضعیت حساب / بدهکار";
                lblClientCreditStatus.TextColor = Color.Red;
            }
            else if (Convert.ToDouble(txtDebtAmount.Text) < 0)
            {
                lblClientCreditStatus.Text      = "وضعیت حساب / بستانکار ";
                lblClientCreditStatus.TextColor = Color.Green;
            }
            else
            {
                lblClientCreditStatus.Text      = "وضعیت حساب";
                lblClientCreditStatus.TextColor = Color.Black;
            }


            btnPayCredit.IsEnabled    = true;
            txtCreditAmount.IsEnabled = true;



            //if (amount[0].Amount > 0)
            //{
            //    txtDebtAmount.Text = amount.FirstOrDefault()?.Amount.ToString() ?? 0.ToString(); ;
            //    btnPayCredit.IsEnabled = true;
            //    txtCreditAmount.IsEnabled = true;
            //}
            //else
            //    btnPayCredit.IsEnabled = false;
        }
Пример #28
0
        async Task GetClients(string Searchtext = null)
        {
            var query = "select Clients.ClientId,Clients.ClientName,Clients.MobileNumber,(select sum(Accounting.DebtorAmount)-sum(Accounting.CreditorAmount) from Accounting where Accounting.ClientId=Clients.ClientId) as Amount from Clients WHERE Clients.IsDeleted == false";

            var clients = await SandoghcheController.GetConnection().QueryAsync <ClientCreditViewModel>(query);

            var result = new List <ClientCreditViewModel>();

            if (String.IsNullOrWhiteSpace(Searchtext))
            {
                result = clients;
            }
            else
            {
                result = clients.Where(c => c.ClientName.Contains(Searchtext)).ToList();
            }


            ClientslistView.ItemsSource = result;

            srchClients.ItemsSource = clients.ToList();
            srchClients.Filter      = new ClientAutoCompleteViewFilter();
        }
Пример #29
0
        //private void btnDeleteItem_Clicked(object sender, EventArgs e)
        //{

        //}

        async private void btnUpdateItem_Clicked(object sender, EventArgs e)
        {
            var product = await SandoghcheController.GetConnection().Table <Product>().FirstOrDefaultAsync(p => p.ProductId == ProductId);

            if (String.IsNullOrWhiteSpace(txtItem.Text) ||
                Convert.ToDouble(txtProductAmount.Value) < 0 || Convert.ToDouble(txtProductPrice.Value) <= 0)
            {
                await DisplayAlert("خطا", "ورود مقادیر اشتباه است", "باشه");
            }
            else if (pkrCategory.SelectedIndex == -1)
            {
                await DisplayAlert("خطا", " طبقه را مشخص کنید ", "باشه");
            }
            else
            {
                product.CategoryId    = categoryId;
                product.ProductText   = txtItem.Text;
                product.ProductPrice  = Convert.ToDouble(txtProductPrice.Value);
                product.ProductAmount = Convert.ToDouble(txtProductAmount.Value);
                product.IsActive      = swchItemStatus.IsToggled;

                await SandoghcheController._connection.UpdateAsync(product);

                txtItem.Text              = "";
                txtProductPrice.Value     = 0;
                txtProductAmount.Value    = 0;
                srchProduct.Text          = "";
                btnAddItem.IsVisible      = true;
                btnCancelItem.IsVisible   = false;
                btnUpdateItem.IsVisible   = false;
                pkrCategory.SelectedIndex = -1;
                await getProducts();

                TabListOfProducts.IsSelected = true;
                await DisplayAlert("ویرایش ", "به روز رسانی با موفقیت انجام شد", "باشه");
            }
        }
Пример #30
0
        async private void btnShare_Clicked(object sender, EventArgs e)
        {
            var s             = sender as Xamarin.Forms.Button;
            var selectedOrder = s.BindingContext;
            var orderModel    = (OrderDetailForSearchViewModel)selectedOrder;
            int orderId       = orderModel.OrderId;

            var order = await SandoghcheController.GetConnection().Table <Order>().FirstOrDefaultAsync(o => o.OrderId == orderId);

            order.OrderDetails = await SandoghcheController.GetConnection().Table <OrderDetail>().Where(od => od.OrderId == orderModel.OrderId).ToListAsync();

            var products = await SandoghcheController.GetConnection().Table <Product>().ToListAsync();

            var client = await SandoghcheController.GetConnection().Table <Client>().FirstOrDefaultAsync(c => c.ClientId == order.ClientId);

            int rownum = 0;

            foreach (var item in order.OrderDetails)
            {
                rownum++;
                item.ProductText = products.FirstOrDefault(p => p.ProductId == item.ProductId).ProductText;
                item.RowNumber   = rownum;
            }

            List <orderDetailViewModel> orderDetails = new List <orderDetailViewModel>();

            foreach (var item in order.OrderDetails)
            {
                orderDetails.Add(new orderDetailViewModel {
                    RowNumber = item.RowNumber, ProductText = item.ProductText, Number = item.Number, Price = item.Price, TotalPrice = item.TotalPrice
                });
            }


            PdfDocument doc = new PdfDocument();

            doc.PageSettings.Size = new Syncfusion.Drawing.SizeF(300, 800);
            PdfMargins margins = new PdfMargins();

            margins.All = 10;
            doc.PageSettings.Margins = margins;
            PdfPage page = doc.Pages.Add();

            PdfGraphics graphics = page.Graphics;

            //var test = GetType().GetTypeInfo().Assembly.GetManifestResourceNames();
            Stream  fontStream = typeof(EditPage).GetTypeInfo().Assembly.GetManifestResourceStream("Sandoghche.Images.IRANSans(FaNum).ttf");
            PdfFont font       = new PdfTrueTypeFont(fontStream, 10);


            PdfStringFormat format = new PdfStringFormat();

            format.TextDirection = PdfTextDirection.RightToLeft;
            format.Alignment     = PdfTextAlignment.Center;

            PdfStringFormat format2 = new PdfStringFormat();

            format2.TextDirection = PdfTextDirection.RightToLeft;
            format2.Alignment     = PdfTextAlignment.Right;

            PdfStringFormat format3 = new PdfStringFormat();

            format3.TextDirection = PdfTextDirection.RightToLeft;
            format3.Alignment     = PdfTextAlignment.Left;


            graphics.DrawString(client.ClientName, font, PdfBrushes.Black, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
            graphics.DrawString("فاکتور فروش", font, PdfBrushes.Black, new RectangleF(0, 20, page.GetClientSize().Width, page.GetClientSize().Height), format);
            graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, 40), new PointF(300, 40));
            graphics.DrawString("تاریخ :" + SandoghcheController.GetPersianDate(Convert.ToDateTime(order.DateCreated)), font, PdfBrushes.Black, new RectangleF(0, 42, page.GetClientSize().Width, page.GetClientSize().Height), format);
            graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, 60), new PointF(300, 60));
            graphics.DrawString("ردیف عنوان                                    تعداد   قیمت واحد   قیمت کل          ", font, PdfBrushes.Black, new RectangleF(0, 60, page.GetClientSize().Width, page.GetClientSize().Height), format);
            graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, 75), new PointF(300, 75));


            string source = "";
            int    length = 5;
            string result = source.PadRight(length).Substring(0, length);


            int height = 75;

            foreach (var item in order.OrderDetails)
            {
                string rowNumber   = item.RowNumber.ToString().PadLeft(5).Substring(0, 5);
                string productText = item.ProductText.PadRight(20).Substring(0, 20);
                string Number      = item.Number.ToString().PadLeft(5).Substring(0, 5);
                string Price       = item.Price.ToString().PadLeft(12).Substring(0, 12);
                string TotalPrice  = item.TotalPrice.ToString().PadLeft(12).Substring(0, 12);
                graphics.DrawString(rowNumber, font, PdfBrushes.Black, 285, height, format2);
                graphics.DrawString(productText, font, PdfBrushes.Black, 255, height, format2);
                graphics.DrawString(Number, font, PdfBrushes.Black, 130, height, format2);
                graphics.DrawString(Price, font, PdfBrushes.Black, 110, height, format2);
                graphics.DrawString(TotalPrice, font, PdfBrushes.Black, 55, height, format2);
                height += 15;
                graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, height), new PointF(300, height));
                productText = "";
            }
            graphics.DrawString("مالیات : " + (order.Tax1 + order.Tax2).ToString(), font, PdfBrushes.Black, new RectangleF(0, height, page.GetClientSize().Width, page.GetClientSize().Height), format3);
            graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, height), new PointF(100, height));
            height += 15;
            graphics.DrawString("سرویس : " + order.TotalServiceFee.ToString(), font, PdfBrushes.Black, new RectangleF(0, height, page.GetClientSize().Width, page.GetClientSize().Height), format3);
            graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, height), new PointF(100, height));
            height += 15;
            graphics.DrawString("پیک : " + order.DeliveryFee.ToString(), font, PdfBrushes.Black, new RectangleF(0, height, page.GetClientSize().Width, page.GetClientSize().Height), format3);
            graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, height), new PointF(100, height));
            height += 15;
            graphics.DrawString‍("تخفیف : " + order.TotalDiscount.ToString(), font, PdfBrushes.Black, new RectangleF(0, height, page.GetClientSize().Width, page.GetClientSize().Height), format3);
            graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, height), new PointF(100, height));
            height += 15;
            graphics.DrawString‍("توضیحات : " + order.Comment, font, PdfBrushes.Black, new RectangleF(0, height, page.GetClientSize().Width, page.GetClientSize().Height), format3);
            graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, height), new PointF(100, height));
            height += 15;
            graphics.DrawString("جمع کل : " + order.FinalPayment.ToString(), font, PdfBrushes.Black, new RectangleF(0, height, page.GetClientSize().Width, page.GetClientSize().Height), format3);
            graphics.DrawLine(new PdfPen(PdfBrushes.Black, .5f), new PointF(0, height), new PointF(300, height));


            MemoryStream stream = new MemoryStream();

            doc.Save(stream);
            byte[] test = stream.ToArray();
            doc.Close(true);


            var fn   = order.OrderId.ToString() + ".pdf";
            var file = Path.Combine(FileSystem.CacheDirectory, fn);

            File.WriteAllBytes(file, test);

            await Share.RequestAsync(new ShareFileRequest
            {
                Title = "فاکتور فروش",
                File  = new ShareFile(file)
            });


            // await Xamarin.Forms.DependencyService.Get<ISave>().Save(order.OrderId.ToString(), "application/pdf", stream);
        }