Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (PrincipalHelper.IsUserSuperAdmin())
                {
                    ComboBoxVloge.DataBind();
                    ComboBoxNadrejeni.DataBind();
                }
                else
                {
                    ASPxPageControl1.TabPages.FindByName("UserCredentialData").ClientVisible = false;
                    ASPxPageControl1.TabPages.FindByName("UserCredentialData").Enabled       = false;
                }

                if (action == (int)Enums.UserAction.Edit || action == (int)Enums.UserAction.Delete)
                {
                    if (employeeID > 0)
                    {
                        model = CheckModelValidation(GetDatabaseConnectionInstance().GetEmployee(employeeID));

                        if (model != null)
                        {
                            GetEmployeeDataProviderInstance().SetEmployeeFullModel(model);
                            FillForm();
                        }
                    }
                }
                else if (action == (int)Enums.UserAction.Add)//acion ADD
                {
                    ComboBoxVloge.SelectedIndex = 0;
                }
                UserActionConfirmBtnUpdate(btnConfirmPopUp, action, true);
            }
        }
Beispiel #2
0
        public IHttpActionResult PostNewEmployeeData([FromBody] object employeeData)
        {
            EmployeeFullModel model = null;

            try
            {
                model = JsonConvert.DeserializeObject <EmployeeFullModel>(employeeData.ToString());

                if (model != null)
                {
                    if (model.idOsebe > 0)//We update existing record in DB
                    {
                        employeeRepo.SaveEmployee(model);
                    }
                    else // We add and save new recod to DB
                    {
                        employeeRepo.SaveEmployee(model, false);
                    }
                }
                else
                {
                    return(BadRequest("Cannot convert posted data to Employee entity instance!"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message + "\r\n" + ex.Source));
            }

            return(Ok(model));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ComboBoxVloga.DataBind();

                if (action == (int)Enums.UserAction.Edit || action == (int)Enums.UserAction.Delete)
                {
                    if (employeeID > 0)
                    {
                        model = CheckModelValidation(GetDatabaseConnectionInstance().GetEmployee(employeeID));

                        if (model != null)
                        {
                            GetEmployeeDataProviderInstance().SetEmployeeFullModel(model);
                            FillForm();
                        }
                    }
                }

                if (!PrincipalHelper.IsUserSuperAdmin())
                {
                    ComboBoxVloga.Enabled                 = false;
                    ComboBoxVloga.BackColor               = Color.LightGray;
                    ComboBoxVloga.ForeColor               = Color.White;
                    txtDelovnoMesto.ReadOnly              = true;
                    txtDelovnoMesto.BackColor             = Color.LightGray;
                    ASPxDateEditDatumZaposlitve.ReadOnly  = true;
                    ASPxDateEditDatumZaposlitve.Enabled   = false;
                    ASPxDateEditDatumZaposlitve.BackColor = Color.LightGray;
                }

                UserActionConfirmBtnUpdate(btnConfirm, action);
            }
        }
        public WebResponseContentModel <EmployeeFullModel> SaveEmployeeChanges(EmployeeFullModel newData)
        {
            WebResponseContentModel <EmployeeFullModel> model = new WebResponseContentModel <EmployeeFullModel>();

            try
            {
                model.Content = newData;
                model         = PostWebRequestData <WebResponseContentModel <EmployeeFullModel> >(WebServiceHelper.SaveEmployeeChanges(), "post", model);
            }
            catch (Exception ex)
            {
                model.ValidationErrorAppSide = ConcatenateExceptionMessage(ex);
            }

            return(model);
        }
Beispiel #5
0
        private bool AddOrEditEntityObject(bool add = false)
        {
            if (add)
            {
                model = new EmployeeFullModel();

                model.idOsebe   = 0;
                model.tsIDOsebe = PrincipalHelper.GetUserPrincipal().ID;
                model.ts        = DateTime.Now;
            }
            else if (model == null && !add)
            {
                model = GetEmployeeDataProviderInstance().GetFullEmployeeModel();
            }

            if (PrincipalHelper.IsUserSuperAdmin())
            {
                model.Email          = txtEmail.Text;
                model.UporabniskoIme = txtUporabniskoIme.Text;
                model.Geslo          = txtGeslo.Text;
                model.idVloga        = CommonMethods.ParseInt(ComboBoxVloge.Value);
                //model.idNadrejeni = CommonMethods.ParseInt(ComboBoxNadrejeni.Value) > 0 ? CommonMethods.ParseInt(ComboBoxNadrejeni.Value) : (int?)null;
                // 22.01.2020, Boris popravek
                model.idNadrejeni = CommonMethods.ParseInt(ComboBoxNadrejeni.Value) > 0 ? CommonMethods.ParseInt(ComboBoxNadrejeni.Value) : 1;
            }

            model.Ime             = txtIme.Text;
            model.Priimek         = txtPriimek.Text;
            model.Naslov          = txtNaslov.Text;
            model.DatumRojstva    = ASPxDateEditDatumRojstva.Date;
            model.Email           = txtEmail.Text;
            model.DatumZaposlitve = ASPxDateEditDatumZaposlitve.Date;
            model.DelovnoMesto    = txtDelovnoMesto.Text;
            model.Zunanji         = CommonMethods.ParseInt(ComboBoxZunanji.SelectedItem.Value);
            model.TelefonGSM      = txtTelefon.Text;

            EmployeeFullModel newModel = CheckModelValidation(GetDatabaseConnectionInstance().SaveEmployeeChanges(model));

            if (newModel != null)//If new record is added we need to refresh aspxgridview. We add new record to session model.
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public IHttpActionResult SaveEventMeetingData([FromBody] object eventMeetingData)
        {
            WebResponseContentModel <EventMeetingModel> model = null;

            try
            {
                model = JsonConvert.DeserializeObject <WebResponseContentModel <EventMeetingModel> >(eventMeetingData.ToString());

                if (model.Content != null)
                {
                    if (model.Content.DogodekSestanekID > 0)//We update existing record in DB
                    {
                        eventRepo.SaveEventMeeting(model.Content);
                    }
                    else // We add and save new recod to DB
                    {
                        model.Content.DogodekSestanekID = eventRepo.SaveEventMeeting(model.Content, false);
                    }

                    EmployeeFullModel tmp = employeeRepo.GetEmployeeByID(model.Content.tsIDOsebe);
                    if (tmp != null)
                    {
                        model.Content.ImeInPriimekOsebe = tmp.Ime + " " + tmp.Priimek;
                    }

                    model.IsRequestSuccesful = true;
                }
                else
                {
                    model.IsRequestSuccesful = false;
                    model.ValidationError    = ValidationExceptionError.res_09;
                }
            }
            catch (Exception ex)
            {
                model.IsRequestSuccesful = false;
                model.ValidationError    = ExceptionValidationHelper.GetExceptionSource(ex);
                return(Json(model));
            }

            return(Json(model));
        }
        private bool AddOrEditEntityObject(bool add = false)
        {
            if (model == null && !add)
            {
                model = GetEmployeeDataProviderInstance().GetFullEmployeeModel();
            }

            if (!model.UporabniskoIme.Equals(txtUporabniskoIme.Text) || !model.Geslo.Equals(txtGesloVnos.Text))//If username or password was changed wee need to sign out!
            {
                pasOrUsernameChanged = true;
            }

            if (PrincipalHelper.IsUserSuperAdmin())
            {
                model.idVloga         = CommonMethods.ParseInt(ComboBoxVloga.Value);
                model.DatumZaposlitve = ASPxDateEditDatumZaposlitve.Date;
                model.DelovnoMesto    = txtDelovnoMesto.Text;
            }

            model.Ime            = txtIme.Text;
            model.Priimek        = txtPriimek.Text;
            model.Naslov         = txtNaslov.Text;
            model.DatumRojstva   = ASPxDateEditDatumRojstva.Date;
            model.Email          = txtEmail.Text;
            model.TelefonGSM     = txtTelefon.Text;
            model.Email          = txtEmail.Text;
            model.UporabniskoIme = txtUporabniskoIme.Text;
            model.Geslo          = txtGesloVnos.Text;

            EmployeeFullModel newModel = CheckModelValidation(GetDatabaseConnectionInstance().SaveEmployeeChanges(model));

            if (newModel != null)//If new record is added we need to refresh aspxgridview. We add new record to session model.
            {
                uploadedImage.Src = newModel.ProfileImage.Replace(AppDomain.CurrentDomain.BaseDirectory, "\\");

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
        public int SaveEmployee(EmployeeFullModel model, bool updateRecord = true)
        {
            try
            {
                Osebe_NOZ          record    = new Osebe_NOZ();
                OsebeNadrejeni_NOZ nadrejeni = new OsebeNadrejeni_NOZ();

                record.OsebaID         = model.idOsebe;
                record.Naslov          = model.Naslov;
                record.Email           = model.Email;
                record.DelovnoMesto    = model.DelovnoMesto;
                record.DatumZaposlitve = model.DatumZaposlitve;
                record.Ime             = model.Ime;
                record.Priimek         = model.Priimek;
                record.DatumRojstva    = model.DatumRojstva;
                record.UporabniskoIme  = model.UporabniskoIme;
                record.Geslo           = model.Geslo;
                record.TelefonGSM      = model.TelefonGSM;
                record.Zunanji         = model.Zunanji;
                record.ProfileImage    = model.ProfileImage;

                record.VlogaID        = model.idVloga;
                record.tsUpdate       = DateTime.Now;
                record.tsUpdateUserID = model.tsIDOsebe;
                record.ts             = model.ts.Equals(DateTime.MinValue) ? (DateTime?)null : model.ts;
                record.tsIDOsebe      = model.tsIDOsebe;
                record.NOZDostop      = model.NOZDostop;

                /*record.EmailGeslo = model.EmailGeslo;
                 * record.EmailSifriranjeSSL = model.EmailSifriranjeSSL;
                 * record.EmailStreznik = model.EmailStreznik;
                 * record.EmailVrata = model.EmailVrata > 0 ? model.EmailVrata : (int?)null;*/
                record.Podpis        = model.Podpis;
                record.PantheonUsrID = model.PantheonUsrID;

                if (record.OsebaID == 0)
                {
                    record.ts        = DateTime.Now;
                    record.tsIDOsebe = model.tsIDOsebe;

                    context.Osebe_NOZ.Add(record);
                    context.SaveChanges();
                }
                else
                {
                    if (updateRecord)
                    {
                        Osebe_NOZ original = context.Osebe_NOZ.Where(e => e.OsebaID == record.OsebaID).FirstOrDefault();
                        context.Entry(original).CurrentValues.SetValues(record);

                        context.SaveChanges();
                    }
                }

                if (model.NadrejeniID > 0)
                {
                    var supervisorExistForEmployee = context.OsebeNadrejeni_NOZ.Where(osn => osn.OsebaID == record.OsebaID).FirstOrDefault();

                    nadrejeni.OsebaID     = record.OsebaID;
                    nadrejeni.NadrejeniID = model.NadrejeniID;

                    if (supervisorExistForEmployee != null)
                    {
                        OsebeNadrejeni_NOZ originalNadrejeni = context.OsebeNadrejeni_NOZ.Where(e => e.OsebaID == record.OsebaID).FirstOrDefault();
                        nadrejeni.OsebeNadrejeniID = originalNadrejeni.OsebeNadrejeniID;


                        context.Entry(originalNadrejeni).CurrentValues.SetValues(nadrejeni);
                    }
                    else
                    {
                        nadrejeni.ts        = DateTime.Now;
                        nadrejeni.tsIDosebe = model.tsIDOsebe;
                        context.OsebeNadrejeni_NOZ.Add(nadrejeni);
                    }
                    context.SaveChanges();
                }

                return(record.OsebaID);
            }
            catch (Exception ex)
            {
                throw new Exception(ValidationExceptionError.res_08, ex);
            }
        }
        public int SaveEmployee(EmployeeFullModel model, bool updateRecord = true)
        {
            try
            {
                Osebe          record    = new Osebe();
                OsebeNadrejeni nadrejeni = new OsebeNadrejeni();

                record.idOsebe         = model.idOsebe;
                record.Naslov          = model.Naslov;
                record.Email           = model.Email;
                record.DelovnoMesto    = model.DelovnoMesto;
                record.DatumZaposlitve = model.DatumZaposlitve;
                record.Ime             = model.Ime;
                record.Priimek         = model.Priimek;
                record.DatumRojstva    = model.DatumRojstva;
                record.UporabniskoIme  = model.UporabniskoIme;
                record.Geslo           = model.Geslo;
                record.TelefonGSM      = model.TelefonGSM;
                record.Zunanji         = model.Zunanji;
                record.ProfileImage    = model.ProfileImage;

                if (model.idVloga <= 0)
                {
                    record.idVloga = null;
                }
                else
                {
                    record.idVloga = model.idVloga;
                }

                if (record.idOsebe == 0)
                {
                    record.ts        = DateTime.Now;
                    record.tsIDOsebe = model.tsIDOsebe;

                    context.Osebe.Add(record);
                    context.SaveChanges();
                }
                else
                {
                    if (updateRecord)
                    {
                        Osebe original = context.Osebe.Where(e => e.idOsebe == record.idOsebe).FirstOrDefault();
                        context.Entry(original).CurrentValues.SetValues(record);

                        context.SaveChanges();
                    }
                }

                if (model.NadrejeniID > 0)
                {
                    var supervisorExistForEmployee = context.OsebeNadrejeni.Where(osn => osn.idOseba == record.idOsebe).FirstOrDefault();

                    nadrejeni.idOseba     = record.idOsebe;
                    nadrejeni.idNadrejeni = model.NadrejeniID;

                    if (supervisorExistForEmployee != null)
                    {
                        OsebeNadrejeni originalNadrejeni = context.OsebeNadrejeni.Where(e => e.idOseba == record.idOsebe).FirstOrDefault();
                        nadrejeni.OsebeNadrejeniID = originalNadrejeni.OsebeNadrejeniID;

                        context.Entry(originalNadrejeni).CurrentValues.SetValues(nadrejeni);
                    }
                    else
                    {
                        nadrejeni.ts        = DateTime.Now;
                        nadrejeni.tsIDosebe = model.tsIDOsebe;
                        context.OsebeNadrejeni.Add(nadrejeni);
                    }
                    context.SaveChanges();
                }

                return(record.idOsebe);
            }
            catch (Exception ex)
            {
                throw new Exception(ValidationExceptionError.res_08, ex);
            }
        }
 /// <summary>
 /// Add employeeFullModel instance to session
 /// </summary>
 /// <param name="model"></param>
 public void SetEmployeeFullModel(EmployeeFullModel model)
 {
     AddValueToSession(Enums.EmployeeSession.EmployeeFullModel, model);
 }