private void LoadData(int InvoiceID) { string strDocNo = ""; string DocType = Session["eDocType"].ToString(); objinvoice.GetDocumentNoByDocID(InvoiceID, DocType, out strDocNo); lbldocumentno.Text = strDocNo; lblVoucherno.Text = Session["eVoucherNumber"].ToString(); lbldocumentdate.Text = Session["eInvoiceDate"].ToString(); lbldocumentstatus.Text = Session["eDocStatus"].ToString(); lblsuppliername.Text = objinvoice.GetSupplierName(InvoiceID, DocType); lblauthstring.Text = objinvoice.GetAuthorisationString(InvoiceID, DocType); lbldepartment.Text = objinvoice.GetDepartment(InvoiceID, DocType); int UserTypeID = objinvoice.GetUserType(Convert.ToInt32(Session["UserID"])); if (UserTypeID < 3) { btndelete.Visible = false; txtcomment.Visible = false; lblComment.Visible = false; lblCreditNoteNo.Visible = false; lbltextCrnNo.Visible = false; } if (DocType == "CRN") { visiblelable = 1; lblassociatedinvoiceno.Text = "Associated Invoice No"; lblassociatedinvoiceno.Visible = true; lblassociatedno.Text = objinvoice.GetAssociatedCreditInvoiceNo(InvoiceID, DocType); lblassociatedno.Visible = true; } if (DocType == "INV") { lblCreditNoteNo.Text = "Associated CreditNote No"; lbltextCrnNo.Text = objinvoice.GetAssociatedCreditInvoiceNo(InvoiceID, DocType); if (lbltextCrnNo.Text.Trim() != "") { visiblelable1 = 1; lblCreditNoteNo.Visible = true; lbltextCrnNo.Visible = true; } } GDlineinfo.DataSource = objinvoice.GetLineInformation(InvoiceID, DocType); GDlineinfo.DataBind(); if (lbldocumentstatus.Text == "Delete/Archive") { btndelete.Visible = false; } }
private void btndelete_Click(object sender, System.EventArgs e) { Invoice.Invoice objinvoice = new Invoice.Invoice(); if (txtComment.Text.Trim() == "") { lblErrorMsg.Text = "Please enter a comment."; return; } else { lblErrorMsg.Text = ""; iApproverStatusID = 7; strComments = txtComment.Text.Trim(); UserTypeID = objinvoice.GetUserType(System.Convert.ToInt32(Session["UserID"].ToString())); if (DocType == "INV") { StatusUpdate = objinvoice.UpdateInvStatusToDelete(System.Convert.ToInt32(Session["eInvoiceID"].ToString())); if (StatusUpdate == 1) { objinvoice.UpdateInvoiceStatusLogApproverWise(System.Convert.ToInt32(Session["eInvoiceID"]), System.Convert.ToInt32(Session["UserID"]), UserTypeID, iApproverStatusID, strComments, ""); lblErrorMsg.Text = "Invoice deleted successfully"; Response.Write("<script>alert('Invoice Deleted Successfully');</script>"); Response.Write("<script>window.opener.Form1.btnSearch.click();</script>"); Response.Write("<script>self.close();</script>"); } else { lblErrorMsg.Text = "Invoice cannot be deleted"; } } else if (DocType == "CRN") { StatusUpdate = objinvoice.UpdateCrnStatusToDelete(System.Convert.ToInt32(Session["eInvoiceID"].ToString())); if (StatusUpdate == 1) { objinvoice.UpdateInvoiceStatusLogApproverWise_CN(System.Convert.ToInt32(Session["eInvoiceID"]), System.Convert.ToInt32(Session["UserID"]), UserTypeID, iApproverStatusID, strComments); lblErrorMsg.Text = "CreditNote deleted successfully"; Response.Write("<script>alert('Credit Note Deleted Successfully');</script>"); Response.Write("<script>window.opener.Form1.btnSearch.click();</script>"); Response.Write("<script>self.close();</script>"); } else { lblErrorMsg.Text = "CreditNote cannot be deleted"; } } else { StatusUpdate = objinvoice.UpdateDebitNoteStatusToDelete(System.Convert.ToInt32(Session["eInvoiceID"].ToString())); if (StatusUpdate == 1) { objinvoice.UpdateInvoiceStatusLogApproverWise_DN(System.Convert.ToInt32(Session["eInvoiceID"]), System.Convert.ToInt32(Session["UserID"]), UserTypeID, iApproverStatusID, strComments); lblErrorMsg.Text = "CreditNote deleted successfully"; Response.Write("<script> alert('Credit Note Deleted Successfully'); </script>"); Response.Write("<script>window.opener.Form1.btnSearch.click();</script>"); Response.Write("<script> self.close(); </script>"); } else { lblErrorMsg.Text = "CreditNote cannot be deleted"; } } } }