示例#1
0
 public ProjectsForm(MainForm form)
 {
     InitializeComponent();
     mainform = form;
     db = mainform.DataAppCore;
     currentModel = new Project();
     //set data grid settings
     ControlFactory.SetDataGridSettings(this.dataGridViewMainSearchResult);
 }
        private void Seed()
        {
            //set default data here
            User rootUser = new User() {
                Id = 999,
                IsActive = true,
                Username = "******",
                Password = "******",
                Token = ""
            };

            Company company = new Company()
            {
                Id = 1,
                Name = "NA",
                Description = "NA",
                Email = "NA",
                IsHidden = false,
                Contact = "NA"
            };

            Project project = new Project()
            {
                Id = 1,
                Name = "NA",
                Description = "NA",
                IsHidden = false
            };

            Check check = new Check()
            {
                Id = 1,
                IsHidden = false,
                IssuedOn = DateTime.Now,
                VoucherNumber = "NA",
                Amount = 0,
                CompanyId = 1
            };

            Expense expense = new Expense()
            {
                Id = 1,
                IsHidden = false,
                Date = DateTime.Now,
                Amount = 0,
                ProjectId=1,
                CompanyId = 1,
                CheckId=1,
                ORNUmber = "xxx",
                Description = "NA"
            };

            if (this.UserController.Get(rootUser.Id) == null)
                this.UserController.Add(rootUser);

            if (this.CompanyController.Get(company.Id) == null)
                this.CompanyController.Add(company);

            if (this.ProjectController.Get(project.Id) == null)
                this.ProjectController.Add(project);

            //if (this.ProjectController.Get(project2.Id) == null)
            //    this.ProjectController.Add(project2);

            if (this.CheckController.Get(check.Id) == null)
                this.CheckController.Add(check);

            if (this.ExpenseController.Get(expense.Id) == null)
                this.ExpenseController.Add(expense);
        }
 public ProjectViewModel(Project project)
 {
     this.project = project;
 }
示例#4
0
        private void EditSelectedObject()
        {
            if (this.contextMenuStripGridView.Items[0].Selected)
            {
                int selectedRowId = 0;

                foreach (DataGridViewRow row in dataGridViewMainSearchResult.SelectedRows)
                {
                    int.TryParse(row.Cells[0].Value.ToString(), out selectedRowId);
                }

                //fetch data
                this.currentModel = db.ProjectController.Get(selectedRowId);

                MapObjectToControls();
                tabControlMain.SelectedIndex = 1;
            }

            //add
            if (this.contextMenuStripGridView.Items[1].Selected)
            {
                ResetDetailsPane();
                tabControlMain.SelectedIndex = 1;
            }
        }
示例#5
0
        private void SaveDataToDB(bool isUpdate=false)
        {
            try
            {
                if(isUpdate == false)
                    currentModel = new Project();

                //map controls to object
                MapControlsToObject();

                //validate
                if (string.IsNullOrEmpty(currentModel.Name) || string.IsNullOrEmpty(currentModel.Description))
                {
                    MessageBox.Show("Please check empty input fields.");
                    return;
                }

                bool result = false;

                if (isUpdate == false)
                    result = db.ProjectController.Add(currentModel);
                else
                    result = db.ProjectController.Update(currentModel);

                if (result)
                {
                    if (isUpdate == false)
                        currentModel = db.ProjectController.Get(currentModel.Id);

                    //map
                    MapObjectToControls();
                    TogleUpdateButtons();
                    mainform.WriteStatusBar("Record saved...");
                }
                else
                {
                    mainform.WriteStatusBar("Saving failed...");
                    MessageBox.Show("Saving failed...");
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
示例#6
0
        void ResetDetailsPane()
        {
            textBoxDetailsDescription.Text = "";
            numericUpDownDetailsID.Value = 0;
            textBoxDetailsDescription.Text = "";
            textBoxDetailsName.Text = "";

            currentModel = new Project();

            buttonDetailsUpdate.Enabled = false;
            buttonDetailsDelete.Enabled = false;
            buttonDetailsAdd.Enabled = true;
        }