Beispiel #1
0
        public Main(String acc)
        {
            InitializeComponent();

            var materialSkinManager = MaterialSkinManager.Instance;

            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            materialSkinManager.ColorScheme = new ColorScheme(Primary.LightGreen500, Primary.Brown800, Primary.BlueGrey500, Accent.Orange100, TextShade.BLACK);

            curent = accDAO.getAllByAccount(acc);

            GetSource.getTableSource(AccountDAO.READ_ALL, dgvAccount);
            GetSource.getTableSource(CustomerDAO.READ_ALL, dgvCustomer);
            GetSource.getTableSource(BillDAOL.READ_ALL, dgvBill);
            GetSource.getTableSource(BookedDAO.SPECIAL, dgvBooked);
            GetSource.getTableSource(CourseDAO.READ_ALL, dgvCourse);
            GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);

            GetSource.getComboxSource(RoleDAO.READ_ALL, cbbRole, "roleName");
            GetSource.getComboxSource(RoleDAO.READ_ALL, cbbPer, "roleName");
            GetSource.getComboxSource(TypeDAO.READ_ALL, cbbType, "Name");
            GetSource.getComboxSource(TypeDAO.READ_ALL, cbbType2, "Name");
            GetSource.getComboxSource(CustomerDAO.READ_ALL, cbbBookCus, "fullName");
            cbbRole.SelectedIndex = -1;
            txtStaff.Text         = curent.accountName;

            GetSource.invisibleColumnAccount(dgvAccount);
            GetSource.invisibleColumnCourse(dgvCourse);
            GetSource.invisibleColumnId(dgvCustomer); GetSource.invisibleColumnId(dgvBooked);
            GetSource.invisibleColumnBill(dgvBill);
            GetSource.invisibleColumnPer(dgvPer);
        }
Beispiel #2
0
        private void dgvPer_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (string.Compare(dgvPer.CurrentCell.OwningColumn.Name, "active") == 0)
            {
                bool checkBoxStatus = Convert.ToBoolean(dgvPer.CurrentCell.EditedFormattedValue);

                if (checkBoxStatus)
                {
                    int id  = Convert.ToInt32(dgvPer.CurrentRow.Cells[3].Value);
                    var idr = cbbPer.SelectedValue.ToString();
                    int id1 = -1;
                    try
                    {
                        id1 = Convert.ToInt32(idr);
                    }
                    catch (Exception ex) { }

                    rfDAO.update(id1, id, 1);
                    GetSource.getTableSourceFromList <RoleFunc>(rfDAO.getAllByIDRole(id1), dgvPer);
                }
                else
                {
                    int id  = Convert.ToInt32(dgvPer.CurrentRow.Cells[3].Value);
                    var idr = cbbPer.SelectedValue.ToString();
                    int id1 = -1;
                    try
                    {
                        id1 = Convert.ToInt32(idr);
                    }
                    catch (Exception ex) { }
                    rfDAO.update(id1, id, 0);
                    GetSource.getTableSourceFromList <RoleFunc>(rfDAO.getAllByIDRole(id1), dgvPer);
                }
            }
        }
Beispiel #3
0
        private void dgvAccount_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (string.Compare(dgvAccount.CurrentCell.OwningColumn.Name, "active") == 0)
            {
                bool checkBoxStatus = Convert.ToBoolean(dgvAccount.CurrentCell.EditedFormattedValue);

                if (checkBoxStatus)
                {
                    int id = Convert.ToInt32(dgvAccount.CurrentRow.Cells[0].Value);
                    accDAO.reactive(id);
                    Diary dia = new Diary();
                    dia.account     = curent.id;
                    dia.date        = DateTime.Today;
                    dia.description = "Reactive account " + id.ToString();
                    diaryDAO.create(dia);
                    GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
                }
                else
                {
                    int id = Convert.ToInt32(dgvAccount.CurrentRow.Cells[0].Value);
                    accDAO.delete(id);
                    Diary dia = new Diary();
                    dia.account     = curent.id;
                    dia.date        = DateTime.Today;
                    dia.description = "Deactive account " + id.ToString();
                    diaryDAO.create(dia);
                    GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
                }
            }
        }
Beispiel #4
0
        private void btnEditCourse_Click(object sender, EventArgs e)
        {
            Course a = new Course();

            a.name   = txtCourseName.Text;
            a.months = Convert.ToDecimal(txtCourseMont.Text);
            a.price  = Convert.ToDecimal(txtCoursePrice.Text);
            a.type   = Convert.ToInt32(cbbType.SelectedValue);

            int id = -1;

            if (dgvAccount != null && dgvCourse.SelectedRows.Count > 0)
            {
                DataGridViewRow i = dgvCourse.SelectedRows[0];
                id = Int32.Parse(i.Cells[0].Value.ToString());
            }
            if (id != -1)
            {
                a.id = id;
                courseDAO.update(a);
                GetSource.getTableSource(CourseDAO.READ_ALL, dgvCourse);
                MessageBox.Show("Updated", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Diary dia = new Diary();
                dia.account     = curent.id;
                dia.date        = DateTime.Today;
                dia.description = "Edited new course " + a.name;
                diaryDAO.create(dia);
                GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
            }
        }
Beispiel #5
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            String key = txtSearch.Text;

            if (key.Equals(""))
            {
                GetSource.getTableSource(BillDAOL.READ_ALL, dgvBill);
            }
            else
            {
                List <Object> search = new List <Object>();

                DataGridViewRowCollection rows = dgvBill.Rows;
                foreach (DataGridViewRow row in rows)
                {
                    if (row.Cells[1].Value.ToString().Contains(key))
                    {
                        search.Add(new
                        {
                            id       = row.Cells[0].Value,
                            fullname = row.Cells[1].Value,
                            address  = row.Cells[2].Value,
                            phone    = row.Cells[3].Value,
                            cusid    = row.Cells[4].Value,
                            name     = row.Cells[5].Value,
                            startday = row.Cells[6].Value,
                            paid     = row.Cells[7].Value
                        });
                    }
                }

                GetSource.getTableSourceFromList <Object>(search, dgvBill);
            }
        }
Beispiel #6
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            Accounts a = new Accounts();

            a.accountName = txtAcc.Text;
            a.fullName    = txtAccName.Text;
            a.role        = Int32.Parse(cbbRole.SelectedValue.ToString());
            Dialog dialog = new Dialog();

            dialog.ShowDialog();
            a.passWord = dialog.pass;
            if (a.passWord != null)
            {
                accDAO.create(a);
                GetSource.getTableSource(AccountDAO.READ_ALL, dgvAccount);
                MessageBox.Show("Created", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Diary dia = new Diary();
                dia.account     = curent.id;
                dia.date        = DateTime.Today;
                dia.description = "Create new account";
                diaryDAO.create(dia);
                GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
            }
            else
            {
                MessageBox.Show("Can not create this account ", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #7
0
        private void btnCusDele_Click(object sender, EventArgs e)
        {
            Customer a = new Customer();

            a.name    = txtCusName.Text;
            a.address = txtCusAddr.Text;
            a.phone   = txtCusPhone.Text;
            int id = -1;

            if (dgvAccount != null && dgvCustomer.SelectedRows.Count > 0)
            {
                DataGridViewRow i = dgvCustomer.SelectedRows[0];
                id = Int32.Parse(i.Cells[0].Value.ToString());
            }
            if (id != -1)
            {
                a.id = id;
                cusDAO.delete(a);
                GetSource.getTableSource(CustomerDAO.READ_ALL, dgvCustomer);
                MessageBox.Show("Deleted", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Diary dia = new Diary();
                dia.account     = curent.id;
                dia.date        = DateTime.Today;
                dia.description = "Delete customer " + a.name;
                diaryDAO.create(dia);
                GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
            }
        }
Beispiel #8
0
        private void btnResetCourse_Click(object sender, EventArgs e)
        {
            txtCourseMont.Text    = "";
            txtCourseName.Text    = "";
            txtCoursePrice.Text   = "";
            cbbType.SelectedIndex = -1;

            GetSource.getTableSource(CourseDAO.READ_ALL, dgvCourse);
        }
Beispiel #9
0
        protected virtual TBody WithMultipleObjects <T>(SequenceGenerator <T> sequenceGenerator)
            where T : IEndable <TBody>
        {
            var sequence = sequenceGenerator.Invoke(WithObject <T>);

            foreach (var element in sequence)
            {
                element.End(); //force generation
            }

            return(GetSource.Invoke());
        }
Beispiel #10
0
        public void RunCallsDefaultSourceControlBlock()
        {
            var getSourceCalled = false;
            var block           = new SourceControlBlockStub
            {
                GetSourceAction = p => getSourceCalled = true
            };
            var task    = new GetSource();
            var project = new Project("Name", task);

            project.SourceControl.Add(block);
            var result = task.Run(null);

            result.Count();
            Assert.IsTrue(getSourceCalled);
        }
Beispiel #11
0
        public void InitVideoCtrls()
        {
            DataReqEventArgs eData = new DataReqEventArgs();

            GetSource?.Invoke(this, eData);
            if (eData.Source != null)
            {
                // timer
                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval = TimeSpan.FromMilliseconds(10);
                timer.Tick    += Timer_Tick;
                timer.Start();
            }
            NotifyPropertyChanged("VideoSpanLblContent");
            NotifyPropertyChanged("VideoPositionSldrMax");
        }
Beispiel #12
0
        private void btnCusCreate_Click(object sender, EventArgs e)
        {
            Customer a = new Customer();

            a.name    = txtCusName.Text;
            a.address = txtCusAddr.Text;
            a.phone   = txtCusPhone.Text;
            cusDAO.create(a);
            GetSource.getTableSource(CustomerDAO.READ_ALL, dgvCustomer);
            GetSource.getComboxSource(CustomerDAO.READ_ALL, cbbBookCus, "fullName");
            MessageBox.Show("Created", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Diary dia = new Diary();

            dia.account     = curent.id;
            dia.date        = DateTime.Today;
            dia.description = "Create customer " + a.name;
            diaryDAO.create(dia);
            GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
        }
Beispiel #13
0
        private void cbbPer_SelectedValueChanged(object sender, EventArgs e)
        {
            var id = cbbPer.SelectedValue.ToString();


            int id1 = -1;

            try
            {
                id1 = Convert.ToInt32(id);
            }
            catch (Exception ex) { }


            if (id1 != -1)
            {
                GetSource.getTableSourceFromList <RoleFunc>(rfDAO.getAllByIDRole(id1), dgvPer);
            }
        }
Beispiel #14
0
        private void materialFlatButton4_Click(object sender, EventArgs e)
        {
            Course course = new Course();

            course.name   = txtCourseName.Text;
            course.months = Convert.ToDecimal(txtCourseMont.Text);
            course.price  = Convert.ToDecimal(txtCoursePrice.Text);
            course.type   = Convert.ToInt32(cbbType.SelectedValue);

            courseDAO.create(course);
            cbbType.SelectedIndex = -1;
            GetSource.getTableSource(CourseDAO.READ_ALL, dgvCourse);
            MessageBox.Show("Created", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

            Diary dia = new Diary();

            dia.account     = curent.id;
            dia.date        = DateTime.Today;
            dia.description = "Create new course " + course.name;
            diaryDAO.create(dia);
            GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
        }
Beispiel #15
0
        private void btnSubmitBook_Click(object sender, EventArgs e)
        {
            Booked booked = new Booked();

            booked.course   = Convert.ToInt32(cbBookCourse.SelectedValue);
            booked.customer = Convert.ToInt32(cbbBookCus.SelectedValue);
            booked.paid     = checkBox1.Checked;
            booked.staff    = curent.id;
            booked.startDay = datePicker.Value;

            bkDAO.create(booked);
            GetSource.getTableSource(BookedDAO.SPECIAL, dgvBooked);
            GetSource.getTableSource(BillDAOL.READ_ALL, dgvBill);
            MessageBox.Show("Booked", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Diary dia = new Diary();

            dia.account     = curent.id;
            dia.date        = DateTime.Today;
            dia.description = "Booked new course " + booked.course;
            diaryDAO.create(dia);
            GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
        }
Beispiel #16
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int          id  = 0;
            DataGridView dgv = sender as DataGridView;

            if (dgvAccount != null && dgvAccount.SelectedRows.Count > 0)
            {
                DataGridViewRow i = dgvAccount.SelectedRows[0];
                id = Int32.Parse(i.Cells[0].Value.ToString());
            }
            Accounts acc = new Accounts();

            acc.accountName = txtAcc.Text;
            acc.fullName    = txtAccName.Text;
            acc.role        = Int32.Parse(cbbRole.SelectedValue.ToString());
            Dialog dialog = new Dialog();

            dialog.ShowDialog();
            acc.passWord = dialog.pass;
            if (id != 0 && acc.passWord != null)
            {
                acc.id = id;
                accDAO.update(acc);
                GetSource.getTableSource(AccountDAO.READ_ALL, dgvAccount);
                MessageBox.Show("Edited", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Diary dia = new Diary();
                dia.account     = curent.id;
                dia.date        = DateTime.Today;
                dia.description = "Edit account " + acc.accountName;
                diaryDAO.create(dia);
                GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
            }
            else
            {
                MessageBox.Show("Can not edit this account ", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #17
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Delete this account ? ", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                int          id  = -1;
                DataGridView dgv = sender as DataGridView;
                if (dgvAccount != null && dgvAccount.SelectedRows.Count > 0)
                {
                    DataGridViewRow i = dgvAccount.SelectedRows[0];
                    id = Int32.Parse(i.Cells[0].Value.ToString());
                }

                Accounts acc = new Accounts();
                acc.accountName = txtAcc.Text;
                acc.fullName    = txtAccName.Text;
                acc.role        = Int32.Parse(cbbRole.SelectedValue.ToString());
                if (id != -1)
                {
                    acc.id = id;
                    accDAO.delete(id);
                    GetSource.getTableSource(AccountDAO.READ_ALL, dgvAccount);
                }
                MessageBox.Show("Deleted", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Diary dia = new Diary();
                dia.account     = curent.id;
                dia.date        = DateTime.Today;
                dia.description = "Delete account " + acc.accountName;
                diaryDAO.create(dia);
                GetSource.getTableSource(DiaryDAO.READ_ALL, dgvLog);
            }
            else
            {
                MessageBox.Show("Can not deleted this account ", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #18
0
        private void btnPaidBill_Click(object sender, EventArgs e)
        {
            Bill acc = new Bill();

            acc.staff = curent.id;

            if (dgvBill != null && dgvBill.SelectedRows.Count > 0)
            {
                DataGridViewRow i = dgvBill.SelectedRows[0];
                acc.booked = Int32.Parse(i.Cells[0].Value.ToString());
                acc.date   = dateTimePicker1.Value;
                billDAO.create(acc);
                bkDAO.paid(acc.booked);
                GetSource.getTableSource(BillDAOL.READ_ALL, dgvBill);
                GetSource.getTableSource(BookedDAO.SPECIAL, dgvBooked);
                MessageBox.Show("Paided", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Can not paid this ", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Booked bk = bkDAO.findByID(acc.booked);
        }
 var(ops, duration) = new T().Sort(GetSource(sourceSize));