示例#1
0
        //private void AddNewMakeAndModel(Scale entity)
        //{
        //    LOVLibrary lib = new LOVLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
        //    if (!string.IsNullOrEmpty(entity.Make))
        //    {
        //        // Make does not exists in database.
        //        LOV makeLOV = lib.GetByValue(entity.Make);
        //        if (makeLOV == null)
        //        {
        //            LOVTypeLibrary libType = new LOVTypeLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
        //            LOVType modelLOVType = libType.GetByLOVType("Make");
        //            makeLOV = new LOV()
        //            {
        //                Active_Ind = true,
        //                LOV_Active = true,
        //                Parent_Type_ID = modelLOVType.ID,
        //                LOV_Value = entity.Make,
        //                LOV_Display_Value = entity.Make,
        //                LOVType = modelLOVType,
        //                Parent = new LOV()
        //            };
        //            lib.Add(makeLOV);
        //        }
        //    }

        //    if (!string.IsNullOrEmpty(entity.Model) && !string.IsNullOrEmpty(entity.Make))
        //    {
        //        // Model does not exists in database.
        //        LOV modelLOV = lib.GetByValueAndParent(entity.Model, entity.Make);
        //        if (modelLOV == null)
        //        {
        //            LOVTypeLibrary libType = new LOVTypeLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
        //            LOVType modelLOVType = libType.GetByLOVType("Model");
        //            LOV parentModelLOV = lib.GetByValue(entity.Make);
        //            modelLOV = new LOV()
        //            {
        //                Active_Ind = true,
        //                LOV_Active = true,
        //                Parent_Type_ID = modelLOVType.ID,
        //                LOV_Value = entity.Model,
        //                LOV_Display_Value = entity.Model,
        //                LOVType = modelLOVType,
        //                Parent = parentModelLOV
        //            };
        //            lib.Add(modelLOV);
        //        }
        //    }
        //}

        public bool GetCustomerImageRefIds(int scaleId, out string thumbImage1, out string thumbImage2, out string photo, out string signatureImage, out string licenseImage, out string vehicleImageRefId, out string cashCardImageRefId)
        {
            thumbImage1 = thumbImage2 = photo = signatureImage = licenseImage = vehicleImageRefId = cashCardImageRefId = string.Empty;
            ScaleAttachments thumb1Attach        = null;
            ScaleAttachments thumb2Attach        = null;
            ScaleAttachments photoAttach         = null;
            ScaleAttachments signatureAttach     = null;
            ScaleAttachments dlLicenseAttach     = null;
            ScaleAttachments vehicleImageAttach  = null;
            ScaleAttachments cashCardImageAttach = null;

            if (scaleId > 0)
            {
                ScaleAttachmentsLibrary lib = new ScaleAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                thumb1Attach        = lib.GetAttachmentsByRefTypeAndParentId(EnumAttachmentRefType.Thumbprint1, scaleId).FirstOrDefault();
                thumb2Attach        = lib.GetAttachmentsByRefTypeAndParentId(EnumAttachmentRefType.Thumbprint2, scaleId).FirstOrDefault();
                photoAttach         = lib.GetAttachmentsByRefTypeAndParentId(EnumAttachmentRefType.Customer, scaleId).FirstOrDefault();
                signatureAttach     = lib.GetAttachmentsByRefTypeAndParentId(EnumAttachmentRefType.Signature, scaleId).FirstOrDefault();
                dlLicenseAttach     = lib.GetAttachmentsByRefTypeAndParentId(EnumAttachmentRefType.DriverLicense, scaleId).FirstOrDefault();
                vehicleImageAttach  = lib.GetAttachmentsByRefTypeAndParentId(EnumAttachmentRefType.Vehicle, scaleId).FirstOrDefault();
                cashCardImageAttach = lib.GetAttachmentsByRefTypeAndParentId(EnumAttachmentRefType.CashCard, scaleId).FirstOrDefault();
            }
            else
            {
                if (Session["ScaleAttachments"] != null)
                {
                    IEnumerable <ScaleAttachments> resultList = (IList <ScaleAttachments>)Session["ScaleAttachments"];
                    thumb1Attach        = resultList.FirstOrDefault(a => a.Ref_Type == (int)EnumAttachmentRefType.Thumbprint1);
                    thumb2Attach        = resultList.FirstOrDefault(a => a.Ref_Type == (int)EnumAttachmentRefType.Thumbprint2);
                    photoAttach         = resultList.FirstOrDefault(a => a.Ref_Type == (int)EnumAttachmentRefType.Customer);
                    signatureAttach     = resultList.FirstOrDefault(a => a.Ref_Type == (int)EnumAttachmentRefType.Signature);
                    dlLicenseAttach     = resultList.FirstOrDefault(a => a.Ref_Type == (int)EnumAttachmentRefType.DriverLicense);
                    vehicleImageAttach  = resultList.FirstOrDefault(a => a.Ref_Type == (int)EnumAttachmentRefType.Vehicle);
                    cashCardImageAttach = resultList.FirstOrDefault(a => a.Ref_Type == (int)EnumAttachmentRefType.CashCard);
                }
            }

            if (thumb1Attach != null)
            {
                thumbImage1 = thumb1Attach.Document_RefId.ToString();
            }

            if (thumb2Attach != null)
            {
                thumbImage2 = thumb2Attach.Document_RefId.ToString();
            }

            if (photoAttach != null)
            {
                photo = photoAttach.Document_RefId.ToString();
            }

            if (signatureAttach != null)
            {
                signatureImage = signatureAttach.Document_RefId.ToString();
            }

            if (dlLicenseAttach != null)
            {
                licenseImage = dlLicenseAttach.Document_RefId.ToString();
            }

            if (vehicleImageAttach != null)
            {
                vehicleImageRefId = vehicleImageAttach.Document_RefId.ToString();
            }

            if (cashCardImageAttach != null)
            {
                cashCardImageRefId = cashCardImageAttach.Document_RefId.ToString();
            }

            return(true);
        }