Example #1
0
        private void save_Click(object sender, EventArgs e)
        {
            if (customer == null)
            {
                isNew    = true;
                customer = new Customer();
            }
            customer.Name           = txtName.Text;
            customer.ContactNumber  = txtContractNumber.Text;
            customer.ContactPerson  = txtContractPerson.Text;
            customer.AnyDescription = txtDescription.Text;
            if (isNew)
            {
                da.AddCustomer(customer);
            }
            else
            {
                da.Update();
            }
            AddContract parent = (AddContract)this.Owner;

            if (parent != null)
            {
                parent.updateCustomerName(customer.Name, customer.Id);
            }
            this.Close();
        }
        private void ContractGrid_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int contractId = 0;

            if (ContractGrid.SelectedRows.Count > 0)
            {
                var row = ContractGrid.SelectedRows[0];
                contractId = ((dynamic)row.DataBoundItem).Id;
            }
            int customerId = 0;

            if (CustomerGrid.SelectedRows.Count > 0)
            {
                var row = CustomerGrid.SelectedRows[0];
                customerId = ((dynamic)row.DataBoundItem).Id;
            }
            var form = new AddContract(customerId);

            form.EditContract(contractId);
            if (form.ShowDialog() == DialogResult.OK)
            {
                da = new DataAccess();
                LoadContractorGrid();

                //todo: noting
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (isNew)
            {
                cp = new ContractPayment();
            }
            cp.Amount        = decimal.Parse(txtAmount.Text);
            cp.PaymentMethod = ddPaymentMethod.Text;
            cp.PaymentNo     = int.Parse(txtPaymentNo.Text);
            cp.Status        = ddStatus.Text;
            cp.DueDate       = DateTime.Parse(ddDueDate.Text);
            cp.Note          = txtNote.Text;
            if (isNew)
            {
                da.AddPaymentByContractId(_contractId, cp);
            }
            else
            {
                da.Update();
            }

            AddContract parent = (AddContract)this.Owner;

            parent.updatePaymentInfo();
        }
        private void NewPayment_Click(object sender, EventArgs e)
        {
            var form = new AddContract(0);

            if (form.ShowDialog() == DialogResult.OK)
            {
                // todo nothing
            }
        }
        private void NewContract_Click(object sender, EventArgs e)
        {
            int customerId = 0;

            var form = new AddContract(customerId, _spaceUnitId);

            form.SelectBuildingAndSpaceUnit();
            if (form.ShowDialog() == DialogResult.OK)
            {
                da = new DataAccess();
                LoadContractGrid();
            }
        }
        private void NewContract_Click(object sender, EventArgs e)
        {
            int customerId = 0;

            if (CustomerGrid.SelectedRows.Count > 0)
            {
                var row = CustomerGrid.SelectedRows[0];
                customerId = ((dynamic)row.DataBoundItem).Id;
            }
            var form = new AddContract(customerId);

            if (form.ShowDialog() == DialogResult.OK)
            {
                da = new DataAccess();
                LoadContractGrid();
            }
        }
        private void ContractGrid_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            string contractId = "0";

            if (ContractGrid.SelectedRows.Count > 0)
            {
                var row = ContractGrid.SelectedRows[0];
                contractId = ((dynamic)row.DataBoundItem).CustomerId;
            }
            var form = new AddContract(int.Parse(contractId.Split('-')[0]));

            form.EditContract(int.Parse(contractId.Split('-')[1]));
            if (form.ShowDialog() == DialogResult.OK)
            {
                da = new DataAccess();
                LoadContractGrid();

                //todo: noting
            }
        }