Ejemplo n.º 1
0
        public void InsertInitialFormItems(ICollection <FormItems> formItemList, int msrId)
        {
            using (var context = new MSR_MaxEntities())
            {
                foreach (Domain.FormItems item in formItemList)
                {
                    var tempFormItem = new FormItem
                    {
                        ItemCode  = item.ItemCode,
                        ItemDesc  = item.ItemDesc,
                        Quantity  = Double.Parse(item.Quantity),
                        Unit      = item.Unit,
                        UnitPrice = String.IsNullOrEmpty(item.UnitPrice) ? (double?)null : Convert.ToDouble(item.UnitPrice),
                        Currency  = item.Currency,
                        ROS_Date  = item.ROSDate,
                        Comments  = item.Comments,
                        MSRId     = msrId,
                        AC_No     = item.ACNo
                    };

                    context.FormItems.Add(tempFormItem);
                }
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        internal void UpdateMSRNeedReview(int msrId, String stateFlag)
        {
            using (var context = new MSR_MaxEntities())
            {
                var msr_db = context.MSRs.Find(msrId);
                if (msr_db != null)
                {
                    msr_db.StateFlag = stateFlag;

                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 3
0
        public void UpdateMSRWaitForApproval(int msrId, String path, String commentFromPath, DateTime approvalDate, String stateFlag)
        {
            if (path.Equals("Approve"))
            {
                using (var context = new MSR_MaxEntities())
                {
                    var msr_db = context.MSRs.Find(msrId);
                    if (msr_db != null)
                    {
                        msr_db.Appr_Date = approvalDate;
                        msr_db.StateFlag = stateFlag;

                        context.SaveChanges();
                    }
                }
            }
            else if (path.Equals("Send for Review"))
            {
                using (var context = new MSR_MaxEntities())
                {
                    var msr_db = context.MSRs.Find(msrId);
                    if (msr_db != null)
                    {
                        msr_db.Review_Comment = commentFromPath;
                        msr_db.StateFlag      = stateFlag;

                        context.SaveChanges();
                    }
                }
            }
            else if (path.Equals("Decline"))
            {
                using (var context = new MSR_MaxEntities())
                {
                    var msr_db = context.MSRs.Find(msrId);
                    if (msr_db != null)
                    {
                        msr_db.Decline_Comment = commentFromPath;
                        msr_db.StateFlag       = stateFlag;

                        context.SaveChanges();
                    }
                }
            }
            else
            {
            }
        }
Ejemplo n.º 4
0
        public void DeleteFormItemsByMSRId(String msrId)
        {
            using (var context = new MSR_MaxEntities())
            {
                //Log DB commands to console
                context.Database.Log = Console.WriteLine;

                var msr_db = context.MSRs
                             .Include("FormItems")
                             .Where(x => x.MSRId.ToString().Equals(msrId))
                             .First();

                var formItemsToDelete = msr_db.FormItems;
                context.FormItems.RemoveRange(formItemsToDelete);
                context.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        public void InsertIntialMSR(Domain.ApproverInfo approverInfo, String project, String vwl, String comments, String budgetYear, String bpNo, String afe, String sugVendor, String contactVendor, DateTime reqDate)
        {
            using (var context = new MSR_MaxEntities())
            {
                //Log DB commands to console
                context.Database.Log = Console.WriteLine;

                //First obtain referenced users
                var usr_RO = context.Usrs.Find(BusinessAPI.BusinessSingleton.Instance.userInfo_EF.UserId);
                var usr_CA = context.Usrs.Find(Int32.Parse(approverInfo.UserId));

                //Initialize new MSR
                var tempMSR = new MSR
                {
                    Project         = project,
                    WVL             = vwl,
                    Comments        = comments,
                    BudgetYear      = Int32.Parse(budgetYear),
                    BP_No           = bpNo,
                    AFE             = afe,
                    SugVendor       = sugVendor,
                    ContactVendor   = contactVendor,
                    Usr_RO          = usr_RO,
                    Usr_CA          = usr_CA,
                    Req_Date        = reqDate,
                    PUR_Comment     = "",
                    Decline_Comment = "",
                    Review_Comment  = "",
                    StateFlag       = Domain.WorkFlowTrace.WAIT_FOR_APPROVAL
                };

                //Adds the newly created MSR
                context.MSRs.Add(tempMSR);
                context.SaveChanges();

                //Gets the just inserted MSR
                int MSRId = tempMSR.MSRId;

                //Attaches the FormItems to that MSR just created
                InsertInitialFormItems(BusinessAPI.BusinessSingleton.Instance.formItemListCreateMSR, MSRId);
            }
        }