예제 #1
0
        internal bool RestoreTable(DataBaseName dbName)
        {
            bool result = false;

            switch (dbName)
            {
            case DataBaseName.Users:
                result = LoadSQLTextFile(SQLStatement.GetInsertUserQuery());
                break;

            case DataBaseName.Category:
                result = LoadSQLTextFile(SQLStatement.GetInsertCategoryQuery());
                break;

            case DataBaseName.Period_Type:
                result = LoadSQLTextFile(SQLStatement.GetInsertPeriodTypeQuery());
                break;

            case DataBaseName.Period:

                break;

            case DataBaseName.Staff:

                break;

            case DataBaseName.All:
                result = (LoadSQLTextFile(SQLStatement.GetInsertUserQuery()) &&
                          LoadSQLTextFile(SQLStatement.GetInsertCategoryQuery()) &&
                          LoadSQLTextFile(SQLStatement.GetInsertPeriodTypeQuery()));
                break;
            }

            return(result);
        }
예제 #2
0
 void InitDatabase()
 {
     LoadSQLTextFile(SQLStatement.GetCreateUserTableQuery());
     LoadSQLTextFile(SQLStatement.GetCreateStaffTableQuery());
     LoadSQLTextFile(SQLStatement.GetCreatePeriodTypeTableQuery());
     LoadSQLTextFile(SQLStatement.GetCreatePeriodTableQuery());
     LoadSQLTextFile(SQLStatement.GetCreateCategoryTableQuery());
     LoadSQLTextFile(SQLStatement.GetCreatePaymentTableQuery());
     LoadSQLTextFile(SQLStatement.GetInsertUserQuery());
     LoadSQLTextFile(SQLStatement.GetInsertCategoryQuery());
     LoadSQLTextFile(SQLStatement.GetInsertPeriodTypeQuery());
 }
        private void BuildStaffFromTable()
        {
            staffTable = dbManager.GetDataTable(SQLStatement.GetStaffTableQuery());

            if (staffTable != null)
            {
                foreach (DataRow r in staffTable.Rows)
                {
                    Staff staff = new Staff(r["Name"].ToString(), r["Phone"].ToString());
                    fromStaffs.Add(staff);
                }
            }

            UpdateButtonsStatus(ButtonStatus.CanAdd);

            StaffListFrom.DataContext = fromStaffs;
            StaffListTo.DataContext   = toStaffs;
        }
예제 #4
0
        // testing function
        internal Boolean CheckUser(String username, String password)
        {
            Boolean valideUser = false;

            DataTable table = GetDataTable(SQLStatement.GetUserTableQuery());

            if (table != null)
            {
                string    filter = string.Format("Login_Name='{0}'", username);
                DataRow[] rows   = table.Select(filter);

                foreach (DataRow r in rows)
                {
                    if (r["Password"].ToString().Equals(MD5PWD.MD5HashPassword(password)))
                    {
                        valideUser = true;
                        break;
                    }
                }
            }

            return(valideUser);
        }
        private void CreateReportGroup()
        {
            int periodNum;

            // remove all rows
            if (PeriodGrid.RowDefinitions.Count > 0)
            {
                PeriodGrid.RowDefinitions.RemoveRange(0, PeriodGrid.RowDefinitions.Count);
                PeriodGrid.Children.Clear();
            }

            periodTable = dbManager.GetDataTable(SQLStatement.GetPeriodTypeTableQuery());

            if (periodTable == null || periodTable.Rows.Count == 0)
            {
                // create a message label to indicate there is no period type available
                // and offer a button to create default period type table
                RowDefinition periodRow1 = new RowDefinition();

                RowDefinition periodRow2 = new RowDefinition();

                PeriodGrid.RowDefinitions.Add(periodRow1);
                PeriodGrid.RowDefinitions.Add(periodRow2);

                // add a label to the first row
                TextBlock txtMsg = new TextBlock();
                txtMsg.Text         = @"Unable to detect any period type in the database, please either add a new period type from the Period button, or use the button below to create default period types: Daily, Weekly, Fortnightly, Monthly, Quarterly, Annually.";
                txtMsg.TextWrapping = TextWrapping.Wrap;
                txtMsg.FontSize     = 15;
                txtMsg.FontWeight   = FontWeights.Bold;
                txtMsg.Margin       = new Thickness(12);

                btnPeriod.BorderBrush     = Brushes.Red;
                btnPeriod.BorderThickness = new Thickness(6);

                Grid.SetRow(txtMsg, 0);

                PeriodGrid.Children.Add(txtMsg);

                // add a button to the second row
                Button btnAddDefault = new Button();

                btnAddDefault.Content  = @"Restore Default Period Types";
                btnAddDefault.FontSize = 15;

                btnAddDefault.Foreground = Brushes.Red;
                btnAddDefault.Margin     = new Thickness(12);

                btnAddDefault.VerticalAlignment = VerticalAlignment.Top;

                btnAddDefault.Click += btnAddDefault_Click;

                Grid.SetRow(btnAddDefault, 1);

                PeriodGrid.Children.Add(btnAddDefault);
            }
            else
            {
                periodNum = periodTable.Rows.Count;

                for (int i = 1; i <= periodNum; i++)
                {
                    RowDefinition periodRow = new RowDefinition();
                    PeriodGrid.RowDefinitions.Add(periodRow);
                }

                // add buttons
                for (int i = 0; i < periodNum; i++)
                {
                    Button btn = new Button();

                    string btnContent = string.Format("{0} Report", periodTable.Rows[i]["Period_Type"].ToString());

                    btn.Content  = btnContent;
                    btn.FontSize = 15;

                    //  btn.Foreground = Brushes.Red;
                    btn.Margin = new Thickness(12);

                    // set tag
                    btn.Tag = periodTable.Rows[i]["Period_Type_ID"];

                    btn.Click += BTN_Period_Type_Clicked;

                    Grid.SetRow(btn, i);

                    PeriodGrid.Children.Add(btn);
                }
            }
        }