Пример #1
0
/************************* Maintain Service Address Form Events ***********************************/

        public void TermsView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var dgv = sender as DataGridView;

            if ((e.ColumnIndex == 3) && (e.RowIndex > -1))//-----------------------------------DateCell
            {
                _srvAddrForm.ShowPicker(true, e.RowIndex);
                return;
            }
            if ((e.ColumnIndex == 5) && (e.RowIndex > -1))//-----------------------------------Remove
            {
                _srvAddrForm.ShowPicker(false, -1);
                try
                {
                    MContractServices.Delete(dgv.Rows[e.RowIndex].Cells["TermID"].Value.ToString());
                    dgv.Rows.RemoveAt(e.RowIndex);
                    IncDecServices(false, _srvAddrForm.GetAddrIndex());
                }
                catch (Exception ed) { }
            }
            else
            {
                _srvAddrForm.ShowPicker(false, -1);
            }
        }
Пример #2
0
        public static void DeleteBlanks()
        {
            DataTable dt = GetColumn("Service_Address", "service_address_id", "address", "address", "'<empty>'");
            int       r  = dt.Rows.Count;

            if (r > 0)
            {
                for (int i = 0; i < r; i++)
                {
                    try { MContractServices.DeleteAll(dt.Rows[i][0].ToString()); }
                    catch (Exception) { }
                }

                Delete("'<empty>'", "Service_Address", "address");
            }
        }
Пример #3
0
        public void SrvAddr_Ok_Button_Click(object sender, EventArgs e)
        {
            int test = 1;

            if (_srvAddrForm.noChanges)
            {
                _srvAddrForm.Close();
                return;
            }

            else
            {
                String[,] values = _srvAddrForm.GetInputs();
                bool okToSubmit = true;

                if (okToSubmit)
                {
                    if (MessageBox.Show("Are you sure you want to submit these changes?", "Confirm Submission", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        MContractServices cs = new MContractServices();
                        try {
                            test = cs.SetMany(values, userID, _contractForm.GetEndDate());
                        }
                        catch (Exception) { MessageBox.Show("Error Updating Database"); }
                        if (test == 1)
                        {
                            _srvAddrForm.Close();
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
Пример #4
0
 public static void Delete(String id)
 {
     MContractServices.DeleteAll(id);
     Delete(id, "Service_Address", "service_address_id");
 }
Пример #5
0
/************************* Add Edit Contract Form Events *****************************************/

        public void Contract_Cell_Click(object sender, DataGridViewCellEventArgs e)
        {
            var dgv = sender as DataGridView;

            if ((e.ColumnIndex == 9) && (e.RowIndex > -1))//-----------------------------------Edit
            {
                #region Edit
                if (_contractForm.GetEndDate().ToShortDateString() != DateTime.Today.ToShortDateString())
                {
                    NewSrvAddr();
                    string addr   = "<No Address>";
                    String addrID = dgv.Rows[e.RowIndex].Cells[0].Value.ToString();
                    try { addr = dgv.Rows[e.RowIndex].Cells["address_col"].Value.ToString(); }
                    catch (NullReferenceException) { }

                    _srvAddrForm = new AddEditSrvAddrForm(this, addr, addrID, e.RowIndex);
                    try { _srvAddrForm.setFields(MContractServices.GetAll(addrID)); }
                    catch (Exception) { }

                    //  _srvAddrForm.Activate();
                    _srvAddrForm.ShowDialog();
                    _srvAddrForm.setDate(_contractForm.GetStartDate());
                    _contractForm.SetTableButtonMetrics(e.RowIndex, addrID);
                }
                else
                {
                    MessageBox.Show("Please specify the end date of the contract.", "Incomplete Contract", MessageBoxButtons.OKCancel);
                }
                #endregion
            }
            if ((e.ColumnIndex == 8) && (e.RowIndex > -1))// ----------------------------------Room
            {
                #region Room
                //int k = arg.RowIndex;
                String addrID = dgv.Rows[e.RowIndex].Cells["idCol"].Value.ToString();
                NewSrvAddr();
                _roomForm = new AddEditRoomForm(this, addrID, e.RowIndex);
                _roomForm.Activate();
                _roomForm.ShowDialog();

                _contractForm.SetTableButtonMetrics(e.RowIndex, addrID);
                return;

                #endregion
            }

            if ((e.ColumnIndex == 10) && (e.RowIndex > -1))//-----------------------------------Remove
            {
                #region Remove
                try
                {
                    string id = dgv.Rows[e.RowIndex].Cells["idCol"].Value.ToString();
                    MServiceAddress.Delete(id, "Service_Address", "service_addres_id");
                }
                catch (Exception) { }
                dgv.Rows.RemoveAt(e.RowIndex);
                #endregion
            }


            else//---------------------------------------------------------------------------Other
            {
                return;
            }
        }
Пример #6
0
        public void SrvAddr_Ok_Button_Click(object sender, EventArgs e)
        {
            int test = 1;
            if (_srvAddrForm.noChanges)
            {
                _srvAddrForm.Close();
                return;
            }

            else
            {
                String[,] values = _srvAddrForm.GetInputs();
                bool okToSubmit = true;

                if (okToSubmit)
                {
                    if (MessageBox.Show("Are you sure you want to submit these changes?", "Confirm Submission", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        MContractServices cs = new MContractServices();
                        try {

                            test = cs.SetMany(values, userID, _contractForm.GetEndDate());
                        }
                        catch (Exception) { MessageBox.Show("Error Updating Database"); }
                        if(test == 1)
                        _srvAddrForm.Close();

                    }
                    else
                    {
                        return;
                    }
                }
            }
        }