/// <summary> /// Completeaza campurile cu datele unui judet /// </summary> private void FillEditForm() { try { int judetId = Convert.ToInt32(txtJudetID.Text); Salaries.Business.AdminJudete judet = new Salaries.Business.AdminJudete(); judet.JudetId = judetId; DataRow rowJudet = judet.GetJudetInfo().Tables[0].Rows[0]; ddlTara.SelectedValue = rowJudet["TaraId"].ToString(); txtNume.Text = rowJudet["Nume"].ToString(); txtSimbol.Text = rowJudet["Simbol"].ToString(); txtCod.Text = rowJudet["Cod"].ToString(); txtJudetID.Text = judetId.ToString(); td_addLine.Visible = false; td_editLine.Visible = true; add_form.Style.Add("display", ""); add_buttonLine.Visible = false; tdTitle.InnerText = "Editare judet"; listDataGrid.Visible = false; //Daca pagina de administrare a fost deschisa din AddAngajat cream functia // care va face refresh la combo-ul cu judete In acest caz va fi goala ... CreateEmptyRefreshFunctionForAddAngajat(); } catch (Exception ex) { litError.Text = "The following error occurred: <br>"; litError.Text += ex.Message; } }
/// <summary> /// Adauga un judet /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, System.EventArgs e) { try { Salaries.Business.AdminJudete newJudet = new Salaries.Business.AdminJudete(); newJudet.TaraId = int.Parse(ddlTara.SelectedValue); newJudet.Nume = txtNume.Text; newJudet.Simbol = txtSimbol.Text; newJudet.Cod = txtCod.Text; newJudet.JudetId = -1; if (!newJudet.VerificareExistentaJudet()) { newJudet.InsertJudet(); // Daca pagina de administrare a fost deschisa din AddAngajat cream // functia care va face refresh la combo-ul cu judete CreateRefreshFunctionForAddAngajat(); } else { Response.Write("<script>alert('Exista in baza de date un judet cu acelesi date! Adaugarea nu a fost realizata!');</script>"); //FillAddForm(); } //ListareJudete(); CompletareTitlu(); PopulareTabela(); } catch (Exception ex) { litError.Text = "The following error occurred: <br>"; litError.Text += ex.Message; } }
/// <summary> /// Populeaza tabela cu judete /// </summary> public void PopulareTabela() { Index = listDataGrid.CurrentPageIndex * 30 + 1; Salaries.Business.AdminJudete objAdminJudete = new Salaries.Business.AdminJudete(); listDataGrid.DataSource = objAdminJudete.LoadInfoJudete(); listDataGrid.DataBind(); }
private void BindLstJudetNastereDDL() { Salaries.Business.AdminJudete judete = new Salaries.Business.AdminJudete(); lstJudetNastere.DataSource = judete.LoadInfoJudete(); lstJudetNastere.DataTextField = "NumeCompus"; lstJudetNastere.DataValueField = "JudetID"; lstJudetNastere.DataBind(); }
/// <summary> /// Face legatura intre dropdownlis-ul cu judete si judetele din tara cu id-ul lstDTara.SelectedValue din baza de date /// </summary> private void BindLstDJudetDDL() { Salaries.Business.AdminJudete judete = new Salaries.Business.AdminJudete(); judete.TaraId = int.Parse(lstDTara.SelectedValue); lstDJudet.DataSource = judete.GetAllJudeteTara(); lstDJudet.DataTextField = "NumeCompus"; lstDJudet.DataValueField = "JudetID"; lstDJudet.DataBind(); }
/// <summary> /// Se trece la pagina urmatoare in lista cu judete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void listDataGrid_PageIndexChanged(Object sender, DataGridPageChangedEventArgs e) { Salaries.Business.AdminJudete objAdminJudete = new Salaries.Business.AdminJudete(); DataSet dt = objAdminJudete.LoadInfoJudete(); CompletareTitlu(); listDataGrid.CurrentPageIndex = e.NewPageIndex; DataView dv = dt.Tables[0].DefaultView; listDataGrid.DataSource = dv; Index = (e.NewPageIndex * listDataGrid.PageSize) + 1; listDataGrid.DataBind(); }
/// <summary> /// Valorile judetelor /// </summary> /// <returns></returns> private string GetSirJudeteValue() { string sirJudVal = ""; string sirJudValFinal = ""; Salaries.Business.AdminTari tari = new Salaries.Business.AdminTari(); DataSet dsTari = tari.LoadInfoTari(); foreach (DataRow drTari in dsTari.Tables[0].Rows) { Salaries.Business.AdminJudete judete = new Salaries.Business.AdminJudete(); judete.TaraId = int.Parse(drTari["TaraID"].ToString()); DataSet ds = judete.GetAllJudeteTara(); if (ds.Tables[0].Rows.Count > 0) { sirJudVal = "["; for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++) { DataRow dr = ds.Tables[0].Rows[i]; sirJudVal += dr["JudetID"].ToString() + ", "; } sirJudVal += ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["JudetID"].ToString() + "]"; } else { sirJudVal = "[]"; } //sirTari = "["+sirTariText+","+sirTariValue+"]"; sirJudValFinal += sirJudVal + ", "; } if (sirJudValFinal == "") { sirJudValFinal += "[[]]"; } else { sirJudValFinal = sirJudValFinal.Substring(0, sirJudValFinal.Length - 2); sirJudValFinal = "[" + sirJudValFinal + "]"; } return(sirJudValFinal); }
/// <summary> /// ID-urile judetelor din fiecare tara. /// </summary> /// <returns> Returneaza id-urile judetelor din fiecare tara.</returns> private string GetSirJudeteValue() { string sirJudVal = ""; string sirJudValFinal = ""; settings = Salaries.Configuration.ModuleConfig.GetSettings(); Salaries.Business.AdminJudete judete = new Salaries.Business.AdminJudete(); DataSet dsTari = (DataSet)lstDTara.DataSource; foreach (DataRow drTari in dsTari.Tables[0].Rows) { judete.TaraId = int.Parse(drTari["TaraID"].ToString()); DataSet ds = judete.GetAllJudeteTara(); if (ds.Tables[0].Rows.Count > 0) { sirJudVal = "["; for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++) { DataRow dr = ds.Tables[0].Rows[i]; sirJudVal += dr["JudetID"].ToString() + ", "; } sirJudVal += ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["JudetID"].ToString() + "]"; } else { sirJudVal = "[]"; } sirJudValFinal += sirJudVal + ", "; } if (sirJudValFinal == "") { sirJudValFinal += "[[]]"; } else { sirJudValFinal = sirJudValFinal.Substring(0, sirJudValFinal.Length - 2); sirJudValFinal = "[" + sirJudValFinal + "]"; } return(sirJudValFinal); }
/// <summary> /// Numele judetelor din fiecare tara. /// </summary> /// <returns> Returneaza numele judetelor din fiecare tara.</returns> private string GetSirJudeteText() { string sirJudText = ""; string sirJudTextFinal = ""; Salaries.Business.AdminJudete judete = new Salaries.Business.AdminJudete(); DataSet dsTari = (DataSet)lstDTara.DataSource; foreach (DataRow drTari in dsTari.Tables[0].Rows) { judete.TaraId = int.Parse(drTari["TaraID"].ToString()); DataSet ds = judete.GetAllJudeteTara(); if (ds.Tables[0].Rows.Count > 0) { sirJudText = "["; for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++) { DataRow dr = ds.Tables[0].Rows[i]; sirJudText += "'" + dr["NumeCompus"].ToString() + "', "; } sirJudText += "'" + ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["NumeCompus"].ToString() + "']"; } else { sirJudText = "[]"; } sirJudTextFinal += sirJudText + ", "; } if (sirJudTextFinal == "") { sirJudTextFinal += "[[]]"; } else { sirJudTextFinal = sirJudTextFinal.Substring(0, sirJudTextFinal.Length - 2); sirJudTextFinal = "[" + sirJudTextFinal + "]"; } return(sirJudTextFinal); }
/// <summary> /// Sterge un judet /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, System.EventArgs e) { try { int judetId = Convert.ToInt32(txtJudetID.Text); Salaries.Business.AdminJudete judet = new Salaries.Business.AdminJudete(); judet.JudetId = judetId; int raspuns = judet.CheckIfJudetCanBeDeleted(); if (raspuns == 2) { judet.DeleteJudet(); // Daca pagina de administrare a fost deschisa din AddAngajat cream functia care va // face refresh la combo-ul cu judete CreateRefreshFunctionForAddAngajat(); } if (raspuns == 1) { Response.Write("<script>alert('Judetul nu poate fi sters deoarece sunt locatii asociate acestuia!');</script>"); FillEditForm(); } if (raspuns == 0) { Response.Write("<script>alert('Judetul nu poate fi sters deoarece este ultimul asociat acestei tari!');</script>"); FillEditForm(); } } catch (Exception ex) { litError.Text = "The following error occurred: <br>"; litError.Text += ex.Message; } //ListareJudete(); CompletareTitlu(); PopulareTabela(); }
private void Page_Load(object sender, System.EventArgs e) { // Tipurile de completare ale carnetelor de munca. Salaries.Business.AdminTipuriCompletareCarnete tipCompletareCarnete = new Salaries.Business.AdminTipuriCompletareCarnete(); tipCompletareCarnete.AngajatorId = GetAngajator(); // Lista bancilor. Salaries.Business.AdminBanci banci = new Salaries.Business.AdminBanci(); string[] textTabs = { "Date angajator", "Conturi bancare", "Adresa angajator", "Domenii de activitate", "Punct de lucru" }; Utilities.CreateHeaderWithTabsForAdminAngajator(tableTabs, textTabs, "../", true); settings = Salaries.Configuration.ModuleConfig.GetSettings(); UtilitiesDb utilDb = new UtilitiesDb(settings.ConnectionString); // Sunt facute invizibile textbox-urile txtHiddenDomDeActPpID.Style.Add("display", "none"); txtHiddenDomDeActListID.Style.Add("display", "none"); txtHiddenPunctLucru.Style.Add("display", "none"); //Lungu Andreea 28.05.2008 //este populat dropdownlist-ul ce contine casele de asigurari DataSet dsCaseDeAsig = new DataSet(); Salaries.Business.CasaDeAsigurari casaAsig = new Salaries.Business.CasaDeAsigurari(); // Lista caselor de asigurari ale unui angajator. dsCaseDeAsig = casaAsig.GetAllCasaDeAsigurari(); drpCaseDeAsigurari.DataSource = dsCaseDeAsig; drpCaseDeAsigurari.DataTextField = "Denumire"; drpCaseDeAsigurari.DataValueField = "CasaDeAsigurariID"; drpCaseDeAsigurari.DataBind(); //tara Salaries.Business.AdminTari tari = new Salaries.Business.AdminTari(); lstDTara.DataSource = tari.LoadInfoTariCuJudete(); lstDTara.DataTextField = "NumeTara"; lstDTara.DataValueField = "TaraID"; lstDTara.DataBind(); if (txtTaraHidden.Value != "") { lstDTara.SelectedValue = txtTaraHidden.Value; } //judetul Salaries.Business.AdminJudete judete = new Salaries.Business.AdminJudete(); judete.TaraId = int.Parse(lstDTara.SelectedValue); lstDJudet.DataSource = judete.GetAllJudeteTara(); lstDJudet.DataTextField = "NumeCompus"; lstDJudet.DataValueField = "JudetID"; lstDJudet.DataBind(); if (txtJudetSectorHidden.Value != "") { lstDJudet.SelectedValue = txtJudetSectorHidden.Value; } // Listarea tipurilor de completare a carnetelor de munca. lstTipCompletare.DataSource = tipCompletareCarnete.GetTipuriCompletareCarnete(); lstTipCompletare.DataTextField = "ModCompletare"; lstTipCompletare.DataValueField = "CompletareCarneteValoriID"; lstTipCompletare.DataBind(); if (txtTipCompletareHidden.Value != "") { lstTipCompletare.SelectedValue = txtTipCompletareHidden.Value; } // Listare banci. drpBanci.DataSource = banci.GetBanci(); drpBanci.DataTextField = "NumeBanca"; drpBanci.DataValueField = "BancaID"; drpBanci.DataBind(); // Listare domenii de activitate ale angajatorului ListareDomeniiDeActivitate(); txtTaraHidden.Value = txtTaraHidden.Value == "" ? lstDTara.SelectedValue : txtTaraHidden.Value; txtJudetSectorHidden.Value = txtJudetSectorHidden.Value == "" ? lstDJudet.SelectedValue : txtJudetSectorHidden.Value; txtTipCompletareHidden.Value = txtTipCompletareHidden.Value == "" ? lstTipCompletare.SelectedValue : txtTipCompletareHidden.Value; ListareAngajatori(); }
private void Page_Load(object sender, System.EventArgs e) { /*if(!IsPostBack) * { * //se obtine tipul de autentificare la aplicatie * string authentication = Salaries.Configuration.CryptographyClass.getSettingsWithoutDecode("authentication"); * * //virtual path * string path = Page.Request.FilePath; * char separator = '/'; * string [] pathArr = path.Split(separator); * int nr = pathArr.Length; * * //autentificare de tip windows * if (authentication == "1") * { * //user-ul loginat * user = new WindowsPrincipal(WindowsIdentity.GetCurrent()); * * //user-ul loginat nu are dreptul sa acceseze aceasta pagina este redirectat catre o pagina care sa il instiinteze de acest lucru * if(!Salaries.Business.Authentication.HasUserRightsOnPage(pathArr[nr-1],user)) * { * Response.Redirect("../Unauthorized.aspx"); * } * } * //autentificare cu user si parola * else * { * string nume = Session["Nume"].ToString(); * string parola = Session["Parola"].ToString(); * int angajatorId = int.Parse(Session["AngajatorId"].ToString()); * * //user-ul loginat nu are dreptul sa acceseze aceasta pagina este redirectat catre o pagina care sa il instiinteze de acest lucru * if(!Salaries.Business.Authentication.HasUserRightsOnPage(pathArr[nr-1], nume, parola, angajatorId)) * { * Response.Redirect("../Unauthorized.aspx"); * } * } * }*/ Salaries.Business.AdminSalariiLuni salarii = new Salaries.Business.AdminSalariiLuni(); DataSet ds = salarii.LoadInfoLuniSalariiUnion(); ds.Tables[0].Rows.RemoveAt(0); lstLuna.DataSource = ds; lstLuna.DataTextField = "Denumire"; lstLuna.DataValueField = "LunaTextID"; lstLuna.DataBind(); int an = DateTime.Now.Year; for (int i = an - 5; i <= an + 5; i++) { lstAn.Items.Add(new ListItem(i + "", i + "")); } // Lista bancilor. Salaries.Business.AdminBanci banci = new Salaries.Business.AdminBanci(); string[] textTabs = { "Date angajator", "Conturi angajator", "Adresa angajator", "Domenii de activitate", "Punct de lucru", "Reprezentanti legali" }; Utilities.CreateHeaderWithTabsForAdminAngajator(tableTabs, textTabs, "../", true); settings = Salaries.Configuration.ModuleConfig.GetSettings(); UtilitiesDb utilDb = new UtilitiesDb(settings.ConnectionString); // Sunt facute invizibile textbox-urile txtHiddenDomDeActPpID.Style.Add("display", "none"); txtHiddenDomDeActListID.Style.Add("display", "none"); txtHiddenPunctLucru.Style.Add("display", "none"); //tara Salaries.Business.AdminTari tari = new Salaries.Business.AdminTari(); lstDTara.DataSource = tari.LoadInfoTariCuJudete(); lstDTara.DataTextField = "NumeTara"; lstDTara.DataValueField = "TaraID"; lstDTara.DataBind(); if (txtTaraHidden.Value != "") { lstDTara.SelectedValue = txtTaraHidden.Value; } //judetul Salaries.Business.AdminJudete judete = new Salaries.Business.AdminJudete(); judete.TaraId = int.Parse(lstDTara.SelectedValue); lstDJudet.DataSource = judete.GetAllJudeteTara(); lstDJudet.DataTextField = "NumeCompus"; lstDJudet.DataValueField = "JudetID"; lstDJudet.DataBind(); if (txtJudetSectorHidden.Value != "") { lstDJudet.SelectedValue = txtJudetSectorHidden.Value; } // Listare banci. drpBanci.DataSource = banci.GetBanci(); drpBanci.DataTextField = "NumeBanca"; drpBanci.DataValueField = "BancaID"; drpBanci.DataBind(); // Listare domenii de activitate ale angajatorului ListareDomeniiDeActivitate(); txtTaraHidden.Value = txtTaraHidden.Value == "" ? lstDTara.SelectedValue : txtTaraHidden.Value; txtJudetSectorHidden.Value = txtJudetSectorHidden.Value == "" ? lstDJudet.SelectedValue : txtJudetSectorHidden.Value; txtHiddenLuna.Value = txtHiddenLuna.Value == "" ? lstLuna.SelectedValue : txtHiddenLuna.Value; txtHiddenAn.Value = txtHiddenAn.Value == "" ? lstAn.SelectedValue : txtHiddenAn.Value; //Lungu Andreea 28.05.2008 //este populat dropdownlist-ul ce contine casele de asigurari DataSet dsCaseDeAsig = new DataSet(); Salaries.Business.CasaDeAsigurari casaAsig = new Salaries.Business.CasaDeAsigurari(); // Lista caselor de asigurari ale unui angajator. dsCaseDeAsig = casaAsig.GetAllCasaDeAsigurari(); drpCaseDeAsigurari.DataSource = dsCaseDeAsig; drpCaseDeAsigurari.DataTextField = "Denumire"; drpCaseDeAsigurari.DataValueField = "CasaDeAsigurariID"; drpCaseDeAsigurari.DataBind(); //Lungu Andreea 19.08.2008 //este populat dropdownlist-ul ce contine functiile reprzentantilor legali DataSet dsFunctiiReprez = new DataSet(); //Lista functiilor reprezentantilor legali ale unui angajator. Salaries.Business.AdminAngajator angajator = new Salaries.Business.AdminAngajator(); dsFunctiiReprez = angajator.GetAllFunctiiReprez(); drpFunctiiReprez.DataSource = dsFunctiiReprez; drpFunctiiReprez.DataTextField = "NumeFunctie"; drpFunctiiReprez.DataValueField = "FunctieReprezID"; drpFunctiiReprez.DataBind(); txtHiddenNrFunctii.Value = drpFunctiiReprez.Items.Count.ToString(); }
/// <summary> /// Daca pagina de administrare a fost deschisa din AddAngajat cream functia /// care va face refresh la combo-ul cu judete /// </summary> private void CreateRefreshFunctionForAddAngajat() { string outStr = ""; //tb resetate sirurile cu tari si judete din AddAngajat din cauza actualizarii tarilor string sirTari = GetSirTari(); string sirJudeteText = GetSirJudeteText(); string sirJudeteValue = GetSirJudeteValue(); Response.Write("<script>var tari1 = " + sirTari + ";</script>"); Response.Write("<script>var judeteText1 = " + sirJudeteText + ";</script>"); Response.Write("<script>var judeteValue1 = " + sirJudeteValue + ";</script>"); //cream scriptul care va contine functia de refresh //ne bazam pe faptul ca se cunoaste numele selectului care contine judetele //initial se sterg toate intrarile din combo outStr += "<script> \r\n function RefreshAddAngajatPage() \r\n" + "{ \r\n" + "window.opener.RecreateArray_TariJudete('judeteText',judeteText1.length); \r\n" + "for(i=0;i<judeteText1.length;i++) \r\n" + " window.opener.RecreateLine_TariJudete( 'judeteText' ,i, judeteText1[i].length); \r\n" + "for(i=0;i<judeteText1.length;i++) \r\n" + "{ \r\n" + " if ( judeteText1[i].length == 0) \r\n" + " window.opener.SetJudeteText( i, 0, null); \r\n"+ " else \r\n" + " for(j=0;j<judeteText1[i].length;j++) \r\n"+ " window.opener.SetJudeteText( i, j, judeteText1[i][j]); \r\n"+ "} \r\n" + "window.opener.RecreateArray_TariJudete('judeteValue',judeteValue1.length); \r\n" + "for(i=0;i<judeteValue1.length;i++) \r\n" + " window.opener.RecreateLine_TariJudete( 'judeteValue' ,i, judeteValue1[i].length); \r\n" + "for(i=0;i<judeteValue1.length;i++) \r\n" + "for(j=0;j<judeteValue1[i].length;j++) \r\n" + "window.opener.SetJudeteValue( i, j, judeteValue1[i][j]); \r\n" + "window.opener.DeleteJudeteCombo(); \r\n" + " FillJudeteCOmbo(); \r\n" + "} \r\n"; //acum se creeaza functie care adauga judetele din recordset //se foloseste o functie din AddAngajat ... FillJudetCombo Salaries.Business.AdminJudete objAdminJudete = new Salaries.Business.AdminJudete(); outStr += " function FillJudeteCOmbo() \r\n" + "{ \r\n"; foreach (DataRow dataRow in objAdminJudete.LoadInfoJudete().Tables[0].Rows) { outStr += "window.opener.FillJudetCombo('" + dataRow["Nume"].ToString() + "'," + dataRow["JudetID"].ToString() + ");"; } outStr += " window.opener.SyncronizeTaraJudete(); \r\n"; outStr += "} \r\n" + "</script>"; Response.Write(outStr); }