public bool Update(ApprovalHistory obj) { try { _db.SubmitChanges(); } catch (Exception ex) { Debug.Print(ex.Message); return(false); } return(true); }
public bool Delete(ApprovalHistory obj) { try { _db.ApprovalHistories.DeleteOnSubmit(obj); _db.SubmitChanges(); } catch (Exception ex) { Debug.Print(ex.Message); return(false); } return(true); }
public int Add(ApprovalHistory obj) { try { _db.ApprovalHistories.InsertOnSubmit(obj); _db.SubmitChanges(); } catch (Exception ex) { Debug.Print(ex.Message); return(-1); } return(_db.ApprovalHistories.Max(x => x.ApprovalHistoryId)); }
public int ApproveRequstCreate(int approveType, int myId, int menuSeqId) { try { var qryMy = _db.Approvals.Where(q => q.IsActive && q.ApproveType == approveType && q.UserId == myId).FirstOrDefault(); if (qryMy != null) { //기안자 결재(approvalhistory add) var cInqry = new CApprovalHistory(); var inqry = new ApprovalHistory(); inqry.ApproveType = approveType; inqry.MenuSeqId = menuSeqId; inqry.ApprovalUser = qryMy.UserId; inqry.ApprovalDate = DateTime.Now; inqry.IsApprovalRequest = true; inqry.ApprovalStep = qryMy.Supervisor == null ? new CGlobal().GetApprovalValue(approveType) : 1; // auto approved or requested inqry.CreatedId = myId; inqry.CreatedDate = DateTime.Now; cInqry.Add(inqry); if (qryMy.Supervisor != null) { int?supervisorId = Convert.ToInt32(qryMy.Supervisor); var flg = true; while (supervisorId != null) { //결재자들 결재 생성 var super = _db.Approvals.Where(q => q.IsActive && q.ApproveType == approveType && q.UserId == supervisorId).FirstOrDefault(); var cSubInqry = new CApprovalHistory(); var subInqry = new ApprovalHistory(); subInqry.ApproveType = approveType; subInqry.MenuSeqId = menuSeqId; subInqry.ApprovalUser = super.UserId; subInqry.CreatedId = myId; subInqry.CreatedDate = DateTime.Now; if (flg) { subInqry.IsApprovalRequest = true; flg = false; } cSubInqry.Add(subInqry); supervisorId = super.Supervisor; } } return((int)inqry.ApprovalStep); } } catch (Exception ex) { Debug.Print(ex.Message); } return(-1); }