コード例 #1
0
        public void drawChartOfAccount()
        {
            treeView1.BeginUpdate();
            treeView1.Nodes.Clear();
            treeView1.Nodes.Add("Accounts");

            using (var db = new Model.posdbEntities())
            {
                var allacounts = db.accounts.ToList();
                foreach (var item in allacounts)
                {
                    if (item.ParentAccountID == null)
                    {
                        treeView1.Nodes[0].Nodes.Add(item.AccountName);
                    }
                }
                treeView1.EndUpdate();
                treeView1.BeginUpdate();
                foreach (var item in allacounts)
                {
                    if (item.ParentAccountID != null)
                    {
                        int?     parentID          = item.ParentAccountID;
                        string   parentAccountName = GetAccountName(parentID);
                        TreeNode node = FindNode(treeView1.Nodes[0], parentAccountName);
                        if (node != null)
                        {
                            node.Nodes.Add(new TreeNode(item.AccountName));
                        }
                    }
                }
            }
            treeView1.EndUpdate();
        }
コード例 #2
0
        private void mmPaperToolStripMenuItem1_CheckedChanged(object sender, EventArgs e)
        {
            ToolStripMenuItem temp;

            // uncheck the old one
            //temp.CheckState = CheckState.Unchecked;
            temp = (ToolStripMenuItem)sender;
            // check the new one
            //temp.CheckState = CheckState.Checked;

            using (var db = new Model.posdbEntities())
            {
                if (temp.CheckState == CheckState.Checked)
                {
                    var printertype = (from p in db.terminals
                                       where p.TerminalName == AppConfig.MacAddress
                                       select p).Single();
                    if (temp.Text == "60mm Paper")
                    {
                        printertype.PrinterType = 60;
                        AppConfig.PrinterType   = "60";
                    }
                    else if (temp.Text == "80mm Paper")
                    {
                        printertype.PrinterType = 80;
                        AppConfig.PrinterType   = "80";
                    }
                    db.SaveChanges();

                    mmPaperToolStripMenuItem.CheckState = CheckState.Unchecked;
                }
            }
        }
コード例 #3
0
        public void refreshPurchaseInvoices()
        {
            var saleDS         = new DataSet();
            var itemsDataTable = new DataTable("PurchaseOrders");

            itemsDataTable.Columns.Add("Pruchase Date");
            itemsDataTable.Columns.Add("Pruchase Amount");
            itemsDataTable.Columns.Add("Amount Paid");
            itemsDataTable.Columns.Add("Pruchase Status");
            itemsDataTable.Columns.Add("User Name");

            using (var db = new Model.posdbEntities())
            {
                var query = (from v in db.purchasesorders
                             orderby v.PurchaseDate descending
                             select v
                             ).ToList();


                foreach (var item in query)
                {
                    itemsDataTable.Rows.Add(item.PurchaseDate.Value.ToShortDateString(), item.PurchaseAmount, item.AmountPaid, item.PurchaseStatus, item.UserName);
                }

                saleDS.Tables.Add(itemsDataTable);
                PurchaseInvoices.DataSource = saleDS;
                PurchaseInvoices.DataMember = "PurchaseOrders";
                PurchaseInvoices.Refresh();
            }
        }
コード例 #4
0
        public void getPrinterConfig()
        {
            using (var db = new Model.posdbEntities())
            {
                var printertype = (from p in db.terminals
                                   where p.TerminalName == AppConfig.MacAddress
                                   select new { PrinterType = p.PrinterType }).SingleOrDefault();

                if (printertype != null)
                {
                    AppConfig.PrinterType = printertype.PrinterType.ToString();
                    if (AppConfig.PrinterType == "80")
                    {
                        mmPaperToolStripMenuItem.Checked  = true;
                        mmPaperToolStripMenuItem1.Checked = false;
                    }
                    else if (AppConfig.PrinterType == "60")
                    {
                        mmPaperToolStripMenuItem.Checked  = false;
                        mmPaperToolStripMenuItem1.Checked = true;
                    }
                }
                else
                {
                    terminal ter = new terminal();
                    ter.StoreID           = 1;
                    ter.TerminalName      = AppConfig.MacAddress;
                    ter.PrinterType       = 80;
                    AppConfig.PrinterType = "80".ToString();
                    db.terminals.Add(ter);
                    db.SaveChanges();
                }
            }
        }
コード例 #5
0
 public void DBAction_LogoutUser()
 {
     using (var db = new Model.posdbEntities())
     {
         //code needs to be written here for user logoff
     }
 }
コード例 #6
0
 public void loadProducts()
 {
     using (var db = new Model.posdbEntities())
     {
         var query = (from p in db.products
                      select new { ProductName = p.ProductName }).ToList();
     }
 }
コード例 #7
0
 public void loadCategories()
 {
     using (var db = new Model.posdbEntities())
     {
         var query = (from c in db.categories
                      select new { CategoryName = c.CategoryName }).ToList();
     }
 }
コード例 #8
0
 public string getBusinessName()
 {
     using (var db = new Model.posdbEntities())
     {
         var query = (from s in db.businesses
                      select new { s.BusinessName }).SingleOrDefault();
         if (query != null)
         {
             return(query.BusinessName);
         }
         else
         {
             return("Please set a business name.");
         }
     }
 }
コード例 #9
0
 public string GetBusinessSlogan()
 {
     using (var db = new Model.posdbEntities())
     {
         var query = (from s in db.businesses
                      select new { BusinessSlogan = s.Slogan }).SingleOrDefault();
         if (query != null)
         {
             return(query.BusinessSlogan);
         }
         else
         {
             return("Please set a business slogan.");
         }
     }
 }
コード例 #10
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            DateLabel.Text = DateTime.Today.Date.ToShortDateString();

            using (var db = new Model.posdbEntities())
            {
                string applicationPath = Path.GetDirectoryName(Application.ExecutablePath);
                var    query           = (from b in db.businesses
                                          select new { ImageFile = b.BusLogoFileName }).SingleOrDefault();
                string fileextension = Path.GetExtension(query.ImageFile);
                string destFile      = System.IO.Path.Combine(applicationPath, "companylogo" + fileextension);
                AppConfig.imagefile = destFile;
                FileStream fs = new FileStream(destFile, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                pictureBox1.Image = Image.FromStream(fs);
                fs.Close();
            }
        }
コード例 #11
0
 public void loadAccountsCombo()
 {
     using (var db = new Model.posdbEntities())
     {
         var query = (from b in db.accounts
                      select new { AccountName = b.AccountName }).ToList();
         AccountNameCombo.Items.Clear();
         int a = 0;
         foreach (var item in query)
         {
             //if (a == 0)
             //{
             //    comboBox1.Items.Add("None");
             //    comboBox1.Text = "None";
             //    comboBox2.Items.Add("None");
             //    comboBox2.Text = "None";
             //}
             //a += 1;
             AccountNameCombo.Items.Add(item.AccountName);
         }
     }
 }
コード例 #12
0
        public void loadExistingAccounts()
        {
            ExistingAccounts.Items.Clear();
            using (var db = new POSApplication.Model.posdbEntities())
            {
                var query = db.accounts.ToList();
                foreach (var item in query)
                {
                    ExistingAccounts.Items.Add(item.AccountName);
                }
            }

            using (var db = new Model.posdbEntities())
            {
                var query = (from b in db.accounts
                             select new { AccountName = b.AccountName }).ToList();
                comboBox1.Items.Clear();
                comboBox2.Items.Clear();
                comboBox3.Items.Clear();
                int a = 0;
                foreach (var item in query)
                {
                    if (a == 0)
                    {
                        comboBox1.Items.Add("None");
                        comboBox1.Text = "None";
                        comboBox2.Items.Add("None");
                        comboBox2.Text = "None";
                    }
                    a += 1;
                    comboBox1.Items.Add(item.AccountName);
                    comboBox2.Items.Add(item.AccountName);
                    comboBox3.Items.Add(item.AccountName);
                }
            }

            drawChartOfAccount();
        }
コード例 #13
0
        public void showExistingBusinessInformation()
        {
            try
            {
                using (var db = new Model.posdbEntities())
                {
                    var query = (from d in db.businesses
                                 select new
                    {
                        BusinessName = d.BusinessName,
                        BusLogoFile = d.BusLogoFileName,
                        City = d.City,
                        Country = d.Country,
                        CurrencyCode = d.CurrencyCode,
                        State = d.State,
                        Address = d.Address,
                        CellNumber = d.CellNumber,
                        EmailAddress = d.EmailAddress,
                        OfficeNumber = d.OfficeNumber,
                        Slogan = d.Slogan
                    }).SingleOrDefault();
                    if (query != null)
                    {
                        var d = new Model.business();
                        BusinessNameField.Text = query.BusinessName;

                        string str             = Application.ExecutablePath;
                        string applicationPath = Path.GetDirectoryName(Application.ExecutablePath);
                        var    dir             = new DirectoryInfo(applicationPath);
                        foreach (var file in dir.EnumerateFiles("companylogo.*"))
                        {
                            fileextension = file.Extension;
                        }
                        string destFile = System.IO.Path.Combine(applicationPath, "companylogo2" + fileextension);
                        filename = System.IO.Path.Combine(applicationPath, "companylogo" + fileextension);

                        //File.Delete(destFile);
                        //File.Copy(filename, destFile, true);


                        //File.Copy(System.IO.Path.Combine(applicationPath, "companylogo" + fileextension), System.IO.Path.Combine(applicationPath, "companylogo2" + fileextension), true);

                        FileStream fs = new FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                        pictureBox1.Image = Image.FromStream(fs);
                        fs.Close();

                        CityNameField.Text       = query.City;
                        CountryNameField.Text    = query.Country;
                        CurrencyNameList.Text    = query.CurrencyCode;
                        StateNameField.Text      = query.State;
                        AddressField.Text        = query.Address;
                        CellNumberField.Text     = query.CellNumber;
                        EmailAddressField.Text   = query.EmailAddress;
                        OfficeNumberField.Text   = query.OfficeNumber;
                        BusinessSloganField.Text = query.Slogan;
                        //pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
コード例 #14
0
        public int saveBusinessInformation()
        {
            string applicationPath = Path.GetDirectoryName(Application.ExecutablePath);
            string destFile        = System.IO.Path.Combine(applicationPath, "companylogo" + fileextension);

            string businessname      = "";
            string addressfield      = "";
            string citynamefield     = "";
            string statenamefield    = "";
            string countrynamefield  = "";
            string currencycodefield = "";
            string cellnumber        = "";
            string officenumber      = "";
            string emailaddress      = "";
            string businessslogan    = "";

            if (filename.Length > 0 && ispicturechanged == true)
            {
                var dir = new DirectoryInfo(applicationPath);
                foreach (var file in dir.EnumerateFiles("companylogo.*"))
                {
                    file.Delete();
                }
                File.Copy(filename, destFile, true);
                Model.AppConfig.imagefile = destFile;

                if (BusinessSloganField.Text.Length > 0)
                {
                    Model.AppConfig.businessSlogan = BusinessNameField.Text;
                }

                FileStream fs = new FileStream(Model.AppConfig.imagefile, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                pictureBox1.Image = Image.FromStream(fs);
                fs.Close();
            }

            try
            {
                if (BusinessNameField.Text.Length > 0)
                {
                    businessname = BusinessNameField.Text;
                }
                else
                {
                    MessageBox.Show("Enter business name");
                    return(0);
                }
                if (AddressField.Text.Length > 0)
                {
                    addressfield = AddressField.Text;
                }
                else
                {
                    MessageBox.Show("Enter business address");
                    return(0);
                }
                if (CityNameField.Text.Length > 0)
                {
                    citynamefield = CityNameField.Text;
                }
                if (StateNameField.Text.Length > 0)
                {
                    statenamefield = StateNameField.Text;
                }
                if (CountryNameField.Text.Length > 0)
                {
                    countrynamefield = CountryNameField.Text;
                }
                else
                {
                    MessageBox.Show("Enter Country name");
                    return(0);
                }
                if (CurrencyNameList.GetItemText(CurrencyNameList.SelectedItem).Length > 0)
                {
                    currencycodefield = CurrencyNameList.GetItemText(CurrencyNameList.SelectedItem).ToString();
                }
                else
                {
                    MessageBox.Show("Enter Currency Code");
                    return(0);
                }

                if (CellNumberField.Text.Length > 0)
                {
                    cellnumber = CellNumberField.Text;
                }

                if (OfficeNumberField.Text.Length > 0)
                {
                    officenumber = OfficeNumberField.Text;
                }

                if (EmailAddressField.Text.Length > 0)
                {
                    emailaddress = EmailAddressField.Text;
                }

                if (BusinessSloganField.Text.Length > 0)
                {
                    businessslogan = BusinessSloganField.Text;
                }

                using (var db = new Model.posdbEntities())
                {
                    var query = (from d in db.businesses
                                 select new { BusinessID = d.BusinessID }).SingleOrDefault();
                    if (query == null)
                    {
                        var d = new Model.business();
                        d.BusinessName = businessname;
                        d.Address      = addressfield;
                        //string str = convertSlashes(filename);
                        //d.BusLogoFileName = str;
                        string str = "companylogo" + Path.GetExtension(filename);
                        d.BusLogoFileName = str;
                        d.City            = citynamefield;
                        d.Country         = countrynamefield;
                        d.CurrencyCode    = currencycodefield;
                        d.State           = statenamefield;
                        //pictureBox1.Image = null;

                        System.Text.RegularExpressions.Regex regex = new Regex(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
                        Match match = regex.Match(emailaddress);
                        if (match.Success)
                        {
                            d.EmailAddress = emailaddress;
                            d.OfficeNumber = officenumber;
                            d.CellNumber   = cellnumber;
                            d.Slogan       = businessslogan;
                            db.businesses.Add(d);
                            db.SaveChanges();
                            MessageBox.Show("New Business has been registered.");
                            SuccessfulPictureChange();
                            return(1);
                        }
                        else
                        {
                            MessageBox.Show("Invalid Email Address.");
                        }
                    }
                    else
                    {
                        var original = db.businesses.Find(query.BusinessID);
                        if (original != null)
                        {
                            original.BusinessID   = query.BusinessID;
                            original.BusinessName = businessname;
                            original.Address      = addressfield;
                            //string str = convertSlashes(filename);
                            //original.BusLogoFileName = str;
                            string str = "companylogo" + Path.GetExtension(filename);
                            original.BusLogoFileName = str;
                            original.City            = citynamefield;
                            original.Country         = countrynamefield;
                            original.CurrencyCode    = currencycodefield;
                            original.State           = statenamefield;

                            System.Text.RegularExpressions.Regex regex = new Regex(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
                            Match match = regex.Match(emailaddress);
                            if (match.Success)
                            {
                                original.EmailAddress          = emailaddress;
                                original.OfficeNumber          = officenumber;
                                original.CellNumber            = cellnumber;
                                original.Slogan                = businessslogan;
                                Model.AppConfig.businessSlogan = businessslogan;
                                //pictureBox1.Image = null;
                                db.SaveChanges();
                                MessageBox.Show("Business Information has been updated.");
                                SuccessfulPictureChange();
                                return(1);
                            }
                            else
                            {
                                MessageBox.Show("Invalid Email Address.");
                            }
                        }
                    }
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException e1)
            {
                MessageBox.Show(e1.Message);
            }
            return(0);
        }