protected void lkcImportConsolidated_Click(object sender, EventArgs e) { try { clsMessageAttribute clsMessage = new clsMessageAttribute(); clsMessage = clsInvoice.ImportAllInvoices(Common.LoggedInUserID()); SendHTMLMail(clsMessage, clsMessage.MailString, String.Join(";", ""));//clsMessage.MailsTo.ToArray() BindViewInvoice(Convert.ToByte(uc_invoiceMonth.GetValue)); this.Master.SuccessMessage = clsMessage.CustomMessage; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelSucessMessage", "$('#viewInvoiceModelSucessMessage').modal();", true); } catch (Exception ex) { cls_ErrorLog ob = new cls_ErrorLog(); cls_ErrorLog.LogError(ex, Common.LoggedInUserID()); } }
public void SendHTMLMail(clsMessageAttribute mailData, string mailString, string sellerEmail) { try { cls_Message message = new cls_Message(); EmailService email = new EmailService(); IdentityMessage msg = new IdentityMessage(); Dictionary <string, string> replaceItem = new Dictionary <string, string>(); replaceItem.Add("@User", mailData.UserName); replaceItem.Add("@InvoiceData", mailString); string mailBody = message.GetMessage(EnumConstants.Message.FileGSTR2, replaceItem); msg.Body = mailBody; //"hi body....."; msg.Destination = Common.UserProfile.Email; //sellerEmail; msg.Subject = "GSTR-2 Filed"; email.Send(msg); } catch (Exception ex) { cls_ErrorLog ob = new cls_ErrorLog(); cls_ErrorLog.LogError(ex, Common.LoggedInUserID()); } }
protected void lkvGSTR2_Click(object sender, EventArgs e) { try { int count = 0; var loggedinUserId = Common.LoggedInUserID(); if (loggedinUserId != null) { DateTime firstdate = DateTime.Now.FirstDayOfMonth(); DateTime lastDate = DateTime.Now.LastDayOfMonth(); var filedItem = unitOfWork.InvoiceAuditTrailRepositry.Filter(f => f.GST_TRN_INVOICE.ReceiverUserID == loggedinUserId && f.AuditTrailStatus == (byte)EnumConstants.InvoiceAuditTrailSatus.FileGSTR2 && f.GST_TRN_INVOICE.Status == true && (f.CreatedDate >= firstdate && f.CreatedDate <= lastDate)).Select(s => s.InvoiceID).ToList(); //var modifiedInvoice = unitOfWork.InvoiceAuditTrailRepositry.Filter(f => f.GST_TRN_INVOICE.ReceiverUserID == loggedinUserId && f.AuditTrailStatus == (byte)EnumConstants.InvoiceAuditTrailSatus.Import2A && f.GST_TRN_INVOICE.InvoiceStatus != (byte)EnumConstants.InvoiceStatus.Fresh && !filedItem.Contains(f.InvoiceID) && f.GST_TRN_INVOICE.Status == true && (f.CreatedDate >= firstdate && f.CreatedDate <= lastDate)).ToList(); var invoices = unitOfWork.InvoiceAuditTrailRepositry.Filter(f => f.GST_TRN_INVOICE.ReceiverUserID == loggedinUserId && (f.AuditTrailStatus == (byte)EnumConstants.InvoiceAuditTrailSatus.Import2A || (f.AuditTrailStatus == (byte)EnumConstants.InvoiceAuditTrailSatus.Upload && (f.GST_TRN_INVOICE.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.Import || f.GST_TRN_INVOICE.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.ReverseCharges))) && (f.ReceiverInvoiceAction != (byte)EnumConstants.InvoiceActionAuditTrail.NA || f.ReceiverInvoiceAction != null) && f.GST_TRN_INVOICE.InvoiceStatus == (byte)EnumConstants.InvoiceStatus.Fresh && !filedItem.Contains(f.InvoiceID) && f.GST_TRN_INVOICE.Status == true && (f.CreatedDate >= firstdate && f.CreatedDate <= lastDate)).ToList(); //again filter due to non working code:TODO optimise var filterInvoice = invoices.Where(w => w.ReceiverInvoiceAction != null).ToList().Where(f => f.ReceiverInvoiceAction != (byte)EnumConstants.InvoiceActionAuditTrail.NA).ToList(); List <clsMessageAttribute> invAttributes = new List <clsMessageAttribute>(); List <string> mailsToList = new List <string>(); List <string> invID = new List <string>(); foreach (GST_TRN_INVOICE_AUDIT_TRAIL inv in filterInvoice) { clsMessageAttribute attribute = new clsMessageAttribute(); //For both line for Email process string invoiceNo = inv.GST_TRN_INVOICE.InvoiceNo; // string id = inv.InvoiceID.ToString(); audittrail.InvoiceID = inv.InvoiceID; audittrail.AuditTrailStatus = Convert.ToByte(EnumConstants.InvoiceAuditTrailSatus.FileGSTR2); audittrail.UserIP = Common.IP; audittrail.InvoiceAction = inv.InvoiceAction; audittrail.ReceiverInvoiceAction = inv.ReceiverInvoiceAction; audittrail.ReceiverInvoiceActionDate = inv.ReceiverInvoiceActionDate; audittrail.CreatedDate = DateTime.Now; audittrail.CreatedBy = loggedinUserId; unitOfWork.InvoiceAuditTrailRepositry.Create(audittrail); unitOfWork.Save(); count = count + 1; if (!mailsToList.Contains(inv.GST_TRN_INVOICE.AspNetUser.Email)) { mailsToList.Add(inv.GST_TRN_INVOICE.AspNetUser.Email); } attribute.UserName = inv.GST_TRN_INVOICE.AspNetUser.OrganizationName; //attribute.MailsTo.Add(); attribute.InvoiceNo = invoiceNo; attribute.InvoiceDate = DateTimeAgo.GetFormatDate(inv.GST_TRN_INVOICE.InvoiceDate); attribute.InvoiceTotalAmount = inv.GST_TRN_INVOICE.GST_TRN_INVOICE_DATA.Sum(s => s.TotalAmountWithTax).ToString(); invAttributes.Add(attribute); invID.Add(id); } if (count > 0) { string mailString = string.Empty; string sellerMail = string.Empty; clsMessageAttribute mailData = new clsMessageAttribute(); foreach (clsMessageAttribute iId in invAttributes) { mailString += "<tr><td align='left' style='table-layout:auto'>" + iId.InvoiceNo.ToString() + "</td>"; mailString += "<td align='middle' style='table-layout:auto'>" + iId.InvoiceDate.ToString() + "</td>"; mailString += "<td align='right' style='table-layout:auto'>" + iId.InvoiceTotalAmount.ToString() + "</td></tr>"; mailData.UserName = iId.UserName; } this.Master.SuccessMessage = "Data Filed Successfully."; SendHTMLMail(mailData, mailString, String.Join(";", mailsToList.ToArray())); //uc_sucess.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelSucessMessage", "$('#viewInvoiceModelSucessMessage').modal();", true); } else { this.Master.WarningMessage = "There is no Data to File."; //uc_sucess.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelWarningMessage", "$('#viewInvoiceModelWarningMessage').modal();", true); } } //var month = DateTime.Now.Month-1; //BindAllGSTN2List(month); BindAllGSTN2List((DateTime.Now.Month)); } catch (Exception ex) { cls_ErrorLog ob = new cls_ErrorLog(); cls_ErrorLog.LogError(ex, Common.LoggedInUserID()); this.Master.ErrorMessage = ex.Message; //uc_sucess.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelErrorMessage", "$('#viewInvoiceModelErrorMessage').modal();", true); } }
protected void lkbImport_Click(object sender, EventArgs e) { try { UnitOfWork unitOfWork = new UnitOfWork(); var loggedinUserId = Common.LoggedInUserID(); int count = 0; //if (loggedinUserId != null) //{ // DateTime firstdate = DateTime.Now.FirstDayOfMonth(); // DateTime lastDate = DateTime.Now.LastDayOfMonth(); // byte FileGSTR2 = Convert.ToByte(EnumConstants.InvoiceAuditTrailSatus.FileGSTR2); // byte Import1A = Convert.ToByte(EnumConstants.InvoiceAuditTrailSatus.Import1A); // var filedItem = unitOfWork.InvoiceAuditTrailRepositry.Filter(f => f.GST_TRN_INVOICE.SellerUserID == loggedinUserId && f.AuditTrailStatus == FileGSTR2 && f.GST_TRN_INVOICE.Status == true && (f.CreatedDate >= firstdate && f.CreatedDate <= lastDate)).Select(s => s.InvoiceID).ToList(); // var invoices = unitOfWork.InvoiceAuditTrailRepositry.Filter(f => f.GST_TRN_INVOICE.SellerUserID == loggedinUserId && f.AuditTrailStatus == Import1A && !filedItem.Contains(f.InvoiceID) && f.GST_TRN_INVOICE.Status == true && (f.CreatedDate >= firstdate && f.CreatedDate <= lastDate)).ToList(); List <clsMessageAttribute> invAttributes = new List <clsMessageAttribute>(); List <string> mailsToList = new List <string>(); foreach (ListViewDataItem item in lvInvoices.Items) { Int64 invoiceID = Convert.ToInt64(lvInvoices.DataKeys[item.DisplayIndex].Values["InvoiceID"].ToString()); CheckBox chk = (CheckBox)item.FindControl("chkImport"); if (chk.Checked) { clsMessageAttribute attribute = new clsMessageAttribute(); var invoiceDetail = unitOfWork.InvoiceRepository.Find(f => f.InvoiceID == invoiceID); string invoiceNo = invoiceDetail.InvoiceNo; Int64 invoiceAction = Convert.ToInt64(lvInvoices.DataKeys[item.DisplayIndex].Values["InvoiceAction"].ToString()); Int64 auditTrailID = Convert.ToInt64(lvInvoices.DataKeys[item.DisplayIndex].Values["AuditTrailID"].ToString()); var getfile2Item = unitOfWork.InvoiceAuditTrailRepositry.Find(f => f.AuditTrailID == auditTrailID); audittrail.InvoiceID = Convert.ToInt64(invoiceID);// item.InvoiceID; audittrail.AuditTrailStatus = Convert.ToByte(EnumConstants.InvoiceAuditTrailSatus.Import1A); audittrail.UserIP = Common.IP; audittrail.CreatedDate = DateTime.Now; audittrail.InvoiceAction = getfile2Item.InvoiceAction;// Convert.ToByte(invoiceAction); audittrail.CreatedBy = loggedinUserId; unitOfWork.InvoiceAuditTrailRepositry.Create(audittrail); unitOfWork.Save(); count = count + 1; if (!mailsToList.Contains(invoiceDetail.AspNetUser.Email)) { mailsToList.Add(invoiceDetail.AspNetUser.Email); } attribute.UserName = invoiceDetail.AspNetUser.OrganizationName; //attribute.MailsTo.Add(); attribute.InvoiceNo = invoiceNo; attribute.InvoiceDate = DateTimeAgo.GetFormatDate(invoiceDetail.InvoiceDate); attribute.InvoiceTotalAmount = invoiceDetail.GST_TRN_INVOICE_DATA.Sum(s => s.TotalAmountWithTax).ToString(); invAttributes.Add(attribute); } } if (count > 0) { string mailString = string.Empty; string sellerMail = string.Empty; clsMessageAttribute mailData = new clsMessageAttribute(); foreach (clsMessageAttribute iId in invAttributes) { mailString += "<tr><td align='left' style='table-layout:auto'>" + iId.InvoiceNo.ToString() + "</td>"; mailString += "<td align='middle' style='table-layout:auto'>" + iId.InvoiceDate.ToString() + "</td>"; mailString += "<td align='right' style='table-layout:auto'>" + iId.InvoiceTotalAmount.ToString() + "</td></tr>"; mailData.UserName = iId.UserName; } this.Master.SuccessMessage = "Data imported successfully."; SendHTMLMail(mailData, mailString, String.Join(";", mailsToList.ToArray())); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelSucessMessage", "$('#viewInvoiceModelSucessMessage').modal();", true); BindViewInvoice(Convert.ToByte(uc_invoiceMonth.GetValue)); } else { this.Master.WarningMessage = "There are no invoices."; //uc_sucess.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelWarningMessage", "$('#viewInvoiceModelWarningMessage').modal();", true); } BindViewInvoice(Convert.ToByte(uc_invoiceMonth.GetValue)); } catch (Exception ex) { cls_ErrorLog ob = new cls_ErrorLog(); cls_ErrorLog.LogError(ex, Common.LoggedInUserID()); this.Master.ErrorMessage = ex.Message; //uc_sucess.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelErrorMessage", "$('#viewInvoiceModelErrorMessage').modal();", true); } }
protected void lkb_Click(object sender, EventArgs e) { try { LinkButton lkb = (LinkButton)sender; int count = 0; List <clsMessageAttribute> invAttributes = new List <clsMessageAttribute>(); List <string> mailsToList = new List <string>(); List <string> invID = new List <string>(); foreach (ListViewDataItem item in lvRegularInvoice.Items) { string auditTrailID = lvRegularInvoice.DataKeys[item.DisplayIndex].Values["AuditTrailID"].ToString(); //string invoiceID = lvInvoices.DataKeys[item.DisplayIndex].Values["InvoiceID"].ToString(); Int64 invoiceID = Convert.ToInt64(lvRegularInvoice.DataKeys[item.DisplayIndex].Values["InvoiceID"].ToString()); CheckBox chk = (CheckBox)item.FindControl("chkSelect"); if (chk.Checked) { clsMessageAttribute attribute = new clsMessageAttribute(); var invoiceDetail = unitOfWork.InvoiceRepository.Find(f => f.InvoiceID == invoiceID); Int64 id = Convert.ToInt64(auditTrailID); // int invoiceid = Convert.ToInt32(audittrail.InvoiceID); var itemAudit = unitOfWork.InvoiceAuditTrailRepositry.Find(f => f.AuditTrailID == id); itemAudit.ReceiverInvoiceAction = (byte)(EnumConstants.InvoiceActionAuditTrail)Enum.Parse(typeof(EnumConstants.InvoiceActionAuditTrail), lkb.CommandName); itemAudit.UpdatedDate = DateTime.Now; itemAudit.UpdatedBy = Common.LoggedInUserID();; unitOfWork.InvoiceAuditTrailRepositry.Update(itemAudit); unitOfWork.Save(); count = count + 1; if (!mailsToList.Contains(invoiceDetail.AspNetUser.Email)) { mailsToList.Add(invoiceDetail.AspNetUser.Email); } attribute.UserName = invoiceDetail.AspNetUser.OrganizationName; //attribute.MailsTo.Add(); //attribute.InvoiceNo = lvInvoices.DataKeys[item.DisplayIndex].Values["InvoiceNo"].ToString(); attribute.InvoiceDate = DateTimeAgo.GetFormatDate(invoiceDetail.InvoiceDate); attribute.InvoiceTotalAmount = invoiceDetail.GST_TRN_INVOICE_DATA.Sum(s => s.TotalAmountWithTax).ToString(); invAttributes.Add(attribute); //invID.Add(invoiceID); } } if (count > 0) { string mailString = string.Empty; string sellerMail = string.Empty; clsMessageAttribute mailData = new clsMessageAttribute(); foreach (clsMessageAttribute iId in invAttributes) { //Int64 id = Convert.ToInt64(iId); //mailString += "<tr><td align='left' style='table-layout:auto'>" + iId.InvoiceNo.ToString() + "</td>"; mailString += "<tr><td align='middle' style='table-layout:auto'>" + iId.InvoiceDate.ToString() + "</td>"; mailString += "<td align='right' style='table-layout:auto'>" + iId.InvoiceTotalAmount.ToString() + "</td></tr>"; mailData.UserName = iId.UserName; } this.Master.SuccessMessage = count.ToString() + " Invoice " + lkb.CommandName + " successfully."; SendHTMLMail(mailData, mailString, String.Join(";", mailsToList.ToArray())); //uc_sucess.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelSucessMessage", "$('#viewInvoiceModelSucessMessage').modal();", true); } else { this.Master.WarningMessage = "There are no invoices."; //uc_sucess.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelWarningMessage", "$('#viewInvoiceModelWarningMessage').modal();", true); //uc_sucess.SuccessMessage = "Data uploaded successfully."; // BindAllInvoices(); } } catch (Exception ex) { this.Master.ErrorMessage = ex.Message; //uc_sucess.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelErrorMessage", "$('#viewInvoiceModelErrorMessage').modal();", true); //uc_sucess.SuccessMessage = "Data uploaded successfully."; cls_ErrorLog ob = new cls_ErrorLog(); cls_ErrorLog.LogError(ex, Common.LoggedInUserID()); // BindAllInvoices(); } }
// GST_TRN_INVOICE_AUDIT_TRAIL audittrail = new GST_TRN_INVOICE_AUDIT_TRAIL(); protected void lkvGSTR2A_Click(object sender, EventArgs e) { try { var loggedinUserId = Common.LoggedInUserID(); LinkButton lkb = (LinkButton)sender; if (lkb.CommandName == "Import") { List <clsMessageAttribute> invAttributes = new List <clsMessageAttribute>(); List <string> mailsToList = new List <string>(); int count = 0; foreach (ListViewDataItem item in lvInvoices.Items) { Int64 invoiceID = Convert.ToInt64(lvInvoices.DataKeys[item.DisplayIndex].Values["InvoiceID"].ToString()); CheckBox chk = (CheckBox)item.FindControl("chkImport"); if (chk.Checked) { //amits start clsMessageAttribute attribute = new clsMessageAttribute(); var invoiceDetail = unitOfWork.InvoiceRepository.Find(f => f.InvoiceID == invoiceID); string invoiceNo = invoiceDetail.InvoiceNo; //End var filedItem = unitOfWork.InvoiceAuditTrailRepositry.Find(f => f.GST_TRN_INVOICE.ReceiverUserID == loggedinUserId && f.AuditTrailStatus == (byte)EnumConstants.InvoiceAuditTrailSatus.Import2A && f.InvoiceID == invoiceID && f.GST_TRN_INVOICE.Status == true); if (filedItem == null) { audittrail.InvoiceID = Convert.ToInt64(invoiceID);// item.InvoiceID; audittrail.AuditTrailStatus = Convert.ToByte(EnumConstants.InvoiceAuditTrailSatus.Import2A); audittrail.UserIP = Common.IP; audittrail.InvoiceAction = (byte)EnumConstants.InvoiceActionAuditTrail.NA; audittrail.ReceiverInvoiceAction = (byte)EnumConstants.InvoiceActionAuditTrail.NA; audittrail.SellerInvoiceAction = (byte)EnumConstants.InvoiceActionAuditTrail.NA; audittrail.CreatedDate = DateTime.Now; audittrail.CreatedBy = loggedinUserId; unitOfWork.InvoiceAuditTrailRepositry.Create(audittrail); unitOfWork.Save(); //count = count + 1; //amits start count = count + 1; if (!mailsToList.Contains(invoiceDetail.AspNetUser.Email)) { mailsToList.Add(invoiceDetail.AspNetUser.Email); } attribute.UserName = invoiceDetail.AspNetUser.OrganizationName; //attribute.MailsTo.Add(); attribute.InvoiceNo = invoiceNo; attribute.InvoiceDate = DateTimeAgo.GetFormatDate(invoiceDetail.InvoiceDate); attribute.InvoiceTotalAmount = invoiceDetail.GST_TRN_INVOICE_DATA.Sum(s => s.TotalAmountWithTax).ToString(); invAttributes.Add(attribute); //End } var invoice = unitOfWork.InvoiceRepository.Filter(f => f.InvoiceID == invoiceID).FirstOrDefault(); cls_PurchaseRegister insertPurchaseRegsiter = new cls_PurchaseRegister(); insertPurchaseRegsiter.LoggedinUserID = Common.LoggedInUserID(); bool isSave = insertPurchaseRegsiter.SaveInvoiveDataInPurchaseRegister(invoice); cls_ITC itc = new cls_ITC(); itc.ITCVoucherType = (byte)EnumConstants.ITCVoucherType.Purchase; itc.SaveItcReceiver(invoice); } else { } } if (count > 0) { string mailString = string.Empty; string sellerMail = string.Empty; clsMessageAttribute mailData = new clsMessageAttribute(); foreach (clsMessageAttribute iId in invAttributes) { mailString += "<tr><td align='left' style='table-layout:auto'>" + iId.InvoiceNo.ToString() + "</td>"; mailString += "<td align='middle' style='table-layout:auto'>" + iId.InvoiceDate.ToString() + "</td>"; mailString += "<td align='right' style='table-layout:auto'>" + iId.InvoiceTotalAmount.ToString() + "</td></tr>"; mailData.UserName = iId.UserName; } this.Master.SuccessMessage = "Data imported successfully."; SendHTMLMail(mailData, mailString, String.Join(";", mailsToList.ToArray())); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelSucessMessage", "$('#viewInvoiceModelSucessMessage').modal();", true); BindViewInvoice(Convert.ToByte(uc_invoiceMonth.GetValue)); } //if (count > 0) //{ // this.Master.SuccessMessage = count.ToString() + " Invoice " + lkb.CommandName + "ed successfully."; // //uc_sucess.Visible = true; // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelSucessMessage", "$('#viewInvoiceModelSucessMessage').modal();", true); //} else { this.Master.WarningMessage = "There are no invoices to import."; //uc_sucess.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelWarningMessage", "$('#viewInvoiceModelWarningMessage').modal();", true); } } BindViewInvoice(Convert.ToByte(uc_invoiceMonth.GetValue)); } catch (Exception ex) { cls_ErrorLog ob = new cls_ErrorLog(); cls_ErrorLog.LogError(ex, Common.LoggedInUserID()); } }