/// <summary> /// Realizeaza download-ul fisieruluice contine toate datele aferente declaratiei A12, /// necesare importului in aplicatia pentru CAS. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDownloadA12_Click(object sender, System.EventArgs e) { // Calea catre fisierul text in care trebuie scrise informatiile. string caleFisierDeclaratie = Server.MapPath("") + "\\..\\DeclaratiiCAS\\a12.txt"; // Calea catre fisierul XML ce contine descrierea declaratiilor. string caleFisierXML = Server.MapPath("") + @"\..\Declaratii\Declaratii.xml"; Salaries.Business.Declaratii declaratiaA12 = new Salaries.Business.Declaratii(this.GetCurrentMonth(), this.GetAngajator(), caleFisierDeclaratie, caleFisierXML); if (!Directory.Exists(Server.MapPath("") + "\\..\\DeclaratiiCAS")) { Directory.CreateDirectory(Server.MapPath("") + "\\..\\DeclaratiiCAS"); } if (File.Exists(caleFisierDeclaratie)) { File.Delete(caleFisierDeclaratie); } // Este generata declaratia a11 pentru CAS. declaratiaA12.GenerareDeclaratieCASa12(DateTime.Parse(txtDataPlatii.Text), int.Parse(txtNrFileAnexa11.Text)); // Se downloadeaza fisierul // Se sterge continutul variabile Response inainte de a fi scrise datele din raport Response.Clear(); Response.ContentType = "text/plain"; string FilePath = Server.MapPath("") + "\\..\\DeclaratiiCAS\\a12.txt"; Response.AppendHeader("content-disposition", "attachment; filename=" + FilePath); Response.WriteFile(FilePath); Response.End(); }
/// <summary> /// Genereaza raportul /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGenereaza_Click(object sender, System.EventArgs e) { an = Convert.ToInt32(textBoxAn.Text); casaDeAsigurariID = Convert.ToInt32(drpCaseDeAsig.SelectedValue.ToString()); tipDeclaratie = Convert.ToInt32(drpTipDeclaratie.SelectedValue.ToString()); string path = Salaries.Configuration.CryptographyClass.getSettingsWithoutDecode(importLogFolder) + "\\FisaFiscala.xml"; XmlTextReader reader = new XmlTextReader(path); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(reader); Salaries.Business.Salariu sal = new Salaries.Business.Salariu(); #region declaratie205 //duc datasetul cu reprezentantii legali - pentru declarant Salaries.Business.AdminAngajator adminAng = new Salaries.Business.AdminAngajator(); adminAng.AngajatorId = angajatorID; DataSet ds = adminAng.GetReprezLegali(); string numeDeclarant = "", prenumeDeclarant = "", functieDeclarant = ""; foreach (DataRow dr in ds.Tables[0].Rows) { // Numele si prenumele declarantului if (dr["NumeFunctie"].ToString().Equals("Contabil sef")) { numeDeclarant = dr["NumeReprez"].ToString(); prenumeDeclarant = dr["PrenumeReprez"].ToString(); functieDeclarant = dr["NumeFunctie"].ToString(); } } DataSet dsAngajator = adminAng.GetAngajatorInfoFiseFiscale(angajatorID); DataTable dtAngajator = dsAngajator.Tables[0]; //completez atributele nodului; XmlNode nodeDeclaratie = xmlDoc.GetElementsByTagName("declaratie205")[0]; nodeDeclaratie.Attributes["luna"].Value = "12"; nodeDeclaratie.Attributes["an"].Value = textBoxAn.Text.ToString(); nodeDeclaratie.Attributes["d_rec"].Value = drpTipDeclaratie.SelectedValue.ToString(); nodeDeclaratie.Attributes["nume_declar"].Value = numeDeclarant; nodeDeclaratie.Attributes["prenume_declar"].Value = prenumeDeclarant; nodeDeclaratie.Attributes["functie_declar"].Value = functieDeclarant; nodeDeclaratie.Attributes["cui"].Value = dtAngajator.Rows[0]["CUI_CNP"].ToString(); nodeDeclaratie.Attributes["den"].Value = dtAngajator.Rows[0]["Denumire"].ToString(); nodeDeclaratie.Attributes["adresa"].Value = dtAngajator.Rows[0]["Adresa"].ToString(); nodeDeclaratie.Attributes["telefon"].Value = dtAngajator.Rows[0]["Telefon"].ToString(); nodeDeclaratie.Attributes["fax"].Value = dtAngajator.Rows[0]["Fax"].ToString(); nodeDeclaratie.Attributes["mail"].Value = dtAngajator.Rows[0]["Email"].ToString(); #endregion #region beneficiar Salaries.Business.Declaratii decl = new Salaries.Business.Declaratii(lunaID, angajatorID); DataSet dsFiseFiscale = decl.GetDateFiseFiscale(an, casaDeAsigurariID); int nrAngajati = dsFiseFiscale.Tables[0].Rows.Count; DataTable dtFiseFiscale = dsFiseFiscale.Tables[0]; XmlNode nodeBenef = xmlDoc.GetElementsByTagName("benef")[0]; XmlNode parent = nodeBenef.ParentNode; foreach (DataRow dr in dsFiseFiscale.Tables[0].Rows) { XmlNode nodeBeneficiar = nodeBenef.CloneNode(true); nodeBeneficiar.Attributes["id_inreg"].Value = dr["AngajatId"].ToString(); nodeBeneficiar.Attributes["tip_venit1"].Value = "07"; nodeBeneficiar.Attributes["den1"].Value = dr["DENUMIRE"].ToString(); nodeBeneficiar.Attributes["cif1"].Value = dr["COD"].ToString(); nodeBeneficiar.Attributes["tip_salAB"].Value = "1"; nodeBeneficiar.Attributes["tip_plata"].Value = "2"; nodeBeneficiar.Attributes["tip_functie"].Value = dr["TIP"].ToString(); nodeBeneficiar.Attributes["vbrut"].Value = dr["VBRUT_13"].ToString(); nodeBeneficiar.Attributes["dedu_pers"].Value = dr["DEDU_13"].ToString(); nodeBeneficiar.Attributes["dedu_alte"].Value = dr["ALTDED_13"].ToString(); nodeBeneficiar.Attributes["baza1"].Value = dr["VENIT_13"].ToString(); nodeBeneficiar.Attributes["imp1"].Value = dr["IMPOZIT_13"].ToString(); parent.InsertAfter(nodeBeneficiar, nodeBenef); totBaza = totBaza + Convert.ToInt32(dtFiseFiscale.Rows[0]["VENIT_13"].ToString()); totImp = totImp + Convert.ToInt32(dtFiseFiscale.Rows[0]["IMPOZIT_13"].ToString()); } parent.RemoveChild(nodeBenef); #endregion #region sect_II XmlNode node = xmlDoc.GetElementsByTagName("sect_II")[0]; node.Attributes["tip_venit"].Value = "07"; node.Attributes["nrben"].Value = nrAngajati.ToString(); node.Attributes["Tcastig"].Value = "0"; node.Attributes["Tpierd"].Value = "0"; node.Attributes["Tbaza"].Value = totBaza.ToString(); node.Attributes["Timp"].Value = totImp.ToString(); int totalPlata = nrAngajati + totBaza + totImp; nodeDeclaratie.Attributes["totalPlata_A"].Value = totalPlata.ToString(); #endregion path = Salaries.Configuration.CryptographyClass.getSettingsWithoutDecode(importLogFolder) + "\\FisaFiscalaOut.xml"; //path = "C:\\Inetpub\\wwwroot\\hr\\InterfataSalarii\\Templates\\DecUnicaOut.xml"; xmlDoc.Save(path); path = this.Page.Request.Url.AbsoluteUri; path = path.Substring(0, path.LastIndexOf("/")); hyperLinkDeclaratie.NavigateUrl = path + "/Templates/FisaFiscalaOut.xml"; hyperLinkDeclaratie.Visible = true; }