protected override void ExcuteSelf() { try { _OverWork.DiyProcess = _OverWorkDiyProcessUtility.GetOverWorkDiyProcessByAccountID(_OverWork.Account.Id); using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { int _CurrentId = _OverWorkDal.InsertOverWork(_OverWork); _OverWork.PKID = _CurrentId; if (_OverWork.Item != null) { foreach (OverWorkItem item in _OverWork.Item) { item.AdjustHour = new UpdateAdjustRestByOverWork(item, _OverWork.Account.Id).GetItemAdjustHour(); int itemid = _OverWorkDal.InsertOverWorkItem(_CurrentId, item); if (item.Status == RequestStatus.Submit) { OverWorkFlow flow = new OverWorkFlow(0, _OverWork.Account, _OverWork.SubmitDate, _OverWork.Reason, item.Status, 1); _OverWorkDal.InsertOverWorkFlow(itemid, flow); } } } ts.Complete(); } } catch { HrmisUtility.ThrowException(HrmisUtility._DbError); } new OverWorkMailAndPhoneDelegate().SubmitOperation(_OverWork.PKID, _CCList); }
/// <summary> /// </summary> public static bool CancelOneItem(OverWorkItem item, Account account, string remark, IOverWork dalOverWork, OverWorkDiyProcessUtility OverWorkDiyProcessUtility) { item = dalOverWork.GetOverWorkItemByItemID(item.ItemID); bool valide = RequestStatus.CanCancelStatus(item.Status); if (valide) { using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { dalOverWork.UpdateOverWorkItemStatusByItemID(item.ItemID, RequestStatus.Cancelled); OverWorkFlow OverWorkFlow = new OverWorkFlow(0, account, DateTime.Now, remark, RequestStatus.Cancelled, 1); dalOverWork.InsertOverWorkFlow(item.ItemID, OverWorkFlow); ts.Complete(); } } return(valide); }
/// <summary> /// </summary> public bool ApproveOneItem(OverWorkItem item, bool isAgree, Account account, OverWork overWork, string remark, IOverWork dalOverWork, OverWorkDiyProcessUtility overWorkDiyProcessUtility, bool isAdjust, bool isChangeAdjust, decimal adjustHour, out Account nextOperator) { if (!isAdjust) { adjustHour = 0; } nextOperator = null; item = dalOverWork.GetOverWorkItemByItemID(item.ItemID); item.AdjustHour = adjustHour; bool valide = RequestStatus.CanApproveStatus(item.Status) && account.Id == overWorkDiyProcessUtility.GetNextOperator(overWork.DiyProcess, item, overWork.Account.Id).Id; if (valide) { if (!isAgree) { using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { RequestStatus requestStatus = RequestUtility.GetStatus(item.Status, isAgree, 1); dalOverWork.UpdateOverWorkItemStatusByItemID(item.ItemID, requestStatus); item.Status = requestStatus; if (isChangeAdjust) { dalOverWork.UpdateOverWorkItemAdjustByItemID(item.ItemID, isAdjust, adjustHour); item.Adjust = isAdjust; } dalOverWork.InsertOverWorkFlow(item.ItemID, new OverWorkFlow(0, account, DateTime.Now, remark, requestStatus, -1)); new UpdateAdjustRestByOverWork(item, overWork.Account.Id).Excute(); ts.Complete(); } nextOperator = null; } else { int step = overWorkDiyProcessUtility.GetNextStep(item.OverWorkFlow, overWork.DiyProcess); RequestStatus requestStatus = RequestUtility.GetStatus(item.Status, isAgree, step); OverWorkFlow OverWorkFlow = new OverWorkFlow(0, account, DateTime.Now, remark, requestStatus, step); using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { dalOverWork.InsertOverWorkFlow(item.ItemID, OverWorkFlow); dalOverWork.UpdateOverWorkItemStatusByItemID(item.ItemID, requestStatus); item.Status = requestStatus; if (isChangeAdjust) { dalOverWork.UpdateOverWorkItemAdjustByItemID(item.ItemID, isAdjust, adjustHour); item.Adjust = isAdjust; } new UpdateAdjustRestByOverWork(item, overWork.Account.Id).Excute(); ts.Complete(); } nextOperator = overWorkDiyProcessUtility.GetNextOperator(overWork.DiyProcess, step, overWork.Account.Id); } } return(valide); }