示例#1
0
 public void clearDocumentData()
 {
     try
     {
         cmbDocumentStatus.SelectedIndex = -1;
         txtEmployee.Text       = "";
         txtDocument.Text       = "";
         txtFinancialLimit.Text = "";
         prevflim = new financiallimit();
     }
     catch (Exception)
     {
     }
 }
示例#2
0
        private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            try
            {
                if (e.ColumnIndex == 5)
                {
                    clearDocumentData();
                    prevflim = new financiallimit();
                    int rowID = e.RowIndex;
                    btnSave.Text             = "Update";
                    pnlDocumentInner.Visible = true;
                    pnlDocumentOuter.Visible = true;
                    pnlDocumentList.Visible  = false;
                    prevflim.DocumentID      = grdList.Rows[e.RowIndex].Cells["DocID"].Value.ToString();
                    prevflim.EmployeeID      = grdList.Rows[e.RowIndex].Cells["EmpName"].Value.ToString().Substring(grdList.Rows[e.RowIndex].Cells["EmpName"].Value.ToString().Trim().IndexOf('-') + 1);
                    prevflim.FinancialLimit  = Convert.ToDouble(grdList.Rows[e.RowIndex].Cells["FinLimit"].Value.ToString());
                    ////////cmbDocument.SelectedIndex = cmbDocument.FindStringExact(grdList.Rows[e.RowIndex].Cells["DocID"].Value.ToString() + "-" + grdList.Rows[e.RowIndex].Cells["DocName"].Value.ToString());
                    txtDocument.Text = grdList.Rows[e.RowIndex].Cells["DocName"].Value.ToString() + "-" + grdList.Rows[e.RowIndex].Cells["DocID"].Value.ToString();

                    txtEmployee.Text                = grdList.Rows[e.RowIndex].Cells["EmpName"].Value.ToString();
                    txtFinancialLimit.Text          = grdList.Rows[e.RowIndex].Cells["FinLimit"].Value.ToString();
                    cmbDocumentStatus.SelectedIndex = cmbDocumentStatus.FindStringExact(grdList.Rows[e.RowIndex].Cells["empStatus"].Value.ToString());
                    txtEmployee.Enabled             = false;
                    txtDocument.Enabled             = false;
                    btnEmployee.Enabled             = false;
                    btnDocument.Enabled             = false;
                    disableBottomButtons();
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                financiallimit   flist = new financiallimit();
                FinancialLimitDB fdb   = new FinancialLimitDB();


                try
                {
                    string[] docmts = txtDocument.Text.Trim().Split('-');
                    string[] emply  = txtEmployee.Text.Trim().Split('-');
                    ////////flist.DocumentID = cmbDocument.SelectedItem.ToString().Trim().Substring(0, cmbDocument.SelectedItem.ToString().Trim().IndexOf('-'));
                    flist.DocumentID = docmts[1];
                    ////////flist.DocumentName = cmbDocument.SelectedItem.ToString().Trim().Substring(cmbDocument.SelectedItem.ToString().Trim().IndexOf('-') + 1);
                    flist.DocumentName = docmts[0];
                    //flist.EmployeeName = txtEmployee.Text.Trim().Substring(0, txtEmployee.Text.Trim().IndexOf('-'));
                    //flist.EmployeeID = txtEmployee.Text.Trim().Substring(txtEmployee.Text.Trim().IndexOf('-') + 1);
                    flist.EmployeeName   = emply[0];
                    flist.EmployeeID     = emply[1];
                    flist.FinancialLimit = Convert.ToDouble(txtFinancialLimit.Text);
                }
                catch (Exception ex)
                {
                    flist.DocumentID   = "";
                    flist.DocumentName = "";
                    flist.EmployeeName = "";
                    flist.EmployeeID   = "";
                }

                flist.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 (fdb.updateFinancialLimit(flist, prevflim))
                        {
                            MessageBox.Show("DocEmpMapping Status updated");
                            closeAllPanels();
                            ListEmpFinLimit();
                        }
                        else
                        {
                            MessageBox.Show("Failed to update DocEmpMapping Status");
                        }
                    }
                    else if (btnText.Equals("Save"))
                    {
                        if (fdb.validateFinancialLimit(flist))
                        {
                            if (fdb.insertFinancialLimit(flist))
                            {
                                MessageBox.Show("EMP Financial list data Added");
                                closeAllPanels();
                                ListEmpFinLimit();
                            }
                            else
                            {
                                MessageBox.Show("Failed to Insert DocEmpMapping");
                            }
                        }
                        else
                        {
                            MessageBox.Show("DocEmpMapping Data Validation failed");
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Failed Adding / Editing User Data");
            }
        }