Esempio n. 1
0
 public string InsertItem(MNRequestMain o, OrderStatus status, WFMain w)
 {
     using (TransactionScope transaction = new TransactionScope())
     {
         try
         {
             if (o.ID.Length == 0 || o.ID == null)
             {
                 o.ID = Guid.NewGuid().ToString();
             }
             if (o.Description == null)
             {
                 o.Description = "";
             }
             if (o.Reason == null)
             {
                 o.Reason = "";
             }
             if (o.MNRequestMainDetails != null)
             {
                 int sequence = 0;
                 foreach (MNRequestMainDetail i in o.MNRequestMainDetails)
                 {
                     sequence                += 1;
                     i.DetailID               = Guid.NewGuid().ToString();
                     i.RequestMainID          = o.ID;
                     i.ItemNo                 = Convert.ToInt16(GetItemNo(sequence));
                     i.PurchaseQuantity       = 0;
                     i.PurchaseEstimateAmount = 0;
                 }
             }
             db.MNRequestMains.Add(o);
             if (status == OrderStatus.SENDING)
             {
                 db.WFMains.Add(w);
             }
             db.SaveChanges();
             transaction.Complete();
             return(o.ID);
         }
         catch (Exception)
         {
             transaction.Dispose();
         }
     }
     return("");
 }
Esempio n. 2
0
        public bool UpdateEndWorkFlow(string OrderCode, string DocumentTypeName, string MainDetailID, string comments, string DelegateID, int?DelegateUserID)
        {
            bool _result = false;

            // -- Update WF Main - Update isFinished = 1
            WFMain WFM = new WFMain()
            {
                OrderCode  = OrderCode,
                isFinished = 1
            };
            // -- Update WF Main Detail -Update IsFinished = 1,CheckDate,Comments
            WFMainDetail WFMD = new WFMainDetail()
            {
                MainDetailID = MainDetailID,
                isFinished   = 1,
                CheckDate    = DateTime.Now,
                Comment      = comments,
                Temp1        = "0",                                                        // -- Add reject status into Temp1 Column. 0: Dont have reject. 1: Reject
                Temp2        = DelegateUserID == 0 ? "" : DelegateUserID.ToString(),       // -- store Userid who was delegated.
                Temp3        = "",
                DelegateID   = DelegateID == null || DelegateID == "" ? null : DelegateID, // -- store DelegateID of WFDelegate table
            };

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    switch (DocumentTypeName)
                    {
                    case "DEVICEREGISTRATION":
                        DeviceRegistration o = new DeviceRegistration()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new DeviceRegistrationManager().UpdateStatus(o, i => i.Status);
                        break;

                    case "HARDWAREREQUIREMENT":
                        HardwareRequirement h = new HardwareRequirement()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new HardwareRequirementManager().UpdateStatus(h, i => i.Status);
                        break;

                    case "SECURITYAREA":
                        ExportItem e = new ExportItem()
                        {
                            OrderCode = OrderCode, Status = (int)FEA_SABusinessLogic.ExportItemManager.OrderStatus.CHECKED
                        };
                        _result = new FEA_SABusinessLogic.ExportItemManager().UpdateStatus(e, i => i.Status);
                        break;

                    case "GENERALAFFAIR":
                        GAItem ga = new GAItem()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_GABusinessLogic.GAItemManager().UpdateStatus(ga, i => i.Status);
                        break;

                    //Added by Tony (2017-02-08)
                    case "ACCESSORYOUT":
                        ERPDocument erp = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erp, i => i.Status);
                        break;

                    case "FABRICOUT":
                        ERPDocument erpf = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpf, i => i.Status);
                        break;

                    case "FABRICMOVEOUT":
                        ERPDocument erpfm = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpfm, i => i.Status);
                        break;

                    case "FABRICMOVEOUTMULTI":
                        ERPDocument erpfmm = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpfmm, i => i.Status);
                        break;

                    case "ACCESSORYMOVEOUT":
                        ERPDocument erpa = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpa, i => i.Status);
                        break;

                    case "ACCESSORYMOVEOUTMULTI":
                        ERPDocument erpam = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpam, i => i.Status);
                        break;

                    case "FABRICDEVELOPOUT":
                        ERPDocument erpdf = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpdf, i => i.Status);
                        break;

                    case "ACCESSORYDEVELOPOUT":
                        ERPDocument erpda = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpda, i => i.Status);
                        break;

                    case "DEVELOPPRODUCT":
                        ERPDocument erpdp = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpdp, i => i.Status);
                        break;

                    case "SUGGESTRUINOUT":
                        ERPDocument suggestruinout = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(suggestruinout, i => i.Status);
                        break;

                    case "MAINTENANCE":
                        MNRequestMain mnr = new MNRequestMain()
                        {
                            OrderCode = OrderCode, Status = 3
                        };
                        _result = new FEA_BusinessLogic.Maintenance.MaintenanceManager().UpdateStatus(mnr, i => i.Status);
                        break;

                    default:
                        break;
                    }
                    _result = new WFMainManager().UpdateItem(WFM, i => i.OrderCode, i => i.isFinished);
                    _result = new WFMainDetailManager().UpdateItem(WFMD, i => i.MainDetailID, i => i.isFinished, i => i.CheckDate, i => i.Comment, i => i.Temp1, i => i.Temp2, i => DelegateID);
                    if (_result)
                    {
                        scope.Complete();
                    }
                    else
                    {
                        scope.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    _result = false;
                    scope.Dispose();
                }
            }
            return(_result);
        }
Esempio n. 3
0
        public bool RejectDocument(string OrderCode, string MainDetailID, string DocumentTypeName, string comments, int CurrentApproverID, string MainID, int CreateUserID, string DelegateID, int?DelegateUserID, Boolean?IsAdminReject = false)
        {
            bool _result = false;

            WFMainDetail WFMDInsert = new WFMainDetail()
            {
                MainDetailID = Guid.NewGuid().ToString(),
                MainID       = MainID,
                NodeID       = "",
                DelegateID   = null,
                PostUserID   = CurrentApproverID,  // CheckUserID
                CheckUserID  = CreateUserID,
                isFinished   = 0,
                Comment      = (IsAdminReject == true)?comments:"",
                Temp1        = "1", // -- Add reject status into Temp1 Column. 0: Dont have reject. 1: Reject
                Temp2        = ""
            };

            if (IsAdminReject == true)
            {
                WFMDInsert.CheckDate = DateTime.Now;
            }


            WFMainDetail WFMUpdate = new WFMainDetail()
            {
                MainDetailID = MainDetailID,
                isFinished   = 1,
                CheckDate    = DateTime.Now,
                Comment      = (IsAdminReject == true) ? "" : comments,
                Temp2        = DelegateUserID == 0 ? "" : DelegateUserID.ToString(),      // -- store Userid who was delegated.
                DelegateID   = DelegateID == "" || DelegateID == null ? null : DelegateID // -- store DelegateID of WFDelegate table
            };


            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    switch (DocumentTypeName)
                    {
                    case "DEVICEREGISTRATION":
                        DeviceRegistration o = new DeviceRegistration()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new DeviceRegistrationManager().UpdateStatus(o, i => i.Status);
                        break;

                    case "HARDWAREREQUIREMENT":
                        HardwareRequirement h = new HardwareRequirement()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new HardwareRequirementManager().UpdateStatus(h, i => i.Status);
                        break;

                    case "SECURITYAREA":
                        ExportItem e = new ExportItem()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_SABusinessLogic.ExportItemManager().UpdateStatus(e, i => i.Status);
                        break;

                    case "GENERALAFFAIR":
                        GAItem ga = new GAItem()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_GABusinessLogic.GAItemManager().UpdateStatus(ga, i => i.Status);
                        break;

                    //Added by Tony (2017-02-08)
                    case "ACCESSORYOUT":
                        ERPDocument erpf = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpf, i => i.Status);
                        break;

                    case "FABRICOUT":
                        ERPDocument erp = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erp, i => i.Status);
                        break;

                    case "FABRICMOVEOUT":
                        ERPDocument erpfm = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpfm, i => i.Status);
                        break;

                    case "FABRICMOVEOUTMULTI":
                        ERPDocument erpfmm = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpfmm, i => i.Status);
                        break;

                    case "ACCESSORYMOVEOUT":
                        ERPDocument erpa = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpa, i => i.Status);
                        break;

                    case "ACCESSORYMOVEOUTMULTI":
                        ERPDocument erpam = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpam, i => i.Status);
                        break;

                    case "FABRICDEVELOPOUT":
                        ERPDocument erpdf = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpdf, i => i.Status);
                        break;

                    case "ACCESSORYDEVELOPOUT":
                        ERPDocument erpda = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erpda, i => i.Status);
                        break;

                    case "DEVELOPPRODUCT":
                        ERPDocument erppd = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(erppd, i => i.Status);
                        break;

                    case "SUGGESTRUINOUT":
                        ERPDocument suggestruinout = new ERPDocument()
                        {
                            OrderCode = OrderCode, Status = 4
                        };
                        _result = new FEA_BusinessLogic.ERP.Order().UpdateStatus(suggestruinout, i => i.Status);
                        break;

                    case "MAINTENANCE":
                        MNRequestMain mnr = new MNRequestMain()
                        {
                            OrderCode = OrderCode, Status = 4, ConfirmID = CurrentApproverID, ConfirmDate = DateTime.Now
                        };
                        _result = new FEA_BusinessLogic.Maintenance.MaintenanceManager().UpdateStatus(mnr, i => i.Status, i => i.ConfirmID, i => i.ConfirmDate);
                        break;

                    default:
                        break;
                    }


                    if (IsAdminReject == true)
                    {
                        // Update IsFinish of WFMain when the Order Status from Checked to Returned
                        WFMain wfMain = new WFMain()
                        {
                            MainID = MainID, OrderCode = OrderCode, isFinished = 0
                        };
                        _result = new WFMainManager().UpdateItem(wfMain, o => o.isFinished);
                    }

                    if (IsAdminReject == false)
                    {
                        _result = new WFMainDetailManager().UpdateItem(WFMUpdate, i => i.MainDetailID, i => i.isFinished, i => i.CheckDate, i => i.Comment, i => i.Temp2, i => i.DelegateID);
                    }

                    _result = new WFMainDetailManager().InsertItem(WFMDInsert);
                    bool isReturn = UpdateWFMainDeatailReject(MainID);
                    if (_result && isReturn)
                    {
                        scope.Complete();
                    }
                    else
                    {
                        scope.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    _result = false;
                    scope.Dispose();
                }
            }
            return(_result);
        }