Ejemplo n.º 1
0
        public void Add(PayDayCodeUnit oUnit)
        {
            SqlCommand oCommand = new SqlCommand();

            oCommand.Connection = this.Connection;
            oCommand.CommandType  = CommandType.StoredProcedure;
            oCommand.CommandText = "SP_TRANS_INSERT_PAYDAYCODE";
            oCommand.Parameters.Add(new SqlParameter("@PayDayCode", oUnit.Code));
            oCommand.Parameters.Add(new SqlParameter("@Remarks", oUnit.Description));

            oCommand.Parameters.Add(new SqlParameter("@DateCreated", oUnit.DateCreated));
            oCommand.Parameters.Add(new SqlParameter("@CreatedBy", oUnit.CreatedBy));
            oCommand.Parameters.Add(new SqlParameter("@DateModified", oUnit.DateModified));
            oCommand.Parameters.Add(new SqlParameter("@ModifiedBy", oUnit.ModifiedBy));
            oCommand.ExecuteNonQuery();

            foreach (DataRow oRow in oUnit.LineItems.Rows)
            {
                SqlCommand oLineCommand = new SqlCommand();

                oLineCommand.Connection = this.Connection;
                oLineCommand.CommandType = CommandType.StoredProcedure;
                oLineCommand.CommandText = "SP_TRANS_INSERT_PAYDAYCODE_LINES";

                oLineCommand.Parameters.Add(new SqlParameter("@PayDayCode", oUnit.Code));
                oLineCommand.Parameters.Add(new SqlParameter("@Interval", oRow["Interval"].ToString()));
                oLineCommand.Parameters.Add(new SqlParameter("@DayWeekNo", oRow["DayWeekNo"].ToString()));
                oLineCommand.ExecuteNonQuery();
            }
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            PayDayCodeManager oManager = new PayDayCodeManager();
            PayDayCodeUnit oUnit = new PayDayCodeUnit();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            oUnit.Code = txtCode.Text;
            oUnit.Description = txtDescription.Text;

            oUnit.DateCreated = Convert.ToDateTime(dtCreated.EditValue);
            oUnit.CreatedBy = txtCreatedBy.Text;
            oUnit.DateModified = Convert.ToDateTime(dtModified.EditValue);
            oUnit.ModifiedBy = txtModifiedBy.Text;

            oUnit.LineItems = this.LineItems;
            oManager.Add(oUnit);

            oManager.Close();

            this.MainMenu.RefreshMainMenu();
        }