private void DocumentUnlock_Load(object sender, EventArgs e) { //////this.FormBorderStyle = FormBorderStyle.None; Region = System.Drawing.Region.FromHrgn(Utilities.CreateRoundRectRgn(0, 0, Width, Height, 20, 20)); initVariables(); this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Width -= 100; this.Height -= 100; dict = new Dictionary <string, string>(); String a = this.Size.ToString(); grdList.ColumnHeadersDefaultCellStyle.BackColor = Color.LightBlue; grdList.EnableHeadersVisualStyles = false; unlockCommiteelist = DocumentUnlockDB.getUnlockCommiteeListString(); CreateButtons(); }
private void CreateButtons() { try { DocumentUnlockDB dbrecord = new DocumentUnlockDB(); List <DocUnlock> docs = dbrecord.getDocUnlockValues(); int intex = 0; foreach (DocUnlock val in docs) { dict.Add(val.DocumentID, val.TableName); addButton(val.DocumentID, val.DocumentName, intex); intex++; } } catch (Exception ex) { MessageBox.Show("Error in request processing"); } }
private void ListDocValues(string tablename) { try { grdList.Rows.Clear(); DocumentUnlockDB dbrecord = new DocumentUnlockDB(); List <DocUnlock> docValues = dbrecord.getDocumentInfo(tablename, selectedDocID); foreach (DocUnlock val in docValues) { //get the employee code of user approved the document ERPUserDB erpuserdb = new ERPUserDB(); string ecode = erpuserdb.getEmpCode(val.ApprovedUser.Trim()); string edet = Login.userLoggedInName + Main.delimiter1 + Login.userLoggedIn + Main.delimiter2; string approverList = DocEmpMappingDB.getApproverList(selectedDocID, ecode); string tstr = Login.userLoggedInName + Main.delimiter1 + Login.userLoggedIn + Main.delimiter1 + Main.delimiter2; ////users who can unlock a document ////user should be found in forwarder list and logged in user is the approver and ////user shall be a member of the approverlist of the document if (!(val.ApprovedUser == Login.userLoggedIn || val.forwarderlist.Contains(tstr)) && approverList.Contains(edet)) { grdList.Rows.Add(val.TemporaryNo, val.TemporaryDate, val.ApprovedUser, val.TableName, val.forwarderlist); } else if (unlockCommiteelist != null && unlockCommiteelist.Contains(";" + Login.userLoggedIn + ";")) { grdList.Rows.Add(val.TemporaryNo, val.TemporaryDate, val.ApprovedUser, val.TableName, val.forwarderlist); } ////if (!val.ApprovedUser.Equals(Login.empLoggedIn) || !val.forwarderlist.Contains(Login.empLoggedIn)) ////{ //// grdList.Rows.Add(val.TemporaryNo, val.TemporaryDate, val.ApprovedUser, val.TableName, val.forwarderlist); ////} } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } pnlDocUnlockList.Visible = true; }
private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } DocumentUnlockDB dudb = new DocumentUnlockDB(); string columnName = grdList.Columns[e.ColumnIndex].Name; if (columnName.Equals("Unlock")) { prevdc.TemporaryNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["TempNo"].Value); prevdc.TemporaryDate = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["TempDate"].Value); prevdc.TableName = grdList.Rows[e.RowIndex].Cells["TableName"].Value.ToString(); string frwdList = grdList.Rows[e.RowIndex].Cells["ForwarderList"].Value.ToString(); if (frwdList == null) { MessageBox.Show("Failed to retrive Forwardlist"); return; } DialogResult dialog = MessageBox.Show("Are you sure to Unlock the document ?\n\nDocument Type\t: " + selectedDocName + "\nTemporary No\t: " + prevdc.TemporaryNo + "\nTemprary Date\t: " + prevdc.TemporaryDate.ToString("yyyy-MM-dd") + "\n" , "Confirmation", MessageBoxButtons.YesNo); if (dialog == DialogResult.No) { return; } string[] strArr = frwdList.Split(Main.delimiter2); int DocStat = strArr.Count(); ////if document is MRN, do not reverse if any issue from the MRN. ////if Invoice out, reverse all quantity before reversing the document if (selectedDocID == "MRN") { if (MRNHeaderDB.checkForIssuesFromMRN(prevdc.TemporaryNo, prevdc.TemporaryDate)) { //no issues (purchase return and Invoice) from MRN MessageBox.Show("Stock has been issued from MRN. Reversal request denied"); return; } else { if (dudb.updateDocForUnlockingMRN(prevdc, DocStat)) { MessageBox.Show("Document Unlocked with Updating Stock sucessfully."); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } } else if (selectedDocID == "POPRODUCTINWARD" || selectedDocID == "POSERVICEINWARD") { string result = POPIHeaderDB.checkForInvoiceIssuesForPOPI(prevdc.TemporaryNo, prevdc.TemporaryDate, selectedDocID); if (result == "error" || result.Length != 0) { if (result == "error") { return; } //Inivoice Prepared For this PO string InvPrepared = ""; string[] invArr = result.Split(Main.delimiter1); foreach (string str in invArr) { if (str.Length != 0) { string[] invNoDate = str.Split(';'); InvPrepared = InvPrepared + "\nTemporary No: " + invNoDate[0] + " Temporary Date: " + Convert.ToDateTime(invNoDate[1]).ToString("yyyy-MM-dd"); } } MessageBox.Show("Inivoice Prepared For this PO. Reversal request denied.\n" + InvPrepared, "Invoice Prepared Details"); return; } else { if (dudb.updateDocForUnlocking(prevdc, DocStat, selectedDocID)) { MessageBox.Show("PO Document Unlocked"); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Failed to unlock Document"); return; } } } else if (selectedDocID == "PRODUCTINVOICEOUT" || selectedDocID == "PRODUCTEXPORTINVOICEOUT") { //return; if (dudb.updateDocForUnlockingInvoiceOUT(prevdc, DocStat, selectedDocID)) { MessageBox.Show("Document Unlocked with Updating Stock sucessfully."); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } else if (selectedDocID == "GTN") { if (GTNDB.checkForIssuesOfGTNInStock(prevdc.TemporaryNo, prevdc.TemporaryDate)) { //no issues (purchase return and Invoice) from MRN MessageBox.Show("Stock has been issued from GTN. Reversal request denied"); return; } else { if (dudb.updateDocForUnlockingGTN(prevdc, DocStat)) { MessageBox.Show("Document Unlocked with Updating Stock sucessfully."); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } } else if (selectedDocID == "POINVOICEIN" || selectedDocID == "WOINVOICEIN" || selectedDocID == "POGENERALINVOICEIN") { //return; if (dudb.updateDocForUnlockingInvoiceIN(prevdc, DocStat, selectedDocID)) { MessageBox.Show("Document Unlocked"); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } else if (dudb.updateDocForUnlocking(prevdc, DocStat, selectedDocID)) { MessageBox.Show("Document Unlocked"); grdList.Rows.RemoveAt(e.RowIndex); } else { MessageBox.Show("Failed to unlock Document"); } } } catch (Exception ex) { MessageBox.Show("Exception : Failed to unlock Document"); } }