Esempio n. 1
0
        public int addToDB()
        {
            try
            {
                AddEmp1 ae1 = new AddEmp1();
                EmpInfoLinqDataContext cntx = new EmpInfoLinqDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\Project Salary Manager\SalaryManager\SalaryManager\EmpployeeInfo.mdf;Integrated Security=True;Connect Timeout=30");

                Loans_Leave lo = new Loans_Leave();
                lo.Id2            = ae1.id2;
                lo.LeaveDays      = 100;
                lo.SavingsAccount = 10000;
                lo.LoanAmount     = 0;
                lo.PayAmount      = 0;
                lo.Year           = Convert.ToInt32(DateTime.Now.ToString("yyyy"));
                taxAndSal trs = new taxAndSal();
                trs.Id2        = ae1.id2;
                trs.PendingTax = 0;

                /*CheckIn ci = new CheckIn();
                 * ci.Id2 = ae1.id2; ;
                 * ci.CheckinMark = 0;
                 * ci.PCheckInMark = 0;
                 * ci.CheckInCounter = "0";
                 * ci.Password = ae1.Pass;*/

                EmpInformation emp = new EmpInformation();

                emp.Id1          = ae1.id1;
                emp.Id2          = ae1.id2;
                emp.Name         = ae1.NName;
                emp.Password     = ae1.Pass;
                emp.PhoneNumber  = ae1.PNumber;
                emp.Rank         = ae1.RRank;
                emp.SalaryGrade  = ae1.SalGrade;
                emp.HomeAddress  = ae1.HAddress;
                emp.EmailAddress = ae1.EAddress;
                emp.Under        = ae.id1 + ae.id2;
                cntx.EmpInformations.InsertOnSubmit(emp);
                cntx.Loans_Leaves.InsertOnSubmit(lo);
                cntx.taxAndSals.InsertOnSubmit(trs);
                //cntx.CheckIns.InsertOnSubmit(ci);
                cntx.SubmitChanges();
                return(0);
            }
            catch
            {
                return(1);
            }
        }
 private void metroTile1_Click(object sender, EventArgs e)
 {
     if (metroTextBox1.Text != "" && metroTextBox2.Text != "" && metroTextBox3.Text != "" && metroTextBox4.Text != "" && metroTextBox5.Text != "" && metroTextBox6.Text != "" && metroTextBox7.Text != "" && metroTextBox5.Text == metroTextBox6.Text)
     {
         SignInEmp si  = new SignInEmp();
         AddEmp1   ae1 = new AddEmp1();
         ae1.id1      = Convert.ToChar(metroLabel5.Text);
         ae1.id2      = metroTextBox4.Text;
         ae1.NName    = metroTextBox7.Text;
         ae1.RRank    = metroLabel6.Text;
         ae1.SalGrade = metroLabel9.Text;
         ae1.PNumber  = metroTextBox1.Text;
         ae1.HAddress = metroTextBox3.Text;
         ae1.EAddress = metroTextBox2.Text;
         ae1.Pass     = metroTextBox5.Text;
         //ae1.DOB = this.metroDateTime1.Text;
         //ae1.Pict = filename;
         AddEmp2 ae2 = new AddEmp2();
         int     c   = ae2.addToDB();
         if (c == 1)
         {
             MetroFramework.MetroMessageBox.Show(this, " Error", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             MetroFramework.MetroMessageBox.Show(this, " Successful", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             metroTextBox1.Text = "";
             metroTextBox2.Text = "";
             metroTextBox3.Text = "";
             metroTextBox4.Text = "";
             metroTextBox5.Text = "";
             metroTextBox6.Text = "";
             metroTextBox7.Text = "";
             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.EmpInformations
                       where a.Under == si.id1 + si.id2
                       select new { Id1 = a.Id1, Id2 = a.Id2, Name = a.Name };
             metroGrid1.DataSource = str;
         }
     }
     else
     {
         MessageBox.Show("Error Ditected", "Please Fillup all the Boxes");
     }
 }