Example #1
0
        private void loadCustomers()
        {
            DataTable data = getService.getDataWithFilter(app.objects["customers"], "CONVERT(VARCHAR(10), created_date, 111) BETWEEN  '" + range.from.Date.ToString("yyyy/MM/dd") + "' AND '" + range.to.Date.ToString("yyyy/MM/dd") + "'");

            if (data.Rows.Count > 0)
            {
                customerGridView.DataSource = data;
            }
        }
        private void loadAjustments()
        {
            DataTable data = getService.getDataWithFilter(app.objects["adjustments"], "CONVERT(VARCHAR(10), transaction_date, 111) BETWEEN  '" + range.from.Date.ToString("yyyy/MM/dd") + "' AND '" + range.to.Date.ToString("yyyy/MM/dd") + "'");

            if (data.Rows.Count > 0)
            {
                adjustmentsGridView.DataSource = data;
            }
        }
Example #3
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            try
            {
                User user = new User()
                {
                    username = loginIDField.Text,
                    password = loginPasswordField.Text,
                };

                if (user.username == "" || user.username == "Username")
                {
                    app.notifyTo(statusLabel, "Enter your username", "warning");
                }
                else if (user.password == "" || user.password == "Password")
                {
                    app.notifyTo(statusLabel, "Enter your Password", "warning");
                }

                if (user.username != "" && user.username != "Username" && user.password != "" && user.password != "Password")
                {
                    DataTable response = getService.getDataWithFilter(app.objects["users"], "username='******' and password='******'");
                    if (response.Rows.Count > 0)
                    {
                        DataRow row = response.Rows[0];
                        user.id   = row.Field <int>("id");
                        user.name = row.Field <string>("name");
                        user.role = row.Field <string>("role");
                        user.bid  = row.Field <int>("bid");
                        updateService.updateLastLoginDate(user);
                        userlog(user.username);
                        app.setSession(user);
                        app.redirect(this, new Dashboard());
                    }
                    else
                    {
                        app.notifyTo(statusLabel, "Invalid Username or Password!", "error");
                    }
                }
            }
            catch (Exception ex)
            {
                app.showError(ex.Message);
            }
        }
Example #4
0
        private void refreshCutsomerBalance(string name)
        {
            DataTable data = getService.getDataWithFilter(app.objects["debtors"], " name ='" + name + "'");

            if (data.Rows.Count > 0)
            {
                int balance = data.Rows[0].Field <int>("amount");
                if (balance == 0)
                {
                    totalBalanceLabel.Text = "0.00";
                }
                else
                {
                    totalBalanceLabel.Text = app.toMoneyOf(balance);
                }
            }
            else
            {
                totalBalanceLabel.Text = "0.00";
            }
            accountBalancePanel.Show();
        }
Example #5
0
        public int addStock(Stock stock)
        {
            SSGetService    getService    = new SSGetService();
            SSUpdateService updateService = new SSUpdateService();

            Product existingProduct = getService.getProductByName(stock.name);

            if (existingProduct.name != null)
            {
                Location existingLocation = getService.getLocationByName(stock.location);
                if (existingLocation.name != null)
                {
                    string    batchName;
                    string    batchFormat = DateTime.Now.ToString("MMyyyy");
                    DataTable batchData   = getService.getDataWithFilter(app.objects["batches"], " name like '%" + batchFormat + "' order by created_date desc");
                    if (batchData.Rows.Count > 0)
                    {
                        DataRow row  = batchData.Rows[0];
                        string  name = row.Field <string>("name");
                        string  val  = name.Substring(name.IndexOf('B') + 1, name.IndexOf('-') - 1);
                        if (app.isAllDigits(val))
                        {
                            batchName = "B" + (int.Parse(val) + 1) + "-" + batchFormat;
                        }
                        else
                        {
                            batchName = "";
                        }
                    }
                    else
                    {
                        batchName = "B1-" + batchFormat;
                    }
                    string batchKey = app.generateId(20);

                    if (batchName != null && batchName != "")
                    {
                        using (SqlCommand batchCommand = new SqlCommand("INSERT INTO ss_batches(name,reference_key,pid,total,balance,sold)VALUES(@name,@reference_key,@pid,@total,@balance,@sold)"))
                        {
                            batchCommand.Parameters.AddWithValue("@name", batchName);
                            batchCommand.Parameters.AddWithValue("@reference_key", batchKey);
                            batchCommand.Parameters.AddWithValue("@pid", existingProduct.id);
                            batchCommand.Parameters.AddWithValue("@total", stock.quantity);
                            batchCommand.Parameters.AddWithValue("@balance", stock.quantity);
                            batchCommand.Parameters.AddWithValue("@sold", 0);

                            int batchResponse = service.execute(batchCommand);
                            if (batchResponse > 0)
                            {
                                Batch batch = getService.getBatchByKey(batchKey);
                                if (batch.key != null)
                                {
                                    using (SqlCommand command = new SqlCommand("INSERT INTO ss_stocks(pid,bid,quantity,cost,description,last_modified_date)VALUES(@pid,@bid,@quantity,@cost,@description, getdate())"))
                                    {
                                        command.Parameters.AddWithValue("@pid", existingProduct.id);
                                        command.Parameters.AddWithValue("@bid", batch.id);
                                        command.Parameters.AddWithValue("@quantity", stock.quantity);
                                        command.Parameters.AddWithValue("@cost", stock.cost);
                                        command.Parameters.AddWithValue("@description", stock.description);
                                        int response = service.execute(command);
                                        if (response > 0)
                                        {
                                            return(response);
                                        }
                                        else
                                        {
                                            return(-1);
                                        }
                                    }
                                }
                                else
                                {
                                    return(-1);
                                }
                            }
                            else
                            {
                                return(-402);
                            }
                        }
                    }
                    else
                    {
                        return(-500);
                    }
                }
                else
                {
                    return(-404);
                }
            }
            else
            {
                return(-403);
            }
        }
Example #6
0
        private void generatePaymentReceipt()
        {
            User      session  = app.getSession();
            DataTable payment  = getService.getDataWithFilter(app.objects["payments"], "id=" + tid);
            DataTable user     = getService.getDataWithFilter(app.objects["users"], "id=" + session.id);
            DataTable customer = getService.getDataWithFilter(app.objects["customers"], "id=" + cid);
            DataTable business = getService.getDataWithFilter(app.objects["business"], "id=" + session.bid);
            DataTable debtor   = getService.getDataWithFilter(app.objects["debtors"], "cid=" + cid);

            if (payment.Rows.Count > 0 && user.Rows.Count > 0 && business.Rows.Count > 0)
            {
                ReportDataSource paymentRDS  = new ReportDataSource("payment", payment);
                ReportDataSource userRDS     = new ReportDataSource("user", user);
                ReportDataSource customerRDS = new ReportDataSource("customer", customer);
                ReportDataSource businessRDS = new ReportDataSource("business", business);
                ReportDataSource debtorRDS   = new ReportDataSource("debtor", debtor);

                this.reportViewer.LocalReport.DataSources.Clear();
                this.reportViewer.LocalReport.DataSources.Add(paymentRDS);
                this.reportViewer.LocalReport.DataSources.Add(userRDS);
                this.reportViewer.LocalReport.DataSources.Add(customerRDS);
                this.reportViewer.LocalReport.DataSources.Add(businessRDS);
                this.reportViewer.LocalReport.DataSources.Add(debtorRDS);
                this.reportViewer.LocalReport.ReportPath = "../../PaymentReceipt.rdlc";
                this.reportViewer.Refresh();
            }
            else
            {
                app.showWarning("Unable to load the payment receipt, please logout->login and try again");
            }
        }