Exemplo n.º 1
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                var TS = new EmployeeSalaryClient();
                using (TransactionScope Trs = new TransactionScope())
                {
                    int id = TS.CreateEmployee(new Employee()
                    {
                        EName = txtEmployeeName.Text, ESalary = double.Parse(txtEmployeeSalary.Text)
                    });
                    if (id != 0)
                    {
                        TS.CreateSalaryHistory(new SalaryHistory()
                        {
                            Eid = id, ESalary = double.Parse(txtEmployeeSalary.Text), StDate = DateTime.Now, EdDate = null
                        });
                    }

                    //Log to the client side
                    CreateTransactionLog(new Transaction {
                        TDate = DateTime.Now, TInfo = String.Format("Name:{0},Salary:{1} ", txtEmployeeName.Text, txtEmployeeSalary.Text)
                    });

                    Trs.Complete();
                }

                txtStatus.Text = String.Format("Success.");
            }
            catch (Exception ex)
            {
                txtStatus.Text = String.Format("Error {0}", ex.Message);
            }
        }
Exemplo n.º 2
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                var TS = new EmployeeSalaryClient();
                using (TransactionScope Trs = new TransactionScope())
                {
                    TS.CreateEmployee(new Employee()
                    {
                        EName   = txtEmployeeName.Text,
                        ESalary = double.Parse(txtEmployeeSalary.Text)
                    });

                    TS.CreateSalaryHistory(new SalaryHistory()
                    {
                        ESalary = double.Parse(txtEmployeeSalary.Text),
                        StDate  = DateTime.Now,
                        EdDate  = null
                    });
                    Trs.Complete();
                }
            }
            catch (Exception)
            {
            }
        }