Exemplo n.º 1
0
        public CashRegisterDrawer()
        {
            InitializeComponent();

            DataTable dtDrawer        = null;
            DataTable dtDrawerHistory = new DataTable();
            DataTable dtTemp          = null;

            try
            {
                dtDrawer = xmlData.Select("*", "", XmlData.Tables.CashRegisterDrawer);
            }
            catch (Exception ex)
            {
                Common.WriteToFile(ex);
            }

            if (dtDrawer != null)
            {
                cashDrawer = (VoodooPOS.objects.CashRegisterDrawer)Common.CreateObjects.FromDataRow(dtDrawer.Rows[0], new VoodooPOS.objects.CashRegisterDrawer());

                txtCurrentAmount.Text = cashDrawer.Amount.ToString("N");
            }

            try
            {
                foreach (string file in Directory.GetFiles(Application.StartupPath + "\\data\\logs", "CashDrawerHistory_*"))
                {
                    FileInfo fi = new FileInfo(file);

                    dtTemp = xmlData.Select("*", "DateCreated asc", "Data\\logs\\" + fi.Name.Replace(".xml", ""), "Data\\" + XmlData.Tables.CashRegisterDrawer.ToString());

                    if (dtTemp != null && dtTemp.Rows.Count > 0)
                    {
                        if (dtDrawerHistory.Rows.Count == 0)
                        {
                            dtDrawerHistory = dtTemp.Copy();
                        }
                        else
                        {
                            foreach (DataRow dr in dtTemp.Rows)
                            {
                                dtDrawerHistory.Rows.Add(dr.ItemArray);
                            }
                        }
                    }
                }

                dtDrawerHistory.DefaultView.Sort = "DateCreated desc";

                dgvDrawer.DataSource = dtDrawerHistory.DefaultView;
            }
            catch (Exception ex)
            {
                Common.WriteToFile(ex);
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (cashDrawer == null)
            {
                cashDrawer             = new VoodooPOS.objects.CashRegisterDrawer();
                cashDrawer.Amount      = double.Parse(txtCurrentAmount.Text);
                cashDrawer.Description = "Cart File didn't exist.  Cart Created";

                CashDrawerChangeReason reasonForm = new CashDrawerChangeReason();
                reasonForm.ShowDialog();

                cashDrawer.ReasonForChange = reasonForm.ReasonForChange;

                xmlData.Insert(cashDrawer, XmlData.Tables.CashRegisterDrawer);
            }
            else
            {
                double origAmount = cashDrawer.Amount;

                cashDrawer.Amount = double.Parse(txtCurrentAmount.Text);

                CashDrawerChangeReason reasonForm = new CashDrawerChangeReason();
                reasonForm.ShowDialog();

                cashDrawer.ReasonForChange = reasonForm.ReasonForChange;

                xmlData.Update(cashDrawer, XmlData.Tables.CashRegisterDrawer);

                cashDrawer.Description = "Drawer amount changed manually from " + origAmount.ToString("C") + " to " + cashDrawer.Amount.ToString("C");
            }

            Common common = new Common(Application.StartupPath);

            common.WriteToLog("CashDrawerHistory", cashDrawer);

            this.Close();
        }