Exemplo n.º 1
0
        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="id">string</param>
        public void Delete(string id, string userUpdate)
        {
            if (id != null)
            {
                // Get current group in dbContext
                Interview objDb = GetById(id);

                if (objDb != null)
                {
                    //Delete  e form
                    EformDao eDao = new EformDao();
                    eDao.DeleteEform(objDb.InterviewFormId, objDb.CandidateId.ToString(), (int)Constants.PersonType.Candidate, (int)objDb.Round,userUpdate);
                    // Set delete info
                    objDb.DeleteFlag = true;
                    objDb.UpdatedDate = DateTime.Now;
                    objDb.UpdatedBy = userUpdate;

                    new InterviewLogDao().WriteLogForInterview(null, objDb, ELogAction.Delete);
                    // Submit changes to dbContext

                    dbContext.Interviews.DeleteOnSubmit(objDb);
                    dbContext.SubmitChanges();

                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Insert colection control id and value on form into database,if not exits then addnew else then update
        /// Rule to define ControlID is:
        /// 1.If control is Checkbox then start with "CheckBox" letter and after is number(ex:CheckBox1).
        /// 2.If control is Textbox then start with "TextBox" letter and after is number(ex:TextBox1).
        /// ....
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public Message SaveControlToDB(FormCollection form, bool isInsert)
        {
            Message msg = null;
            List<EForm_Detail> detailList = new List<EForm_Detail>();
            string EformID = form.Get("Hidden1");

            for (int i = 0; i < form.Count; i++)
            {
                string controlID = form.GetKey(i);
                bool flag = false;
                foreach (String str in control)
                {
                    if (controlID.StartsWith(str))
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    CRM.Models.EForm_Detail detailItem = new Models.EForm_Detail();
                    string value = form.Get(controlID);
                    if (controlID.StartsWith("CheckBox"))
                    {
                        value = value.Split(Convert.ToChar(","))[0];
                    }
                    detailItem.ControlID = controlID;
                    detailItem.Value = value;
                    detailItem.EFormID = Int32.Parse(EformID);
                    detailList.Add(detailItem);

                }
            }
            CRM.Models.EformDao efDao = new EformDao();
            msg = isInsert == true ? efDao.Inser(detailList) : efDao.Update(detailList);

            return msg;
        }
Exemplo n.º 3
0
        public Message Update(PerformanceReview pr, string eformMasterId)
        {
            Message msg = null;
            EmployeeDao empDao = new EmployeeDao();
            EformDao eformDao = new EformDao();

            DbTransaction trans = null;
            try
            {
                if (dbContext.Connection.State == System.Data.ConnectionState.Closed)
                {
                    dbContext.Connection.Open();
                }
                trans = dbContext.Connection.BeginTransaction();
                dbContext.Transaction = trans;
                EForm oldEform = null;
                PerformanceReview prDB = GetById(pr.ID);
                //Update eform
                EForm eform = new EForm();
                if (!pr.EForm.MasterID.Equals(eformMasterId))
                {
                    //Delete old eform
                    oldEform = pr.EForm;
                    //Insert new eform
                    eform.MasterID = eformMasterId;
                    eform.PersonID = pr.EmployeeID;
                    eform.PersonType = (int)Constants.PersonType.Employee;
                    eform.FormIndex = 1;
                    eform.CreateDate = DateTime.Now;
                    eform.CreatedBy = pr.CreatedBy;
                    dbContext.EForms.InsertOnSubmit(eform);
                    dbContext.SubmitChanges();
                    pr.EForm = eform;
                }
                //Update performance Review
                prDB.AssignID = pr.AssignID;
                prDB.EForm = pr.EForm;
                prDB.AssignRole = pr.AssignRole;
                prDB.CCEmail = pr.CCEmail;
                prDB.InvolveDate = pr.InvolveDate;
                prDB.InvolveID = pr.InvolveID;
                prDB.InvolveResolution = pr.InvolveResolution;
                prDB.InvolveRole = pr.InvolveRole;
                prDB.NextReviewDate = pr.NextReviewDate;
                prDB.PRDate = pr.PRDate;
                prDB.UpdateDate = DateTime.Now;
                prDB.UpdatedBy = pr.UpdatedBy;
                prDB.WFResolutionID = pr.WFResolutionID;
                if(oldEform!=null)
                    dbContext.EForms.DeleteOnSubmit(oldEform);
                dbContext.SubmitChanges();
                msg = new Message(MessageConstants.I0001, MessageType.Info,
                    "Performance Review \"" + pr.ID + "\"", "updated");
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Insert performance review
        /// </summary>
        /// <param name="pr">PerformanceReview</param>
        /// <param name="eformMasterId">string</param>
        /// <returns>Message</returns>
        public Message Insert(PerformanceReview pr, string eformMasterId)
        {
            Message msg = null;
            EmployeeDao empDao = new EmployeeDao();
            EformDao eformDao = new EformDao();
            DbTransaction trans = null;
            try
            {
                if (dbContext.Connection.State == System.Data.ConnectionState.Closed)
                {
                    dbContext.Connection.Open();
                }
                trans = dbContext.Connection.BeginTransaction();
                dbContext.Transaction = trans;

                EForm eform = new EForm();
                eform.MasterID = eformMasterId;
                eform.PersonID = pr.EmployeeID;
                eform.PersonType = (int)Constants.PersonType.Employee;
                eform.FormIndex = 1;
                eform.CreateDate = DateTime.Now;
                eform.CreatedBy = pr.CreatedBy;
                dbContext.EForms.InsertOnSubmit(eform);
                dbContext.SubmitChanges();

                pr.ID = GetNewPrId(pr.EmployeeID);
                pr.EFormID = eform.ID;
                dbContext.PerformanceReviews.InsertOnSubmit(pr);

                msg = new Message(MessageConstants.I0001, MessageType.Info, "PR", "setup");
                dbContext.SubmitChanges();
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }