private void showInAccountCodeDataGridView() { try { frmPopup = new Form(); frmPopup.StartPosition = FormStartPosition.CenterScreen; frmPopup.BackColor = Color.CadetBlue; frmPopup.MaximizeBox = false; frmPopup.MinimizeBox = false; frmPopup.ControlBox = false; frmPopup.FormBorderStyle = FormBorderStyle.FixedSingle; frmPopup.Size = new Size(550, 370); Label lblSearch = new Label(); lblSearch.Location = new System.Drawing.Point(200, 5); lblSearch.AutoSize = true; lblSearch.Text = "Search by Name"; lblSearch.Font = new System.Drawing.Font("Microsoft Sans Serif", 9, FontStyle.Bold); lblSearch.ForeColor = Color.Black; frmPopup.Controls.Add(lblSearch); txtSearch = new TextBox(); txtSearch.Size = new Size(220, 18); txtSearch.Location = new System.Drawing.Point(320, 3); txtSearch.Font = new System.Drawing.Font("Microsoft Sans Serif", 9, FontStyle.Regular); txtSearch.ForeColor = Color.Black; txtSearch.TextChanged += new System.EventHandler(this.txtSearch_TextChangedInAccINCodeGridList); txtSearch.TabIndex = 0; txtSearch.Focus(); frmPopup.Controls.Add(txtSearch); AccCodeGrd = AccountCodeDB.getGridViewForAccountCode(); AccCodeGrd.Bounds = new Rectangle(new Point(0, 27), new Size(550, 300)); frmPopup.Controls.Add(AccCodeGrd); AccCodeGrd.Columns["AccountName"].Width = 380; Button lvOK = new Button(); lvOK.BackColor = Color.Tan; lvOK.Text = "OK"; lvOK.Location = new System.Drawing.Point(20, 335); lvOK.Click += new System.EventHandler(this.grdAccINCOdeOK_Click1); frmPopup.Controls.Add(lvOK); Button lvCancel = new Button(); lvCancel.Text = "CANCEL"; lvCancel.BackColor = Color.Tan; lvCancel.Location = new System.Drawing.Point(110, 335); lvCancel.Click += new System.EventHandler(this.grdAccINCancel_Click1); frmPopup.Controls.Add(lvCancel); frmPopup.ShowDialog(); } catch (Exception ex) { } }
private void lvForwardOK_Click(object sender, EventArgs e) { try { { int kount = 0; string approverUID = ""; string approverUName = ""; foreach (ListViewItem itemRow in lvApprover.Items) { if (itemRow.Checked) { approverUID = itemRow.SubItems[2].Text; approverUName = itemRow.SubItems[1].Text; kount++; } } if (kount == 0) { MessageBox.Show("Select one approver"); return; } if (kount > 1) { MessageBox.Show("Select only one approver"); return; } else { DialogResult dialog = MessageBox.Show("Are you sure to forward the document ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { //do forward activities AccountCodeDB accDB = new AccountCodeDB(); prevaccode.ForwardUser = approverUID; string s = prevaccode.ForwarderList; prevaccode.ForwarderList = prevaccode.ForwarderList + approverUName + Main.delimiter1 + approverUID + Main.delimiter1 + Main.delimiter2; if (accDB.forwardAccountCode(prevaccode)) { MessageBox.Show("Account Code Document Forwarded"); closeAllPanels(); listOption = 1; ListAccountDetail(listOption); setButtonVisibility("btnEditPanel"); //activites are same for cance, forward,approce and reverse frmPopup.Close(); frmPopup.Dispose(); } } } } } catch (Exception) { } }
private void btnSelectAccountCode_Click(object sender, EventArgs e) { try { //pnllv = new Panel(); lv = new ListView(); frmPopup = new Form(); frmPopup.StartPosition = FormStartPosition.CenterScreen; frmPopup.BackColor = Color.CadetBlue; //frmPopup.ShowIcon = false; frmPopup.MaximizeBox = false; frmPopup.MinimizeBox = false; frmPopup.ControlBox = false; frmPopup.FormBorderStyle = FormBorderStyle.FixedSingle; frmPopup.Size = new Size(450, 300); lv = AccountCodeDB.getAccountCodeListView(); lv.ColumnClick += new ColumnClickEventHandler(LvColumnClick); lv.Bounds = new Rectangle(new Point(0, 0), new Size(450, 250)); frmPopup.Controls.Add(lv); Button lvOK = new Button(); lvOK.BackColor = Color.Tan; lvOK.Text = "OK"; lvOK.Location = new Point(44, 270); lvOK.Click += new System.EventHandler(this.lvOK_Clicked); frmPopup.Controls.Add(lvOK); Button lvCancel = new Button(); lvCancel.BackColor = Color.Tan; lvCancel.Text = "CANCEL"; lvCancel.Location = new Point(141, 270); lvCancel.Click += new System.EventHandler(this.lvCancel_Clicked); frmPopup.Controls.Add(lvCancel); Label lblSearch = new Label(); lblSearch.Text = "Find"; lblSearch.Location = new Point(250, 272); lblSearch.Size = new Size(45, 15); frmPopup.Controls.Add(lblSearch); txtSearch = new TextBox(); txtSearch.Location = new Point(300, 270); txtSearch.TextChanged += new EventHandler(txtSearch_TextChanged); frmPopup.Controls.Add(txtSearch); frmPopup.ShowDialog(); //pnllv.Visible = true; } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } }
private void brnSelectAccCode_Click(object sender, EventArgs e) { grdList.Rows.Clear(); removeControlsFromlvPanel(); pnlList.Controls.Remove(pnllv); ////btnSelectAccCode.Enabled = false; pnllv = new Panel(); pnllv.BorderStyle = BorderStyle.FixedSingle; pnllv.Bounds = new Rectangle(new Point(311, 46), new Size(566, 281)); lv = AccountCodeDB.getAccountCodeListView(); lv.ColumnClick += new ColumnClickEventHandler(LvColumnClick); //this.lv.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listView1_ItemChecked1); lv.Bounds = new Rectangle(new Point(35, 13), new Size(500, 225)); pnllv.Controls.Add(lv); Button lvOK = new Button(); lvOK.Text = "OK"; lvOK.Location = new Point(71, 245); lvOK.Click += new System.EventHandler(this.lvOK_Click2); pnllv.Controls.Add(lvOK); Button lvCancel = new Button(); lvCancel.Text = "Cancel"; lvCancel.Location = new Point(187, 245); lvCancel.Click += new System.EventHandler(this.lvCancel_Click2); pnllv.Controls.Add(lvCancel); Label lblSearch = new Label(); lblSearch.Text = "Find"; lblSearch.Location = new Point(364, 249); lblSearch.Size = new Size(37, 15); pnllv.Controls.Add(lblSearch); txtSearch = new TextBox(); txtSearch.Location = new Point(414, 246); txtSearch.TextChanged += new EventHandler(txtSearch_TextChanged); pnllv.Controls.Add(txtSearch); pnlList.Controls.Add(pnllv); pnllv.BringToFront(); pnllv.Visible = true; txtSearch.Focus(); }
private static Hashtable AccountIdTable() { Hashtable ht = new Hashtable(); //accountcode acc = new accountcode(); AccountCodeDB accDB = new AccountCodeDB(); List <accountcode> AccList = accDB.getAccoutCodesList(); foreach (accountcode accode in AccList) { try { string id = accode.AccountCode; if (id.Length == 10) { string key = id.Substring(0, 6); string value = id.Substring(6, 4); if (ht.ContainsKey(key)) { ht[key] = value; } else { ht.Add(key, value); } } else { string key = id.Substring(0, 10); string value = id.Substring(10, 4); if (ht.ContainsKey(key)) { ht[key] = value; } else { ht.Add(key, value); } } } catch (Exception ex) { } } return(ht); }
private void btnApprove_Click_1(object sender, EventArgs e) { try { AccountCodeDB accDB = new AccountCodeDB(); DialogResult dialog = MessageBox.Show("Are you sure to Approve the document ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { if (accDB.ApproveAccountCode(prevaccode, id)) { MessageBox.Show("Account Code Approved"); closeAllPanels(); listOption = 1; ListAccountDetail(listOption); setButtonVisibility("btnEditPanel"); } } } catch (Exception) { } }
private void btnReverse_Click_1(object sender, EventArgs e) { try { DialogResult dialog = MessageBox.Show("Are you sure to Reverse the document ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { string reverseStr = getReverseString(prevaccode.ForwarderList); //do forward activities //prevpopi.CommentStatus = DocCommenterDB.removeUnapprovedCommentStatus(prevpopi.CommentStatus); AccountCodeDB accDB = new AccountCodeDB(); if (reverseStr.Trim().Length > 0) { int ind = reverseStr.IndexOf("!@#"); prevaccode.ForwarderList = reverseStr.Substring(0, ind); prevaccode.ForwardUser = reverseStr.Substring(ind + 3); prevaccode.documentStatus = prevaccode.documentStatus - 1; } else { prevaccode.ForwarderList = ""; prevaccode.ForwardUser = ""; prevaccode.documentStatus = 1; } if (accDB.reverseAccountCode(prevaccode)) { MessageBox.Show("Account Code Reversed"); closeAllPanels(); listOption = 1; ListAccountDetail(listOption); setButtonVisibility("btnEditPanel"); //activites are same for cance, forward,approce and reverse } } } catch (Exception ex) { } }
private void ListAccountDetail(int option) { try { // pnlActionButtons.Visible = true; lblActionHeader.Visible = true; grdList.Rows.Clear(); txtSearch.Text = ""; forwarderList = demDB.getForwarders(docID, Login.empLoggedIn); approverList = demDB.getApprovers(docID, Login.empLoggedIn); if (option == 1) { lblActionHeader.Text = "List of Action Pending Documents"; } else if (option == 2) { lblActionHeader.Text = "List of In-Process Documents"; } else if (option == 3 || option == 6) { lblActionHeader.Text = "List of Approved Documents"; } AccountCodeDB ACDB = new AccountCodeDB(); List <accountcode> ACItems = ACDB.getFilteredAccountDetails(userString, option); foreach (accountcode acc in ACItems) { if (option == 1) { if (acc.documentStatus == 99) { continue; } } else { } grdList.Rows.Add(); grdList.Rows[grdList.RowCount - 1].Cells["AccCode"].Value = acc.AccountCode; grdList.Rows[grdList.RowCount - 1].Cells["AccName"].Value = acc.Name; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel1"].Value = acc.GroupLevel1; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel1Desc"].Value = acc.GroupLevel1Description; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel2"].Value = acc.GroupLevel2; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel2Desc"].Value = acc.GroupLevel2eDescription; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel3"].Value = acc.GroupLevel3; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel3Desc"].Value = acc.GroupLevel3Description; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel4"].Value = acc.GroupLevel4; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel4Desc"].Value = acc.GroupLevel4Description; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel5"].Value = acc.GroupLevel5; grdList.Rows[grdList.RowCount - 1].Cells["GroupLevel5Desc"].Value = acc.GroupLevel5Description; grdList.Rows[grdList.RowCount - 1].Cells["Status"].Value = acc.status; grdList.Rows[grdList.RowCount - 1].Cells["DocumentStatus"].Value = acc.documentStatus; grdList.Rows[grdList.RowCount - 1].Cells["CreateUser"].Value = acc.CreateUser; grdList.Rows[grdList.RowCount - 1].Cells["Creator"].Value = acc.CreateUserName; grdList.Rows[grdList.RowCount - 1].Cells["Forwarder"].Value = acc.ForwardUserName; grdList.Rows[grdList.RowCount - 1].Cells["Approver"].Value = acc.ApproveUserName; grdList.Rows[grdList.RowCount - 1].Cells["ForwarderLists"].Value = acc.ForwarderList; } } catch (Exception ex) { MessageBox.Show("Error in Account Code listing"); } setButtonVisibility("init"); pnlList.Visible = true; grdList.Columns["Creator"].Visible = true; grdList.Columns["Forwarder"].Visible = true; grdList.Columns["Approver"].Visible = true; if (listOption == 3 || listOption == 6) { grdList.Columns["TempEdit"].Visible = true; } else { grdList.Columns["TempEdit"].Visible = false; } }
private void btnSave_Click_1(object sender, EventArgs e) { Boolean status = true; try { accountcode acc = new accountcode(); AccountCodeDB accDB = new AccountCodeDB(); //cvi.ConversionDate = dtDate.Value; try { acc.GroupLevel1 = cmbGroup1Select.SelectedItem.ToString().Trim().Substring(0, cmbGroup1Select.SelectedItem.ToString().Trim().IndexOf('-')); acc.GroupLevel1Description = cmbGroup1Select.SelectedItem.ToString().Trim().Substring(cmbGroup1Select.SelectedItem.ToString().Trim().IndexOf('-') + 1); } catch (Exception) { acc.GroupLevel1 = ""; acc.GroupLevel1Description = ""; } try { acc.GroupLevel2 = cmbGroup2Select.SelectedItem.ToString().Trim().Substring(0, cmbGroup2Select.SelectedItem.ToString().Trim().IndexOf('-')); acc.GroupLevel2eDescription = cmbGroup2Select.SelectedItem.ToString().Trim().Substring(cmbGroup2Select.SelectedItem.ToString().Trim().IndexOf('-') + 1); } catch (Exception) { acc.GroupLevel2 = ""; acc.GroupLevel2eDescription = ""; } try { acc.GroupLevel3 = cmbGroup3Select.SelectedItem.ToString().Trim().Substring(0, cmbGroup3Select.SelectedItem.ToString().Trim().IndexOf('-')); acc.GroupLevel3Description = cmbGroup3Select.SelectedItem.ToString().Trim().Substring(cmbGroup3Select.SelectedItem.ToString().Trim().IndexOf('-') + 1); } catch (Exception) { acc.GroupLevel3 = ""; acc.GroupLevel3Description = ""; } try { acc.GroupLevel4 = cmbGroup4Select.SelectedItem.ToString().Trim().Substring(0, cmbGroup4Select.SelectedItem.ToString().Trim().IndexOf('-')); acc.GroupLevel4Description = cmbGroup4Select.SelectedItem.ToString().Trim().Substring(cmbGroup4Select.SelectedItem.ToString().Trim().IndexOf('-') + 1); } catch (Exception) { acc.GroupLevel4 = ""; acc.GroupLevel4Description = ""; } try { acc.GroupLevel5 = cmbGroup5Select.SelectedItem.ToString().Trim().Substring(0, cmbGroup5Select.SelectedItem.ToString().Trim().IndexOf('-')); acc.GroupLevel5Description = cmbGroup5Select.SelectedItem.ToString().Trim().Substring(cmbGroup5Select.SelectedItem.ToString().Trim().IndexOf('-') + 1); } catch (Exception ex) { acc.GroupLevel5 = ""; acc.GroupLevel5Description = ""; } acc.Name = txtName.Text.Replace("'", "''"); acc.ForwarderList = prevaccode.ForwarderList; System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btn.Text; if (accDB.validateAccountCodeDetail(acc)) { if (btnText.Equals("Update")) { if (isTempEditCLick) { acc.status = getstatuscode(cmbStatus.SelectedItem.ToString().Trim()); } else { acc.status = 0; } if (accDB.updateAccountCodeDetails(acc, prevaccode)) { MessageBox.Show("Account Code updated"); closeAllPanels(); listOption = 1; ListAccountDetail(listOption); } else { status = false; MessageBox.Show("Failed to Update Account Code"); } } else if (btnText.Equals("Save")) { acc.documentStatus = 1;//created if (accDB.insertAccountCodeDetails(acc)) { MessageBox.Show("Account Code Added"); closeAllPanels(); listOption = 1; ListAccountDetail(listOption); } else { status = false; MessageBox.Show("Failed to Insert Account Code"); } } } else { MessageBox.Show("Account Code Data Validation failed"); return; } } catch (Exception ex) { MessageBox.Show("Failed Adding / Editing Account Code"); return; } if (status) { setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save } }