Exemple #1
0
 public int Add()
 {
     using (var context = new RedSeaEntities())
     {
         var designation = new tblDesignation()
         {
             Designation = this.designation
         };
         context.tblDesignations.Add(designation);
         context.SaveChanges();
         this.id = designation.Id;
     }
     return(this.id);
 }
Exemple #2
0
        public bool Delete()
        {
            bool result = false;

            using (var context = new RedSeaEntities())
            {
                var designation = context.tblDesignations.SingleOrDefault(i => i.Id == this.id);
                if (designation != null)
                {
                    context.tblDesignations.Remove(designation);
                    context.SaveChanges();
                    result = true;
                }
            }
            return(result);
        }
Exemple #3
0
        private void SaveNew()
        {
            // check validation first
            if (!dxValidationProvider1.Validate())
            {
                return;
            }

            using (var context = new RedSeaEntities())
            {
                tblFTE currentFte = new tblFTE();

                currentFte.FirstName    = Classes.Logic.CleanString(firstNameTextEdit.Text, 1);
                currentFte.LastName     = Classes.Logic.CleanString(lastNameTextEdit.Text, 1);
                currentFte.Username     = usernameTextEdit.Text;
                currentFte.Designation  = Convert.ToInt32(positionLookUpEdit.EditValue);
                currentFte.Team         = Convert.ToInt32(teamLookUpEdit.EditValue);
                currentFte.HireDate     = Convert.ToDateTime(hireDateDateEdit.EditValue);
                currentFte.Active       = (statusComboBoxEdit.SelectedIndex == 0) ? true : false;
                currentFte.Email        = emailTextEdit.Text;
                currentFte.Code         = codeTextEdit.Text;
                currentFte.FingerPrint  = fingerprintTextEdit.Text;
                currentFte.DirectReport = Convert.ToInt64(directReportLookUpEdit.EditValue);
                currentFte.Phone        = phoneTextEdit.Text;
                currentFte.Cisco        = ciscoTextEdit.Text;
                currentFte.PC           = Convert.ToInt32(pcLookUpEdit.EditValue);
                currentFte.Authority    = Convert.ToString(authorityLookUpEdit.EditValue);
                currentFte.Notes        = notesMemoEdit.Text;
                currentFte.PassKey      = "12345";
                if (photoPictureEdit.Image != Resources.images__1_)
                {
                    currentFte.Photo = RedSea24.Classes.Logic.ImageToByteArray(photoPictureEdit.Image);
                }

                context.tblFTEs.Add(currentFte);
                context.SaveChanges();
                this.employeeId = currentFte.Id;
                SaveLanguages();
                SaveSkills();
                SavePrograms();
                this.employeeCollectionView.GetDataSource();
                this.parent.ShowMessage("Saved", "New employee has been added successfully!");
            }
        }
Exemple #4
0
        private void SavePrograms()
        {
            using (var context = new RedSeaEntities())
            {
                // delete old rows
                var oldPrograms = context.tblLinkSystems
                                  .Where(b => b.FTE == this.employeeId);

                context.tblLinkSystems.RemoveRange(oldPrograms);

                // add new rows
                for (var i = 0; i < programsCheckedComboBoxEdit.Properties.Items.Count; i++)
                {
                    if (programsCheckedComboBoxEdit.Properties.Items[i].CheckState == CheckState.Checked)
                    {
                        tblLinkSystem newProgram = new tblLinkSystem();
                        newProgram.FTE     = this.employeeId;
                        newProgram.cSystem = Convert.ToInt32(programsCheckedComboBoxEdit.Properties.Items[i].Value);
                        context.tblLinkSystems.Add(newProgram);
                    }
                }
                context.SaveChanges();
            }
        }
Exemple #5
0
        private void SaveSkills()
        {
            using (var context = new RedSeaEntities())
            {
                // delete old rows
                var oldSkills = context.tblLinkSkills
                                .Where(b => b.FTE == this.employeeId);

                context.tblLinkSkills.RemoveRange(oldSkills);

                // add new rows
                for (var i = 0; i < skillsCheckedComboBoxEdit.Properties.Items.Count; i++)
                {
                    if (skillsCheckedComboBoxEdit.Properties.Items[i].CheckState == CheckState.Checked)
                    {
                        tblLinkSkill newSkill = new tblLinkSkill();
                        newSkill.FTE   = this.employeeId;
                        newSkill.Skill = Convert.ToInt32(skillsCheckedComboBoxEdit.Properties.Items[i].Value);
                        context.tblLinkSkills.Add(newSkill);
                    }
                }
                context.SaveChanges();
            }
        }
Exemple #6
0
        private void SaveLanguages()
        {
            using (var context = new RedSeaEntities())
            {
                // delete old rows
                var oldLanguages = context.tblLinkLanguages
                                   .Where(b => b.FTE == this.employeeId);

                context.tblLinkLanguages.RemoveRange(oldLanguages);

                // add new rows
                for (var i = 0; i < languagesCheckedComboBoxEdit.Properties.Items.Count; i++)
                {
                    if (languagesCheckedComboBoxEdit.Properties.Items[i].CheckState == CheckState.Checked)
                    {
                        tblLinkLanguage newLanguage = new tblLinkLanguage();
                        newLanguage.FTE       = this.employeeId;
                        newLanguage.cLanguage = Convert.ToInt32(languagesCheckedComboBoxEdit.Properties.Items[i].Value);
                        context.tblLinkLanguages.Add(newLanguage);
                    }
                }
                context.SaveChanges();
            }
        }