public int salgE() { try { SalGr sg = new SalGr(); if (sg.SAL == 0 || sg.Heal == 0 || sg.HAL == 0 || sg.Dl == 0) { return(1); } else { EmpInfoLinqDataContext cntx = new EmpInfoLinqDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\Project Salary Manager\SalaryManager\SalaryManager\EmpployeeInfo.mdf;Integrated Security=True;Connect Timeout=30"); var str = from a in cntx.SalaryGs select a; SalaryG p = str.Where(obj => obj.SalaryGrade == sg.SLG).First(); p.Salary = sg.SAL; p.HealthAl = sg.Heal; p.HomeAl = sg.HAL; p.HealthAlp = sg.Heal2; p.HomeAlp = sg.HAL2; p.DayAl = sg.Dl; p.Bonus = sg.BON; cntx.SubmitChanges(); return(0); } } catch { return(1); } }
private void metroTile1_Click(object sender, EventArgs e) { try { if (metroRadioButton1.Checked == false) { SalGr sg = new SalGr(); AddEmp2 ae = new AddEmp2(); sg.SLG = metroComboBox1.SelectedItem.ToString(); sg.HAL = Convert.ToInt32(metroTextBox2.Text); sg.Heal = Convert.ToInt32(metroTextBox3.Text); //sg.HAL2 = Convert.ToInt32(metroTextBox2.Text); //sg.Heal2 = Convert.ToInt32(metroTextBox3.Text); sg.SAL = Convert.ToInt32(metroTextBox1.Text); sg.Dl = Convert.ToInt32(metroTextBox5.Text); int s = ae.salgE(); if (s == 0) { MetroFramework.MetroMessageBox.Show(this, "Successfully Changed", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroFramework.MetroMessageBox.Show(this, "There Is An Error", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { SalGr sg = new SalGr(); AddEmp2 ae = new AddEmp2(); sg.SLG = metroComboBox1.SelectedItem.ToString(); sg.HAL = Convert.ToInt32(metroTextBox2.Text); sg.Heal = Convert.ToInt32(metroTextBox3.Text); //sg.HAL2 = Convert.ToInt32(metroTextBox2.Text); //sg.Heal2 = Convert.ToInt32(metroTextBox3.Text); sg.SAL = Convert.ToInt32(metroTextBox1.Text); sg.Dl = Convert.ToInt32(metroTextBox5.Text); string bon = metroComboBox2.SelectedItem.ToString(); sg.BON = Convert.ToInt32(bon); int s = ae.salgE(); if (s == 0) { MetroFramework.MetroMessageBox.Show(this, "Successfully Changed", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); metroRadioButton1.Checked = false; } else { MetroFramework.MetroMessageBox.Show(this, "There Is An Error", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch { MetroFramework.MetroMessageBox.Show(this, "Please Fill Up All the fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int salgF() { SalGr sg = new SalGr(); try { EmpInfoLinqDataContext cntx = new EmpInfoLinqDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\Project Salary Manager\SalaryManager\SalaryManager\EmpployeeInfo.mdf;Integrated Security=True;Connect Timeout=30"); var str = from a in cntx.SalaryGs select a; SalaryG p = str.Where(obj => obj.SalaryGrade == sg.SLG).First(); sg.SAL = Convert.ToInt32(p.Salary); sg.Heal = Convert.ToInt32(p.HealthAl); sg.HAL = Convert.ToInt32(p.HomeAl); sg.Dl = Convert.ToInt32(p.DayAl); return(0); } catch { return(1); } }
private void metroButton1_Click(object sender, EventArgs e) { SalGr sg = new SalGr(); AddEmp2 ae = new AddEmp2(); sg.SLG = metroComboBox1.SelectedItem.ToString(); int s = ae.salgF(); if (s == 1) { MetroFramework.MetroMessageBox.Show(this, "Error", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MetroFramework.MetroMessageBox.Show(this, "The values Are Retrived.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); metroTextBox2.Text = Convert.ToString(sg.HAL); metroTextBox1.Text = Convert.ToString(sg.SAL); metroTextBox3.Text = Convert.ToString(sg.Heal); metroTextBox5.Text = Convert.ToString(sg.Dl); } }