예제 #1
0
        private void UserValidator(string Role)
        {
            string branchCode = inif.Read("BranchCode", "CompanyDetails");

            POS_Menu.Visible = false;
            ActiveRole       = Role;
            if (ActiveRole.ToLower() == "staff")
            {
                ToolAccess.Visible = false;
                POS PS = new POS();
                PS.inif      = inif;
                PS.MdiParent = this;
                PS.Show();
                POS_Menu.Visible  = true;
                cf.sqlconn_client = SQLCLient;
                string InitialValue = "0.00";
                if (cf.CheckCashDrawerOfDay(branchCode, ref InitialValue))
                {
                    DialogResult dr = MessageBox.Show("Warning: System detects that you have not yet settle the POS Drawer today.\nWould you like to configure it first?", "Configure Drawer", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        CashDrawer cd = new CashDrawer();
                        cd.BranchCode = inif.Read("BranchCode", "CompanyDetails");
                        cd.ActiveUser = ActiveUser;
                        cd._sqlClient = SQLCLient;
                        cd._sqlServer = SQLServer;
                        cd.ShowDialog();
                    }
                }
            }
            else
            {
                if (ActiveRole.ToLower() == "admin")
                {
                    ToolAccess.Visible = true;
                    string StandAlone = inif.Read("Stand-Alone", "System");
                    if (StandAlone.ToLower() == "false")
                    {
                        MessageBox.Show("Error: Your POS was not set to \"Stand-Alone\".\n Kindly set it true to use to have Administratve Module.", "POS: Stand-Alone is Off", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ActiveUser         = string.Empty;
                        tssActiveUser.Text = string.IsNullOrEmpty(ActiveUser) ? "N/A" : ActiveUser;
                        tssLogout.Visible  = false;
                        tssLogin.Visible   = !tssLogout.Visible;
                        return;
                    }
                    else
                    {
                        Admin_Menu.Visible = true;
                        POS_Menu.Visible   = true;
                    }
                }
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    TotalCount = 0;
            string CashRegisterInitialValue = "0.00";

            if (!cf.CheckCashDrawerOfDay(BranchCode, ref CashRegisterInitialValue))
            {
                MessageBox.Show("Error: You have already set your cash drawer today.\nTo change it use administrative account.", "Cash Drawer Amount : " + CashRegisterInitialValue, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DialogResult dr = MessageBox.Show("Are you sure you want to set this value to your cash drawer?", "Cash Drawer Value:" + lblTotalAmount.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                if ((lblTotalAmount.Text == "0.00") || (lblTotalAmount.Text == "0"))
                {
                    DialogResult dr2 = MessageBox.Show("Warning: Are you sure you want to save 0.00 amount?", "Zero Amount Defined", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr2 == DialogResult.No)
                    {
                        return;
                    }
                }
                else
                {
                    bool ErrorSaved = false;
                    foreach (DataGridViewRow dgr in dataGridView1.Rows)
                    {
                        if (dgr.Cells["Count"].Value != "0")
                        {
                            TotalCount += dgr.Cells["Total"].Value.ToString() != "0.00" ? int.Parse(dgr.Cells["Total"].Value.ToString()):0;
                        }
                    }

                    if ((decimal.Parse(TotalCount.ToString()) == decimal.Parse(lblTotalAmount.Text)).ToString()
                        == ((decimal.Parse(textBox1.Text).ToString() == (decimal.Parse(lblTotalAmount.Text).ToString())).ToString()))
                    {
                        string PK = string.Empty;

                        if (cf.InsertCashDrawer(BranchCode, lblTotalAmount.Text, "In", ActiveUser, ref PK))
                        {
                            if (!string.IsNullOrEmpty(PK))
                            {
                                foreach (DataGridViewRow dgr in dataGridView1.Rows)
                                {
                                    if (dgr.Cells["Count"].Value.ToString() != "0")
                                    {
                                        int PK_ID      = int.Parse(cf.GetFieldsbyValues("tblMoneyEntry", "TOP 1 sysiD", " where POS_PK='" + PK + "'"));
                                        int MoneyValue = int.Parse(dgr.Cells["Amount"].Value.ToString());
                                        int Quantity   = int.Parse(dgr.Cells["Count"].Value.ToString());
                                        if (!cf.InsertDetailCashDrawer(BranchCode, PK_ID, MoneyValue, Quantity))
                                        {
                                            MessageBox.Show("Error: Cannot save cash drawer information. Please check your entry", "Cash Drawer Save Failed.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            if (cf.DeleteCashDrawer(PK))
                                            {
                                                cf.DeleteDetailCashDrawer(PK_ID.ToString());
                                            }
                                            ErrorSaved = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        if (!ErrorSaved)
                        {
                            MessageBox.Show("Cash Drawer for today was successfully saved", "Cash Drawer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Error: Details amount is not tally with Total Amount.", "Please check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }