Beispiel #1
0
 public void clearDocumentData()
 {
     try
     {
         cmbStatus.SelectedIndex = 0;
         txtDocument.Text        = "";
         txtEmployee.Text        = "";
         cmbOffice.SelectedIndex = 0;
         prevdoc = new documentreceiver();
     }
     catch (Exception)
     {
     }
 }
Beispiel #2
0
 private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     try
     {
         string columnName = grdList.Columns[e.ColumnIndex].Name;
         if (columnName.Equals("Edit"))
         {
             clearDocumentData();
             prevdoc = new documentreceiver();
             int rowID = e.RowIndex;
             btnSave.Text             = "Update";
             pnlDocumentInner.Visible = true;
             pnlDocumentOuter.Visible = true;
             pnlDocumentList.Visible  = false;
             prevdoc.RowID            = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["RowID"].Value);
             prevdoc.DocumentID       = grdList.Rows[e.RowIndex].Cells["DocumentID"].Value.ToString();
             prevdoc.EmployeeID       = grdList.Rows[e.RowIndex].Cells["EmployeeID"].Value.ToString();
             prevdoc.OfficeID         = grdList.Rows[e.RowIndex].Cells["OfficeID"].Value.ToString();
             cmbOffice.SelectedIndex  =
                 Structures.ComboFUnctions.getComboIndex(cmbOffice, prevdoc.OfficeID);
             txtDocument.Text = grdList.Rows[e.RowIndex].Cells["DocumentName"].Value.ToString() + "-" +
                                grdList.Rows[e.RowIndex].Cells["DocumentID"].Value.ToString();
             txtEmployee.Text = grdList.Rows[e.RowIndex].Cells["Employee"].Value.ToString() + "-" +
                                grdList.Rows[e.RowIndex].Cells["EmployeeID"].Value.ToString();
             cmbStatus.SelectedIndex = cmbStatus.FindString(grdList.Rows[e.RowIndex].Cells["Status"].Value.ToString());
             txtDocument.Enabled     = false;
             btnSelDoc.Enabled       = false;
             disableBottomButtons();
         }
     }
     catch (Exception)
     {
     }
 }
Beispiel #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                documentreceiver   drrec = new documentreceiver();
                DocumentReceiverDB drDB  = new DocumentReceiverDB();
                try
                {
                    string[] docmts = txtDocument.Text.Split('-');
                    string[] emply  = txtEmployee.Text.Split('-');
                    drrec.DocumentID = docmts[1];
                    drrec.EmployeeID = emply[1];
                    drrec.OfficeID   = ((Structures.ComboBoxItem)cmbOffice.SelectedItem).HiddenValue;
                    drrec.OfficeName = ((Structures.ComboBoxItem)cmbOffice.SelectedItem).ToString();
                }
                catch (Exception)
                {
                    drrec.DocumentID   = "";
                    drrec.DocumentName = "";
                    drrec.EmployeeName = "";
                    drrec.EmployeeID   = "";
                    drrec.OfficeID     = "";
                    drrec.OfficeName   = "";
                }

                drrec.Status = getStatusCode(cmbStatus.SelectedItem.ToString());
                System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button;
                string btnText = btn.Text;

                {
                    if (btnText.Equals("Update"))
                    {
                        if (drDB.updateDocumentReceiver(drrec, prevdoc))
                        {
                            MessageBox.Show("Document Receiver Status updated");
                            closeAllPanels();
                            ListDocumentReceiver();
                        }
                        else
                        {
                            MessageBox.Show("Failed to update Document Receiver Status");
                        }
                    }
                    else if (btnText.Equals("Save"))
                    {
                        if (drDB.validateDocument(drrec))
                        {
                            if (drDB.insertDocumentReceiver(drrec))
                            {
                                MessageBox.Show("Document Receiver Added");
                                closeAllPanels();
                                ListDocumentReceiver();
                            }
                            else
                            {
                                MessageBox.Show("Failed to Insert Document Receiver");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Document Receiver Validation failed");
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Failed Adding / Editing Document Receiver");
            }
        }