예제 #1
0
 public bool Update(Hire obj)
 {
     try
     {
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
예제 #2
0
        //public void SetDelete(int hireId)
        //{
        //    var query = _db.Hires.FirstOrDefault(x => x.HireId == hireId);
        //    if (query != null)
        //    {
        //        _db.Hires.DeleteOnSubmit(query);

        //        _db.SubmitChanges();
        //    }
        //}

        public int Add(Hire obj)
        {
            try
            {
                _db.Hires.InsertOnSubmit(obj);
                _db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                return(-1);
            }
            return(_db.Hires.Max(x => x.HireId));
        }
예제 #3
0
 public bool Delete(Hire obj)
 {
     try
     {
         _db.Hires.DeleteOnSubmit(obj);
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
예제 #4
0
        protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            // Save or Modify
            if (e.Item.Text == "TempSave" || e.Item.Text == "Request")
            {
                if (IsValid)
                {
                    var cObj = new CHire();
                    var obj  = cObj.Get(Id);

                    // new one
                    if (obj == null)
                    {
                        obj             = new Erp2016.Lib.Hire();
                        obj.CreatedId   = Convert.ToInt32(CurrentUserId);
                        obj.CreatedDate = DateTime.Now;
                        int newIndex = Convert.ToInt32(cObj.Add(obj).ToString());
                        obj = cObj.Get(newIndex);
                        ViewState["NewIndex"] = newIndex;
                    }
                    else
                    {
                        obj.UpdatedId         = Convert.ToInt32(CurrentUserId);
                        obj.UpdatedDate       = DateTime.Now;
                        ViewState["NewIndex"] = obj.HireId.ToString();
                    }

                    obj.ApprovalId   = CurrentUserId;
                    obj.ApprovalDate = DateTime.Now;


                    if (e.Item.Text == "TempSave")
                    {
                        obj.ApprovalStatus = null;
                    }
                    else
                    {
                        var cApprovalHistory = new CApprovalHistory();
                        cApprovalHistory.DelApprovalHistory((int)CConstValue.Approval.Hire, Convert.ToInt32(ViewState["NewIndex"]));

                        // approve request
                        var approval       = new CApproval();
                        var approvalResult = approval.ApproveRequstCreate((int)CConstValue.Approval.Hire, CurrentUserId, Convert.ToInt32(ViewState["NewIndex"]));
                        if (approvalResult > 0)
                        {
                            obj.ApprovalStatus = approvalResult;
                        }
                        else
                        {
                            ShowMessage("Failed");
                            return;
                        }

                        new CMail().SendMail(CConstValue.Approval.Hire, CConstValue.MailStatus.ToApproveUser, Convert.ToInt32(ViewState["NewIndex"]), string.Empty, CurrentUserId);
                    }

                    obj.Department = Convert.ToInt32(RadComboBoxDepartment.SelectedValue);
                    obj.Genre      = Convert.ToInt32(RadComboBoxGenre.SelectedValue);
                    obj.Condition  = Convert.ToInt32(RadComboBoxCondition.SelectedValue);

                    obj.JobTitle                            = RadTextBoxJobTitle.Text;
                    obj.ReasonForHiring                     = RadTextBoxReasonForHiring.Text;
                    obj.DutiesAndResponsibilities           = RadEditorDuties.Text;
                    obj.SkillsAndExperienceAndQualification = RadEditorSkills.Text;
                    obj.SalaryOrWage                        = RadTextBoxSalary.Text;
                    obj.EmploymentCategory                  = RadTextBoxEmployment.Text;
                    obj.HoursOrDaysOfWork                   = RadTextBoxHours.Text;
                    obj.AdditionalComments                  = RadEditorAdditional.Text;

                    cObj.Update(obj);

                    // save other tables
                    RunClientScript("Close();");
                }
                else
                {
                    ShowMessage("Failed");
                }
            }
            // Revise
            else if (e.Item.Text == "Revise")
            {
                RunClientScript("ShowApprovalReviseWindow('" + Id + "');");
            }
            // Approval
            else if (e.Item.Text == "Approve")
            {
                RunClientScript("ShowApprovalWindow('" + Id + "');");
            }
            // Reject
            else if (e.Item.Text == "Reject")
            {
                RunClientScript("ShowApprovalRejectWindow('" + Id + "');");
            }
            // Print
            else if (e.Item.Text == "Print")
            {
                RunClientScript("ShowPrint();");
            }
            // Cancel
            else if (e.Item.Text == "Cancel")
            {
                RunClientScript("ShowApprovalCancelWindow('" + Id + "');");
            }
            // close
            else if (e.Item.Text == "Close")
            {
                RunClientScript("Close();");
            }
        }