コード例 #1
0
 public void clearDocumentData()
 {
     try
     {
         cmbDocumentStatus.SelectedIndex = 0;
         txtDocument.Text    = "";
         txtEmployee.Text    = "";
         txtSnrEmployee.Text = "";
         prevdoc             = new docempmapping();
     }
     catch (Exception)
     {
     }
 }
コード例 #2
0
 private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     try
     {
         if (e.ColumnIndex == 5)
         {
             clearDocumentData();
             btnDocument.Enabled = false;
             prevdoc             = new docempmapping();
             int rowID = e.RowIndex;
             btnSave.Text             = "Update";
             pnlDocumentInner.Visible = true;
             pnlDocumentOuter.Visible = true;
             pnlDocumentList.Visible  = false;
             prevdoc.DocumentID       = grdList.Rows[e.RowIndex].Cells[0].Value.ToString();
             prevdoc.EmployeeID       = grdList.Rows[e.RowIndex].Cells[2].Value.ToString().Substring(grdList.Rows[e.RowIndex].Cells[2].Value.ToString().Trim().IndexOf('-') + 1);
             prevdoc.SeniorEmployeeID = grdList.Rows[e.RowIndex].Cells[3].Value.ToString().Substring(grdList.Rows[e.RowIndex].Cells[3].Value.ToString().Trim().IndexOf('-') + 1);
             txtDocument.Text         = grdList.Rows[e.RowIndex].Cells[1].Value.ToString() + '-' + grdList.Rows[e.RowIndex].Cells[0].Value.ToString();
             txtEmployee.Text         = grdList.Rows[e.RowIndex].Cells[2].Value.ToString();
             txtSnrEmployee.Text      = grdList.Rows[e.RowIndex].Cells[3].Value.ToString();
             ////////cmbDocument.SelectedIndex = cmbDocument.FindStringExact(grdList.Rows[e.RowIndex].Cells[0].Value.ToString() + "-" + grdList.Rows[e.RowIndex].Cells[1].Value.ToString());
             //cmbDocument.SelectedIndex =
             //    Structures.ComboFUnctions.getComboIndex(cmbDocument, grdList.Rows[e.RowIndex].Cells[0].Value.ToString());
             //cmbEmployee.SelectedIndex = cmbEmployee.FindStringExact(grdList.Rows[e.RowIndex].Cells[2].Value.ToString());
             //cmbSeniorEmployee.SelectedIndex = cmbSeniorEmployee.FindStringExact(grdList.Rows[e.RowIndex].Cells[3].Value.ToString());
             //cmbDocumentStatus.SelectedIndex = cmbDocumentStatus.FindStringExact(grdList.Rows[e.RowIndex].Cells[4].Value.ToString());
             //cmbDocument.Enabled = false;
             disableBottomButtons();
         }
     }
     catch (Exception)
     {
     }
 }
コード例 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                docempmapping   doc   = new docempmapping();
                DocEmpMappingDB docDB = new DocEmpMappingDB();


                try
                {
                    string[] docmts   = txtDocument.Text.Split('-');
                    string[] emply    = txtEmployee.Text.Split('-');
                    string[] snremply = txtSnrEmployee.Text.Split('-');
                    doc.DocumentID         = docmts[1];
                    doc.DocumentName       = docmts[0];
                    doc.EmployeeID         = emply[1];
                    doc.EmployeeName       = emply[0];
                    doc.SeniorEmployeeID   = snremply[1];
                    doc.SeniorEmployeeName = snremply[0];
                    //doc.DocumentID = ((Structures.ComboBoxItem)cmbDocument.SelectedItem).HiddenValue;
                    //////////doc.DocumentName = cmbDocument.SelectedItem.ToString().Trim().Substring(cmbDocument.SelectedItem.ToString().Trim().IndexOf('-') + 1);
                    //doc.DocumentName = ((Structures.ComboBoxItem)cmbDocument.SelectedItem).ToString();
                    //doc.EmployeeName = cmbEmployee.SelectedItem.ToString().Trim().Substring(0, cmbEmployee.SelectedItem.ToString().Trim().IndexOf('-'));
                    //doc.EmployeeID = cmbEmployee.SelectedItem.ToString().Trim().Substring(cmbEmployee.SelectedItem.ToString().Trim().IndexOf('-') + 1);
                    //doc.SeniorEmployeeName = cmbSeniorEmployee.SelectedItem.ToString().Trim().Substring(0, cmbSeniorEmployee.SelectedItem.ToString().Trim().IndexOf('-'));
                    //doc.SeniorEmployeeID = cmbSeniorEmployee.SelectedItem.ToString().Trim().Substring(cmbSeniorEmployee.SelectedItem.ToString().Trim().IndexOf('-') + 1);
                }
                catch (Exception)
                {
                    doc.DocumentID         = "";
                    doc.DocumentName       = "";
                    doc.EmployeeName       = "";
                    doc.EmployeeID         = "";
                    doc.SeniorEmployeeName = "";
                    doc.SeniorEmployeeID   = "";
                }

                doc.DocumentStatus = ComboFIll.getStatusCode(cmbDocumentStatus.SelectedItem.ToString());
                System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button;
                string btnText = btn.Text;

                {
                    if (btnText.Equals("Update"))
                    {
                        if (docDB.updateDocEmpMapping(doc, prevdoc))
                        {
                            MessageBox.Show("DocEmpMapping Status updated");
                            closeAllPanels();
                            ListDocEmpMapping();
                        }
                        else
                        {
                            MessageBox.Show("Failed to update DocEmpMapping Status");
                        }
                    }
                    else if (btnText.Equals("Save"))
                    {
                        if (docDB.validateDocument(doc))
                        {
                            if (docDB.insertDocEmpMapping(doc))
                            {
                                MessageBox.Show("DocEmpMapping data Added");
                                closeAllPanels();
                                ListDocEmpMapping();
                            }
                            else
                            {
                                MessageBox.Show("Failed to Insert DocEmpMapping");
                            }
                        }
                        else
                        {
                            MessageBox.Show("DocEmpMapping Data Validation failed");
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Failed Adding / Editing User Data");
            }
        }