Ejemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            holidaysDto objHoliday = new holidaysDto();

            objHoliday.d_Date      = dtFechaAdd.Value.Date;
            objHoliday.i_Year      = DateTime.Now.Year;
            objHoliday.v_Reason    = txtMotivoAdd.Text;
            objHoliday.i_IsDeleted = (int)SiNo.NO;

            if (Accion == Actualizar)
            {
                objHoliday.v_HolidayId = holidayId;

                bool result = false;
                using (new LoadingClass.PleaseWait(this.Location, "Actualizando..."))
                {
                    result = _holidayBL.UpdateHoliday(objHoliday);
                }


                if (!result)
                {
                    MessageBox.Show("Sucedió un error al actualizar, por favor vuelva a intentar.", "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                gbUpdateAdd.Enabled = false;
                LimpiarCampos();
            }
            else if (Accion == Agregar)
            {
                bool result = false;
                using (new LoadingClass.PleaseWait(this.Location, "Insertando..."))
                {
                    result = _holidayBL.AddHoliday(objHoliday, Globals.ClientSession.i_CurrentExecutionNodeId);
                }

                if (!result)
                {
                    MessageBox.Show("Sucedió un error al agregar, por favor vuelva a intentar.", "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                gbUpdateAdd.Enabled = false;
                LimpiarCampos();
            }

            BindingGrid();
        }
Ejemplo n.º 2
0
        public bool AddHoliday(holidaysDto dataHoliday, int nodeId)
        {
            try
            {
                SigesoftEntitiesModel cnx = new SigesoftEntitiesModel();
                string newId = Common.Utils.GetNewId(nodeId, Utils.GetNextSecuentialId(nodeId, 51), "FR");
                dataHoliday.v_HolidayId = newId;
                holidays entityHolidays = holidaysAssembler.ToEntity(dataHoliday);

                cnx.AddToholidays(entityHolidays);

                return(cnx.SaveChanges() > 0);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool UpdateHoliday(holidaysDto dataHoliday)
        {
            try
            {
                SigesoftEntitiesModel cnx = new SigesoftEntitiesModel();

                var objHoliday = cnx.holidays.Where(x => x.v_HolidayId == dataHoliday.v_HolidayId).FirstOrDefault();

                objHoliday.i_Year   = dataHoliday.i_Year;
                objHoliday.d_Date   = dataHoliday.d_Date;
                objHoliday.v_Reason = dataHoliday.v_Reason;

                return(cnx.SaveChanges() > 0);
            }
            catch (Exception)
            {
                return(false);
            }
        }