Exemplo n.º 1
0
        public string SaveUpdateOutputUnit(PrdOutputUnit OutputUnitInfo, vmCmnParameters objcmnParam)
        {
            string result = string.Empty;

            using (TransactionScope transaction = new TransactionScope())
            {
                GenericFactory_EF_OutputUnit = new PrdOutputUnit_EF();
                long MainId = 0; string CustomNo = string.Empty, OutputNos = string.Empty;
                var  UOutputUnit = new PrdOutputUnit();
                try
                {
                    if (OutputUnitInfo.OutputID > 0)
                    {
                        UOutputUnit             = GenericFactory_EF_OutputUnit.GetAll().Where(x => x.OutputID == OutputUnitInfo.OutputID).FirstOrDefault();
                        UOutputUnit.OutputNo    = OutputUnitInfo.OutputNo;
                        UOutputUnit.OutputName  = OutputUnitInfo.OutputName;
                        UOutputUnit.ProcessID   = OutputUnitInfo.ProcessID;
                        UOutputUnit.Description = OutputUnitInfo.Description;

                        UOutputUnit.CompanyID = objcmnParam.loggedCompany;
                        UOutputUnit.UpdateBy  = objcmnParam.loggeduser;
                        UOutputUnit.UpdateOn  = DateTime.Now;
                        UOutputUnit.UpdatePc  = HostService.GetIP();
                        //OutputNos = UOutputUnit.OutputNo;
                    }
                    else
                    {
                        MainId = Convert.ToInt16(GenericFactory_EF_OutputUnit.getMaxID("PrdOutputUnit"));
                        //CustomNo = GenericFactory_EF_OutputUnit.getCustomCode(objcmnParam.menuId, DateTime.Now, objcmnParam.loggedCompany, 1, 1);
                        //if (CustomNo == null || CustomNo == "")
                        //{
                        //    OutputNos = MainId.ToString();
                        //}
                        //else
                        //{
                        //    OutputNos = CustomNo;
                        //}

                        UOutputUnit = new PrdOutputUnit()
                        {
                            OutputID    = (int)MainId,
                            OutputNo    = OutputUnitInfo.OutputNo,//OutputNos.ToString(),
                            OutputName  = OutputUnitInfo.OutputName,
                            ProcessID   = OutputUnitInfo.ProcessID,
                            Description = OutputUnitInfo.Description,
                            IsDeleted   = false,

                            CompanyID = objcmnParam.loggedCompany,
                            CreateBy  = objcmnParam.loggeduser,
                            CreateOn  = DateTime.Now,
                            CreatePc  = HostService.GetIP()
                        };
                    }


                    if (OutputUnitInfo.OutputID > 0)
                    {
                        GenericFactory_EF_OutputUnit.Update(UOutputUnit);
                        GenericFactory_EF_OutputUnit.Save();
                    }
                    else
                    {
                        GenericFactory_EF_OutputUnit.Insert(UOutputUnit);
                        GenericFactory_EF_OutputUnit.Save();
                        GenericFactory_EF_OutputUnit.updateMaxID("PrdOutputUnit", Convert.ToInt64(MainId));
                        GenericFactory_EF_OutputUnit.updateCustomCode(objcmnParam.menuId, DateTime.Now, objcmnParam.loggedCompany, 1, 1);
                    }

                    transaction.Complete();
                    result = OutputUnitInfo.OutputNo;
                }
                catch (Exception e)
                {
                    e.ToString();
                    result = "";
                }
            }
            return(result);
        }