Пример #1
0
        public ActionResult Insert(MSupplier viewModel, FormCollection formCollection)
        {
            RefAddress address = new RefAddress();

            TransferFormValuesTo(address, formCollection);
            address.SetAssignedIdTo(Guid.NewGuid().ToString());
            address.CreatedDate = DateTime.Now;
            address.CreatedBy   = User.Identity.Name;
            address.DataStatus  = EnumDataStatus.New.ToString();
            _refAddressRepository.Save(address);

            UpdateNumericData(viewModel, formCollection);
            MSupplier mSupplierToInsert = new MSupplier();

            TransferFormValuesTo(mSupplierToInsert, viewModel);
            mSupplierToInsert.SetAssignedIdTo(viewModel.Id);
            mSupplierToInsert.CreatedDate = DateTime.Now;
            mSupplierToInsert.CreatedBy   = User.Identity.Name;
            mSupplierToInsert.DataStatus  = EnumDataStatus.New.ToString();

            mSupplierToInsert.AddressId = address;

            _mSupplierRepository.Save(mSupplierToInsert);

            return(Content("success"));
        }
Пример #2
0
        public ActionResult Update(MSupplier viewModel, FormCollection formCollection)
        {
            UpdateNumericData(viewModel, formCollection);
            MSupplier mSupplierToUpdate = _mSupplierRepository.Get(viewModel.Id);

            TransferFormValuesTo(mSupplierToUpdate, viewModel);
            mSupplierToUpdate.ModifiedDate = DateTime.Now;
            mSupplierToUpdate.ModifiedBy   = User.Identity.Name;
            mSupplierToUpdate.DataStatus   = EnumDataStatus.Updated.ToString();

            RefAddress address = mSupplierToUpdate.AddressId;

            TransferFormValuesTo(address, formCollection);
            address.ModifiedDate = DateTime.Now;
            address.ModifiedBy   = User.Identity.Name;
            address.DataStatus   = EnumDataStatus.Updated.ToString();

            _mSupplierRepository.Update(mSupplierToUpdate);


            bool isSave = false;

            try
            {
                _mSupplierRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mSupplierRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Пример #3
0
 private void TransferFormValuesTo(RefAddress address, FormCollection formCollection)
 {
     address.AddressLine1 = formCollection["AddressLine1"];
     address.AddressLine2 = formCollection["AddressLine2"];
     address.AddressLine3 = formCollection["AddressLine3"];
     address.AddressPhone = formCollection["AddressPhone"];
 }
Пример #4
0
        public ActionResult Insert(MWarehouse viewModel, FormCollection formCollection)
        {
            RefAddress address = new RefAddress();

            address.AddressLine1 = formCollection["AddressLine1"];
            address.AddressLine2 = formCollection["AddressLine2"];
            address.AddressLine3 = formCollection["AddressLine3"];
            address.AddressPhone = formCollection["AddressPhone"];
            address.AddressCity  = formCollection["AddressCity"];
            address.SetAssignedIdTo(Guid.NewGuid().ToString());
            _refAddressRepository.Save(address);

            MWarehouse mWarehouseToInsert = new MWarehouse();

            TransferFormValuesTo(mWarehouseToInsert, viewModel);
            mWarehouseToInsert.EmployeeId   = _mEmployeeRepository.Get(formCollection["EmployeeId"]);
            mWarehouseToInsert.CostCenterId = _mCostCenterRepository.Get(formCollection["CostCenterId"]);
            mWarehouseToInsert.SetAssignedIdTo(viewModel.Id);
            mWarehouseToInsert.CreatedDate = DateTime.Now;
            mWarehouseToInsert.CreatedBy   = User.Identity.Name;
            mWarehouseToInsert.DataStatus  = EnumDataStatus.New.ToString();
            mWarehouseToInsert.AddressId   = address;
            _mWarehouseRepository.Save(mWarehouseToInsert);

            //save account persediaan barang
            MAccountRef accountRef = new MAccountRef();

            accountRef.SetAssignedIdTo(Guid.NewGuid().ToString());
            accountRef.ReferenceId    = mWarehouseToInsert.Id;
            accountRef.ReferenceTable = EnumReferenceTable.Warehouse.ToString();
            accountRef.ReferenceType  = EnumReferenceTable.Warehouse.ToString();
            accountRef.AccountId      = _mAccountRepository.Get(formCollection["AccountId"]);
            _mAccountRefRepository.Save(accountRef);

            //save account pemakaian barang
            accountRef = new MAccountRef();
            accountRef.SetAssignedIdTo(Guid.NewGuid().ToString());
            accountRef.ReferenceId    = mWarehouseToInsert.Id;
            accountRef.ReferenceTable = EnumReferenceTable.WarehouseUsing.ToString();
            accountRef.ReferenceType  = EnumReferenceTable.WarehouseUsing.ToString();
            accountRef.AccountId      = _mAccountRepository.Get(formCollection["UsingAccountId"]);
            _mAccountRefRepository.Save(accountRef);

            try
            {
                _mWarehouseRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mWarehouseRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Пример #5
0
        public ActionResult Update(MSupplier viewModel, FormCollection formCollection)
        {
            UpdateNumericData(viewModel, formCollection);
            MSupplier mSupplierToUpdate = _mSupplierRepository.Get(viewModel.Id);

            TransferFormValuesTo(mSupplierToUpdate, viewModel);
            mSupplierToUpdate.ModifiedDate = DateTime.Now;
            mSupplierToUpdate.ModifiedBy   = User.Identity.Name;
            mSupplierToUpdate.DataStatus   = EnumDataStatus.Updated.ToString();

            RefAddress address = mSupplierToUpdate.AddressId;

            TransferFormValuesTo(address, formCollection);
            address.ModifiedDate = DateTime.Now;
            address.ModifiedBy   = User.Identity.Name;
            address.DataStatus   = EnumDataStatus.Updated.ToString();

            _mSupplierRepository.Update(mSupplierToUpdate);


            bool        isSave     = false;
            MAccountRef accountRef = GetAccountRef(mSupplierToUpdate.Id);

            if (accountRef == null)
            {
                accountRef = new MAccountRef();
                accountRef.SetAssignedIdTo(Guid.NewGuid().ToString());
                isSave = true;
            }
            accountRef.ReferenceId    = mSupplierToUpdate.Id;
            accountRef.ReferenceTable = EnumReferenceTable.Supplier.ToString();
            accountRef.ReferenceType  = EnumReferenceTable.Supplier.ToString();
            accountRef.AccountId      = _mAccountRepository.Get(formCollection["AccountId"]);
            if (isSave)
            {
                _mAccountRefRepository.Save(accountRef);
            }
            else
            {
                _mAccountRefRepository.Update(accountRef);
            }
            try
            {
                _mSupplierRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mSupplierRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Пример #6
0
        public ActionResult Update(MPartner viewModel, RefAddress addressVm, FormCollection formCollection)
        {
            try
            {
                _mPartnerRepository.DbContext.BeginTransaction();

                MPartner partner = _mPartnerRepository.Get(viewModel.Id);

                partner.PartnerName   = viewModel.PartnerName;
                partner.PartnerDesc   = viewModel.PartnerDesc;
                partner.PartnerStatus = viewModel.PartnerStatus;

                partner.ModifiedDate = DateTime.Now;
                partner.ModifiedBy   = User.Identity.Name;
                partner.DataStatus   = EnumDataStatus.Updated.ToString();

                RefAddress address = partner.AddressId;

                if (address == null)
                {
                    address = new RefAddress();

                    partner.AddressId = address;

                    address.AddressLine1 = addressVm.AddressLine1;
                    address.SetAssignedIdTo(Guid.NewGuid().ToString());
                    address.CreatedDate = DateTime.Now;
                    address.CreatedBy   = User.Identity.Name;
                    address.DataStatus  = EnumDataStatus.New.ToString();
                    _refAddressRepository.Save(address);
                }
                else
                {
                    address.AddressLine1 = addressVm.AddressLine1;
                    address.ModifiedDate = DateTime.Now;
                    address.ModifiedBy   = User.Identity.Name;
                    address.DataStatus   = EnumDataStatus.Updated.ToString();
                    _refAddressRepository.Update(address);
                }

                _mPartnerRepository.Update(partner);

                _mPartnerRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mPartnerRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("Data Toko Berhasil Diupdate"));
        }
Пример #7
0
        public ActionResult Insert(MSupplier viewModel, FormCollection formCollection)
        {
            try
            {
                _mSupplierRepository.DbContext.BeginTransaction();

                UpdateNumericData(viewModel, formCollection);
                RefAddress address = new RefAddress();
                TransferFormValuesTo(address, formCollection);
                address.SetAssignedIdTo(Guid.NewGuid().ToString());
                address.CreatedDate = DateTime.Now;
                address.CreatedBy   = User.Identity.Name;
                address.DataStatus  = EnumDataStatus.New.ToString();
                _refAddressRepository.Save(address);

                MSupplier mSupplierToInsert = new MSupplier();
                TransferFormValuesTo(mSupplierToInsert, viewModel);
                mSupplierToInsert.SetAssignedIdTo(viewModel.Id);
                mSupplierToInsert.CreatedDate = DateTime.Now;
                mSupplierToInsert.CreatedBy   = User.Identity.Name;
                mSupplierToInsert.DataStatus  = EnumDataStatus.New.ToString();

                mSupplierToInsert.AddressId = address;

                _mSupplierRepository.Save(mSupplierToInsert);

                MAccountRef accountRef = new MAccountRef();
                accountRef.SetAssignedIdTo(Guid.NewGuid().ToString());
                accountRef.ReferenceId    = mSupplierToInsert.Id;
                accountRef.ReferenceTable = EnumReferenceTable.Supplier.ToString();
                accountRef.ReferenceType  = EnumReferenceTable.Supplier.ToString();
                accountRef.AccountId      = _mAccountRepository.Get(formCollection["AccountId"]);
                accountRef.CreatedDate    = DateTime.Now;
                accountRef.CreatedBy      = User.Identity.Name;
                accountRef.DataStatus     = EnumDataStatus.New.ToString();
                _mAccountRefRepository.Save(accountRef);

                _mSupplierRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mSupplierRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Пример #8
0
        public ActionResult Insert(MCustomer viewModel, FormCollection formCollection)
        {
            RefAddress address = new RefAddress();

            TransferFormValuesTo(address, formCollection);
            address.SetAssignedIdTo(Guid.NewGuid().ToString());
            address.CreatedDate = DateTime.Now;
            address.CreatedBy   = User.Identity.Name;
            address.DataStatus  = EnumDataStatus.New.ToString();
            _refAddressRepository.Save(address);

            RefPerson person = new RefPerson();

            TransferFormValuesTo(person, formCollection);
            person.SetAssignedIdTo(Guid.NewGuid().ToString());
            person.CreatedDate = DateTime.Now;
            person.CreatedBy   = User.Identity.Name;
            person.DataStatus  = EnumDataStatus.New.ToString();
            _refPersonRepository.Save(person);

            UpdateNumericData(viewModel, formCollection);
            MCustomer mCustomerToInsert = new MCustomer();

            TransferFormValuesTo(mCustomerToInsert, viewModel);
            mCustomerToInsert.SetAssignedIdTo(viewModel.Id);
            mCustomerToInsert.CreatedDate = DateTime.Now;
            mCustomerToInsert.CreatedBy   = User.Identity.Name;
            mCustomerToInsert.DataStatus  = EnumDataStatus.New.ToString();

            mCustomerToInsert.AddressId = address;
            mCustomerToInsert.PersonId  = person;

            _mCustomerRepository.Save(mCustomerToInsert);

            try
            {
                _mCustomerRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mCustomerRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Пример #9
0
        public ActionResult Insert(MEmployee viewModel, FormCollection formCollection)
        {
            MEmployee  mEmployeeToInsert = new MEmployee();
            RefPerson  person            = new RefPerson();
            RefAddress address           = new RefAddress();

            TransferFormValuesTo(person, formCollection);
            person.SetAssignedIdTo(Guid.NewGuid().ToString());
            person.CreatedDate = DateTime.Now;
            person.CreatedBy   = User.Identity.Name;
            person.DataStatus  = EnumDataStatus.New.ToString();
            _refPersonRepository.Save(person);

            TransferFormValuesTo(address, formCollection);
            address.SetAssignedIdTo(Guid.NewGuid().ToString());
            address.CreatedDate = DateTime.Now;
            address.CreatedBy   = User.Identity.Name;
            address.DataStatus  = EnumDataStatus.New.ToString();
            _refAddressRepository.Save(address);

            TransferFormValuesTo(mEmployeeToInsert, viewModel);
            mEmployeeToInsert.DepartmentId = _mDepartmentRepository.Get(formCollection["DepartmentId"]);
            mEmployeeToInsert.SetAssignedIdTo(viewModel.Id);
            mEmployeeToInsert.CreatedDate = DateTime.Now;
            mEmployeeToInsert.CreatedBy   = User.Identity.Name;
            mEmployeeToInsert.DataStatus  = EnumDataStatus.New.ToString();

            mEmployeeToInsert.PersonId  = person;
            mEmployeeToInsert.AddressId = address;
            _mEmployeeRepository.Save(mEmployeeToInsert);

            try
            {
                _mEmployeeRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mEmployeeRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("Data Karyawan Berhasil Disimpan"));
        }
Пример #10
0
        public ActionResult Insert(MPartner partnerVM, RefAddress addressVM, MPartner viewModel, FormCollection formCollection)
        {
            //bool isSave = true;
            //MPartner mCompanyToInsert = new MPartner();
            //TransferFormValuesTo(mCompanyToInsert, viewModel);
            MPartner   partner = new MPartner();
            RefAddress address = new RefAddress();

            //save address
            address.AddressLine1 = addressVM.AddressLine1;

            address.SetAssignedIdTo(Guid.NewGuid().ToString());
            address.CreatedDate = DateTime.Now;
            address.CreatedBy   = User.Identity.Name;
            address.DataStatus  = EnumDataStatus.New.ToString();
            _refAddressRepository.Save(address);

            //save partner
            partner.AddressId = address;

            partner.PartnerName   = partnerVM.PartnerName;
            partner.PartnerDesc   = partnerVM.PartnerDesc;
            partner.PartnerStatus = partnerVM.PartnerStatus;

            partner.SetAssignedIdTo(viewModel.Id);
            partner.CreatedDate = DateTime.Now;
            partner.CreatedBy   = User.Identity.Name;
            partner.DataStatus  = EnumDataStatus.New.ToString();

            _mPartnerRepository.Save(partner);

            try
            {
                _mPartnerRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mPartnerRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Пример #11
0
        private void TransferFormValuesTo(RefAddress address, FormCollection formCollection)
        {
            address.AddressLine1    = formCollection["AddressLine1"];
            address.AddressLine2    = formCollection["AddressLine2"];
            address.AddressLine3    = formCollection["AddressLine3"];
            address.AddressPhone    = formCollection["AddressPhone"];
            address.AddressCity     = formCollection["AddressCity"];
            address.AddressRt       = formCollection["AddressRt"];
            address.AddressRw       = formCollection["AddressRw"];
            address.AddressPostCode = formCollection["AddressPostCode"];


            address.AddressIdCardLine1    = formCollection["AddressIdCardLine1"];
            address.AddressIdCardLine2    = formCollection["AddressIdCardLine2"];
            address.AddressIdCardLine3    = formCollection["AddressIdCardLine3"];
            address.AddressIdCardPhone    = formCollection["AddressIdCardPhone"];
            address.AddressIdCardCity     = formCollection["AddressIdCardCity"];
            address.AddressIdCardRt       = formCollection["AddressIdCardRt"];
            address.AddressIdCardRw       = formCollection["AddressIdCardRw"];
            address.AddressIdCardPostCode = formCollection["AddressIdCardPostCode"];
        }
Пример #12
0
        public ActionResult Update(MCustomer viewModel, FormCollection formCollection)
        {
            MCustomer customer = _mCustomerRepository.Get(viewModel.Id);

            TransferFormValuesTo(customer, viewModel);
            customer.ModifiedDate = DateTime.Now;
            customer.ModifiedBy   = User.Identity.Name;
            customer.DataStatus   = EnumDataStatus.Updated.ToString();

            RefAddress address = customer.AddressId;

            TransferFormValuesTo(address, formCollection);
            address.ModifiedDate = DateTime.Now;
            address.ModifiedBy   = User.Identity.Name;
            address.DataStatus   = EnumDataStatus.Updated.ToString();

            RefPerson person = customer.PersonId;

            TransferFormValuesTo(person, formCollection);
            person.ModifiedDate = DateTime.Now;
            person.ModifiedBy   = User.Identity.Name;
            person.DataStatus   = EnumDataStatus.Updated.ToString();

            _mCustomerRepository.Update(customer);

            try
            {
                _mCustomerRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mCustomerRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Пример #13
0
        public ActionResult Insert(MWarehouse viewModel, FormCollection formCollection)
        {
            RefAddress address = new RefAddress();

            address.AddressLine1 = formCollection["AddressLine1"];
            address.AddressLine2 = formCollection["AddressLine2"];
            address.AddressLine3 = formCollection["AddressLine3"];
            address.AddressPhone = formCollection["AddressPhone"];
            address.AddressCity  = formCollection["AddressCity"];
            address.SetAssignedIdTo(Guid.NewGuid().ToString());
            _refAddressRepository.Save(address);

            MWarehouse mWarehouseToInsert = new MWarehouse();

            TransferFormValuesTo(mWarehouseToInsert, viewModel);
            mWarehouseToInsert.EmployeeId = _mEmployeeRepository.Get(formCollection["EmployeeId"]);
            mWarehouseToInsert.SetAssignedIdTo(viewModel.Id);
            mWarehouseToInsert.CreatedDate = DateTime.Now;
            mWarehouseToInsert.CreatedBy   = User.Identity.Name;
            mWarehouseToInsert.DataStatus  = EnumDataStatus.New.ToString();
            mWarehouseToInsert.AddressId   = address;
            _mWarehouseRepository.Save(mWarehouseToInsert);

            try
            {
                _mWarehouseRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mWarehouseRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Пример #14
0
        public static SurveyFormViewModel CreateSurveyFormViewModel(ITLoanSurveyRepository tLoanSurveyRepository, IMEmployeeRepository mEmployeeRepository, IMZoneRepository mZoneRepository, IMPartnerRepository mPartnerRepository, IMDepartmentRepository mDepartmentRepository, string loanSurveyId)
        {
            SurveyFormViewModel viewModel = new SurveyFormViewModel();

            viewModel.CanEditId = true;

            TLoanSurvey loanSurvey = null;
            TLoanUnit   loanUnit   = null;
            RefPerson   person     = new RefPerson();
            RefAddress  address    = new RefAddress();

            if (!string.IsNullOrEmpty(loanSurveyId))
            {
                loanSurvey = tLoanSurveyRepository.Get(loanSurveyId);
                person     = loanSurvey.LoanId.PersonId;
                address    = loanSurvey.LoanId.AddressId;
                if (loanSurvey.LoanId.LoanUnits.Count > 0)
                {
                    loanUnit = loanSurvey.LoanId.LoanUnits[0];
                }
                else
                {
                    loanUnit = new TLoanUnit();
                }

                viewModel.CanEditId = true;
            }
            if (loanSurvey == null)
            {
                TLoan loan = new TLoan();
                loanUnit = new TLoanUnit();
                MCustomer customer = new MCustomer();
                loanSurvey = new TLoanSurvey();
                MZone    zone    = new MZone();
                MPartner partner = new MPartner();

                loanSurvey.LoanId                      = loan;
                loanSurvey.LoanId.CustomerId           = customer;
                loanSurvey.LoanId.CustomerId.PersonId  = person;
                loanSurvey.LoanId.CustomerId.AddressId = address;
                loanSurvey.LoanId.ZoneId               = zone;
                loanSurvey.LoanId.PartnerId            = partner;

                MEmployee emp = new MEmployee();
                loan.SalesmanId  = emp;
                loan.SurveyorId  = emp;
                loan.CollectorId = emp;
                loan.TLSId       = emp;
            }
            viewModel.LoanSurvey = loanSurvey;
            viewModel.LoanUnit   = loanUnit;

            //set asset
            SetAssetCheck(loanSurvey.SurveyNeighborAsset, viewModel);

            //fill gender
            var values = from EnumGender e in Enum.GetValues(typeof(EnumGender))
                         select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.GenderList = new SelectList(values, "Id", "Name", person.PersonGender);

            //get education list
            var edus = from EnumEducation e in Enum.GetValues(typeof(EnumEducation))
                       select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.EducationList = new SelectList(edus, "Id", "Name", person.PersonLastEducation);

            //get married status list
            var merrieds = from EnumMarriedStatus e in Enum.GetValues(typeof(EnumMarriedStatus))
                           select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.MarriedStatusList = new SelectList(merrieds, "Id", "Name", person.PersonMarriedStatus);

            //get religions list
            var religions = from EnumReligion e in Enum.GetValues(typeof(EnumReligion))
                            select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.ReligionList = new SelectList(religions, "Id", "Name", person.PersonReligion);

            //get house owner status list
            var houses = from EnumHouseOwner e in Enum.GetValues(typeof(EnumHouseOwner))
                         select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.HouseOwnerList          = new SelectList(houses, "Id", "Name", address.AddressStatusOwner);
            viewModel.GuarantorHouseOwnerList = new SelectList(houses, "Id", "Name", person.PersonGuarantorHouseOwnerStatus);

            //get neighbor character list
            var neighbors = from EnumNeighborChar e in Enum.GetValues(typeof(EnumNeighborChar))
                            select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.NeighborCharList = new SelectList(neighbors, "Id", "Name", loanSurvey.SurveyNeighbor);

            //get house type list
            var housetypes = from EnumHouseType e in Enum.GetValues(typeof(EnumHouseType))
                             select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.HouseTypeList = new SelectList(housetypes, "Id", "Name", loanSurvey.SurveyHouseType);

            //get known customer list
            var knowcustomers = from EnumKnowCustomer e in Enum.GetValues(typeof(EnumKnowCustomer))
                                select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.KnowCustomerList = new SelectList(knowcustomers, "Id", "Name", loanSurvey.LoanId.LoanIsSalesmanKnownCustomer);

            MEmployee employee = new MEmployee();

            var listSaEmployee = mEmployeeRepository.GetEmployeeByDept(EnumDepartment.SA.ToString());

            listSaEmployee.Insert(0, employee);

            var salesman = from emp in listSaEmployee
                           select new { Id = emp.Id, Name = emp.PersonId != null ? emp.PersonId.PersonName : "-Pilih Salesman-" };

            viewModel.SalesmanList = new SelectList(salesman, "Id", "Id", loanSurvey.LoanId.SalesmanId != null ? loanSurvey.LoanId.SalesmanId.Id : string.Empty);

            var listSuEmployee = mEmployeeRepository.GetEmployeeByDept(EnumDepartment.SU.ToString());

            listSuEmployee.Insert(0, employee);

            var surveyor = from emp in listSuEmployee
                           select new { Id = emp.Id, Name = emp.PersonId != null ? emp.PersonId.PersonName : "-Pilih Surveyor-" };

            viewModel.SurveyorList = new SelectList(surveyor, "Id", "Id", loanSurvey.LoanId.SurveyorId != null ? loanSurvey.LoanId.SurveyorId.Id : string.Empty);

            var listColEmployee = mEmployeeRepository.GetEmployeeByDept(EnumDepartment.COL.ToString());

            listColEmployee.Insert(0, employee);

            var collector = from emp in listColEmployee
                            select new { Id = emp.Id, Name = emp.PersonId != null ? emp.PersonId.PersonName : "-Pilih Kolektor-" };

            viewModel.CollectorList = new SelectList(collector, "Id", "Id", loanSurvey.LoanId.CollectorId != null ? loanSurvey.LoanId.CollectorId.Id : string.Empty);

            var listTlsEmployee = mEmployeeRepository.GetEmployeeByDept(EnumDepartment.TLS.ToString());

            listTlsEmployee.Insert(0, employee);

            var tls = from emp in listTlsEmployee
                      select new { Id = emp.Id, Name = emp.PersonId != null ? emp.PersonId.PersonName : "-Pilih Team Leader-" };

            viewModel.TLSList = new SelectList(tls, "Id", "Id", loanSurvey.LoanId.TLSId != null ? loanSurvey.LoanId.TLSId.Id : string.Empty);

            var   listZone = mZoneRepository.GetAll();
            MZone z        = new MZone();

            z.ZoneName = "-Pilih Wilayah-";
            listZone.Insert(0, z);
            var zones = from zo in listZone
                        select new { Id = zo.Id, Name = zo.ZoneName };

            viewModel.ZoneList = new SelectList(zones, "Id", "Name", loanSurvey.LoanId.ZoneId != null ? loanSurvey.LoanId.ZoneId.Id : string.Empty);

            var      listPartner = mPartnerRepository.GetAll();
            MPartner p           = new MPartner();

            p.PartnerName = "-Pilih Toko-";
            listPartner.Insert(0, p);
            var partners = from prtner in listPartner
                           select new { Id = prtner.Id, Name = prtner.PartnerName };

            viewModel.PartnerList = new SelectList(partners, "Id", "Name", loanSurvey.LoanId.PartnerId != null ? loanSurvey.LoanId.PartnerId.Id : string.Empty);

            const string separator = "|";

            string[] photos = new string[0];//= loanSurvey.LoanId.LoanDesc.Split(separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (!string.IsNullOrEmpty(loanSurvey.LoanId.LoanDesc))
            {
                photos = loanSurvey.LoanId.LoanDesc.Split(separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            }
            viewModel.Photo1 = "~/Content/Images/no_photo104_on.jpg";
            viewModel.Photo2 = "~/Content/Images/no_photo104_on.jpg";
            if (photos.Count() > 0)
            {
                viewModel.Photo1 = photos[0];
            }
            if (photos.Count() > 1)
            {
                viewModel.Photo2 = photos[1];
            }

            return(viewModel);
        }
Пример #15
0
        public static CRFormViewModel CreateCRFormViewModel(ITLoanRepository tLoanRepository, IMEmployeeRepository mEmployeeRepository, string loanCustomerRequestId)
        {
            CRFormViewModel viewModel = new CRFormViewModel();

            viewModel.CanEditId = true;

            TLoan      loan     = null;
            TLoanUnit  loanUnit = null;
            RefPerson  person   = new RefPerson();
            RefAddress address  = new RefAddress();

            if (!string.IsNullOrEmpty(loanCustomerRequestId))
            {
                loan    = tLoanRepository.Get(loanCustomerRequestId);
                person  = loan.PersonId;
                address = loan.AddressId;
                if (loan.LoanUnits.Count > 0)
                {
                    loanUnit = loan.LoanUnits[0];
                }
                else
                {
                    loanUnit = new TLoanUnit();
                }

                viewModel.CanEditId = false;
            }

            if (loan == null)
            {
                MEmployee emp  = new MEmployee();
                MCustomer cust = new MCustomer();

                loan     = new TLoan();
                loanUnit = new TLoanUnit();

                loan.TLSId                = emp;
                loan.CustomerId           = cust;
                loan.CustomerId.PersonId  = person;
                loan.CustomerId.AddressId = address;
            }

            viewModel.Loan     = loan;
            viewModel.LoanUnit = loanUnit;

            if (loan.LoanAdminFee != null)
            {
                if (loan.LoanAdminFee == 25000)
                {
                    viewModel.LoanAdminFee1 = true;
                }
                else if (loan.LoanAdminFee == 50000)
                {
                    viewModel.LoanAdminFee2 = true;
                }
                else if (loan.LoanAdminFee == 75000)
                {
                    viewModel.LoanAdminFee3 = true;
                }
            }

            if (loan.LoanMateraiFee != null)
            {
                viewModel.LoanMateraiFee = true;
            }

            viewModel.Photo1 = "~/Content/Images/no_photo104_on.jpg";
            viewModel.Photo2 = "~/Content/Images/no_photo104_on.jpg";

            if (!string.IsNullOrEmpty(loan.LoanDesc))
            {
                string   separator = "|";
                string[] photos    = loan.LoanDesc.Split(separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (photos.Count() > 0)
                {
                    viewModel.Photo1 = photos[0];
                }
                if (photos.Count() > 1)
                {
                    viewModel.Photo2 = photos[1];
                }
            }

            MEmployee employee = new MEmployee();

            var listTlsEmployee = mEmployeeRepository.GetEmployeeByDept(EnumDepartment.TLS.ToString());

            listTlsEmployee.Insert(0, employee);

            var tls = from emps in listTlsEmployee
                      select new { Id = emps.Id, Name = emps.PersonId != null ? emps.PersonId.PersonName : "-Pilih Team Leader-" };

            viewModel.TLSList = new SelectList(tls, "Id", "Id", loan.TLSId != null ? loan.TLSId.Id : string.Empty);

            var listSaEmployee = mEmployeeRepository.GetEmployeeByDept(EnumDepartment.SA.ToString());

            listSaEmployee.Insert(0, employee);

            var salesman = from emps in listSaEmployee
                           select new { Id = emps.Id, Name = emps.PersonId != null ? emps.PersonId.PersonName : "-Pilih Salesman-" };

            viewModel.SalesmanList = new SelectList(salesman, "Id", "Id", loan.SalesmanId != null ? loan.SalesmanId.Id : string.Empty);

            var listSuEmployee = mEmployeeRepository.GetEmployeeByDept(EnumDepartment.SU.ToString());

            listSuEmployee.Insert(0, employee);

            var surveyor = from emps in listSuEmployee
                           select new { Id = emps.Id, Name = emps.PersonId != null ? emps.PersonId.PersonName : "-Pilih Surveyor-" };

            viewModel.SurveyorList = new SelectList(surveyor, "Id", "Id", loan.SurveyorId != null ? loan.SurveyorId.Id : string.Empty);

            return(viewModel);
        }
Пример #16
0
        public ActionResult Update(MWarehouse viewModel, FormCollection formCollection)
        {
            try
            {
                MWarehouse mWarehouseToUpdate = _mWarehouseRepository.Get(viewModel.Id);
                TransferFormValuesTo(mWarehouseToUpdate, viewModel);
                mWarehouseToUpdate.EmployeeId   = _mEmployeeRepository.Get(formCollection["EmployeeId"]);
                mWarehouseToUpdate.CostCenterId = _mCostCenterRepository.Get(formCollection["CostCenterId"]);
                mWarehouseToUpdate.ModifiedDate = DateTime.Now;
                mWarehouseToUpdate.ModifiedBy   = User.Identity.Name;
                mWarehouseToUpdate.DataStatus   = EnumDataStatus.Updated.ToString();

                bool       isSave  = false;
                RefAddress address = mWarehouseToUpdate.AddressId;
                if (address == null)
                {
                    address = new RefAddress();
                    address.SetAssignedIdTo(Guid.NewGuid().ToString());
                    isSave = true;
                }
                address.AddressLine1 = formCollection["AddressLine1"];
                address.AddressLine1 = formCollection["AddressLine1"];
                address.AddressLine2 = formCollection["AddressLine2"];
                address.AddressLine3 = formCollection["AddressLine3"];
                address.AddressPhone = formCollection["AddressPhone"];
                address.AddressCity  = formCollection["AddressCity"];

                _refAddressRepository.Save(address);
                if (isSave)
                {
                    _refAddressRepository.Save(address);
                }
                else
                {
                    _refAddressRepository.Update(address);
                }

                mWarehouseToUpdate.AddressId = address;
                _mWarehouseRepository.Update(mWarehouseToUpdate);

                //save account persediaan barang
                isSave = false;
                MAccountRef accountRef = GetAccountRef(EnumReferenceTable.Warehouse, mWarehouseToUpdate.Id);
                if (accountRef == null)
                {
                    accountRef = new MAccountRef();
                    accountRef.SetAssignedIdTo(Guid.NewGuid().ToString());
                    isSave = true;
                }
                accountRef.ReferenceId    = mWarehouseToUpdate.Id;
                accountRef.ReferenceTable = EnumReferenceTable.Warehouse.ToString();
                accountRef.ReferenceType  = EnumReferenceTable.Warehouse.ToString();
                accountRef.AccountId      = _mAccountRepository.Get(formCollection["AccountId"]);
                if (isSave)
                {
                    _mAccountRefRepository.Save(accountRef);
                }
                else
                {
                    _mAccountRefRepository.Update(accountRef);
                }

                //save account pemakaian barang
                isSave     = false;
                accountRef = GetAccountRef(EnumReferenceTable.WarehouseUsing, mWarehouseToUpdate.Id);
                if (accountRef == null)
                {
                    accountRef = new MAccountRef();
                    accountRef.SetAssignedIdTo(Guid.NewGuid().ToString());
                    isSave = true;
                }
                accountRef.ReferenceId    = mWarehouseToUpdate.Id;
                accountRef.ReferenceTable = EnumReferenceTable.WarehouseUsing.ToString();
                accountRef.ReferenceType  = EnumReferenceTable.WarehouseUsing.ToString();
                accountRef.AccountId      = _mAccountRepository.Get(formCollection["UsingAccountId"]);
                if (isSave)
                {
                    _mAccountRefRepository.Save(accountRef);
                }
                else
                {
                    _mAccountRefRepository.Update(accountRef);
                }


                _mWarehouseRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mWarehouseRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Пример #17
0
        public ActionResult Update(MEmployee viewModel, FormCollection formCollection)
        {
            MEmployee mEmployeeToUpdate = _mEmployeeRepository.Get(viewModel.Id);

            TransferFormValuesTo(mEmployeeToUpdate, viewModel);
            mEmployeeToUpdate.DepartmentId = _mDepartmentRepository.Get(formCollection["DepartmentId"]);
            mEmployeeToUpdate.ModifiedDate = DateTime.Now;
            mEmployeeToUpdate.ModifiedBy   = User.Identity.Name;
            mEmployeeToUpdate.DataStatus   = EnumDataStatus.Updated.ToString();

            RefPerson person = mEmployeeToUpdate.PersonId;

            if (person == null)
            {
                person = new RefPerson();
                TransferFormValuesTo(person, formCollection);
                person.SetAssignedIdTo(Guid.NewGuid().ToString());
                person.CreatedDate = DateTime.Now;
                person.CreatedBy   = User.Identity.Name;
                person.DataStatus  = EnumDataStatus.New.ToString();
                _refPersonRepository.Save(person);

                mEmployeeToUpdate.PersonId = person;
            }
            else
            {
                TransferFormValuesTo(person, formCollection);
                person.ModifiedDate = DateTime.Now;
                person.ModifiedBy   = User.Identity.Name;
                person.DataStatus   = EnumDataStatus.Updated.ToString();
            }

            RefAddress address = mEmployeeToUpdate.AddressId;

            if (address == null)
            {
                address = new RefAddress();
                TransferFormValuesTo(address, formCollection);
                address.SetAssignedIdTo(Guid.NewGuid().ToString());
                address.CreatedDate = DateTime.Now;
                address.CreatedBy   = User.Identity.Name;
                address.DataStatus  = EnumDataStatus.New.ToString();
                _refPersonRepository.Save(person);

                mEmployeeToUpdate.AddressId = address;
            }
            else
            {
                TransferFormValuesTo(address, formCollection);
                address.ModifiedDate = DateTime.Now;
                address.ModifiedBy   = User.Identity.Name;
                address.DataStatus   = EnumDataStatus.Updated.ToString();
            }


            _mEmployeeRepository.Update(mEmployeeToUpdate);

            try
            {
                _mEmployeeRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mEmployeeRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("Data Karyawan Berhasil Diupdate"));
        }
Пример #18
0
 private void TransferFormValuesTo(RefAddress address, FormCollection formCollection)
 {
     address.AddressLine1 = formCollection["AddressLine1"];
 }
Пример #19
0
        public ActionResult Registration(MCustomer customer, FormCollection formCollection)
        {
            _mCustomerRepository.DbContext.BeginTransaction();
            RefAddress address = new RefAddress();
            RefPerson  person  = new RefPerson();

            TransferFormValuesTo(address, formCollection);
            address.SetAssignedIdTo(Guid.NewGuid().ToString());
            address.CreatedDate = DateTime.Now;
            address.CreatedBy   = User.Identity.Name;
            address.DataStatus  = EnumDataStatus.New.ToString();
            _refAddressRepository.Save(address);

            TransferFormValuesTo(person, formCollection);
            person.SetAssignedIdTo(Guid.NewGuid().ToString());
            person.CreatedDate = DateTime.Now;
            person.CreatedBy   = User.Identity.Name;
            person.DataStatus  = EnumDataStatus.New.ToString();
            _refPersonRepository.Save(person);

            //MCustomer customer = new MCustomer();
            //TransferFormValuesTo(customer, cust);
            if (customer == null)
            {
                customer = new MCustomer();
            }
            customer.SetAssignedIdTo(formCollection["Id"]);
            customer.CreatedDate = DateTime.Now;
            customer.CreatedBy   = User.Identity.Name;
            customer.DataStatus  = EnumDataStatus.New.ToString();

            customer.AddressId = address;
            customer.PersonId  = person;

            _mCustomerRepository.Save(customer);

            try
            {
                _mCustomerRepository.DbContext.CommitChanges();
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Success;
            }
            catch (Exception e)
            {
                _mCustomerRepository.DbContext.RollbackTransaction();
                TempData[EnumCommonViewData.SaveState.ToString()]    = EnumSaveState.Failed;
                TempData[EnumCommonViewData.ErrorMessage.ToString()] = e.Message;

                //throw e.GetBaseException();
                var result = new
                {
                    Success = false,
                    Message = e.Message
                };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            var resultx = new
            {
                Success = true,
                Message = //Helper.ViewHelper.RenderPartialToString("~/Views/Shared/Status.ascx", "", null, this.ControllerContext.RequestContext)
                          @" <div class='ui-state-highlight ui-corner-all' style='padding: 5pt; margin-bottom: 5pt;'>
                            <p>
                                <span class='ui-icon ui-icon-info' style='float: left; margin-right: 0.3em;'></span>
                                Data berhasil disimpan.</p>
                        </div>"
            };

            return(Json(resultx, JsonRequestBehavior.AllowGet));
            //return View("Status");
        }
Пример #20
0
        public ActionResult Edit(MCustomer customer, FormCollection formCollection, string customerId)
        {
            _mCustomerRepository.DbContext.BeginTransaction();
            RefAddress address = new RefAddress();
            RefPerson  person  = new RefPerson();

            {
                customer = _mCustomerRepository.Get(customerId);
                //customer.CustomerFaceTreatment = formCollection["CustomerFaceTreatment"];
                //customer.CustomerAllergy = formCollection["CustomerAllergy"];
                //customer.CustomerSkinProblem = formCollection["CustomerSkinProblem"];
                //customer.CustomerPlanTreatment = formCollection["CustomerPlanTreatment"];
                //customer.CustomerPhoneJakarta = formCollection["CustomerPhoneJakarta"];
                //customer.CustomerLetter = formCollection["CustomerLetter"];
                customer.ModifiedDate = DateTime.Now;
                customer.ModifiedBy   = User.Identity.Name;
                customer.DataStatus   = EnumDataStatus.Updated.ToString();

                address = customer.AddressId;
                TransferFormValuesTo(address, formCollection);
                //address.AddressLine1 = formCollection["AddressLine1"];
                //address.AddressLine2 = formCollection["AddressLine2"];
                //address.AddressRt = formCollection["AddressRt"];
                //address.AddressRw = formCollection["AddressRw"];
                //address.AddressCity = formCollection["AddressCity"];
                //address.AddressPostCode = formCollection["AddressPostCode"];
                //address.AddressPhone = formCollection["AddressPhone"];
                //address.AddressFax = formCollection["AddressFax"];
                //address.AddressEmail = formCollection["AddressEmail"];
                address.ModifiedDate = DateTime.Now;
                address.ModifiedBy   = User.Identity.Name;
                address.DataStatus   = EnumDataStatus.Updated.ToString();

                person = customer.PersonId;
                TransferFormValuesTo(person, formCollection);
                //person.PersonFirstName = formCollection["PersonFirstName"];
                //person.PersonAnotherName = formCollection["PersonAnotherName"];
                //person.PersonPob = formCollection["PersonPob"];
                //if (!string.IsNullOrEmpty(formCollection["PersonDob"]))
                //    person.PersonDob = Convert.ToDateTime(formCollection["PersonDob"]);
                //else
                //    person.PersonDob = null;
                //person.PersonMobile = formCollection["PersonMobile"];
                //person.PersonOccupation = formCollection["PersonJob"];
                //person.PersonOfficceName = formCollection["PersonOfficceName"];
                //person.PersonOfficceAddress = formCollection["PersonOfficceAddress"];
                //person.PersonOfficceCity = formCollection["PersonOfficceCity"];
                //person.PersonOfficcePostCode = formCollection["PersonOfficcePostCode"];
                //person.PersonOfficcePhone = formCollection["PersonOfficcePhone"];
                //person.PersonOfficceFax = formCollection["PersonOfficceFax"];
                //person.PersonReligion = formCollection["PersonReligion"];
                //person.PersonLastEdu = formCollection["PersonLastEdu"];
                //person.PersonMarriedStatus = formCollection["PersonMarriedStatus"];
                //person.PersonHobby = formCollection["PersonHobby"];
                person.ModifiedDate = DateTime.Now;
                person.ModifiedBy   = User.Identity.Name;
                person.DataStatus   = EnumDataStatus.Updated.ToString();

                _mCustomerRepository.Update(customer);
            }

            try
            {
                _mCustomerRepository.DbContext.CommitChanges();
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Success;
            }
            catch (Exception e)
            {
                _mCustomerRepository.DbContext.RollbackTransaction();
                TempData[EnumCommonViewData.SaveState.ToString()]    = EnumSaveState.Failed;
                TempData[EnumCommonViewData.ErrorMessage.ToString()] = e.GetBaseException().Message;

                //throw e.GetBaseException();

                var result = new
                {
                    Success = false,
                    Message = e.Message
                };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            var resultx = new
            {
                Success = true,
                Message = @" <div class='ui-state-highlight ui-corner-all' style='padding: 5pt; margin-bottom: 5pt;'>
                            <p>
                                <span class='ui-icon ui-icon-info' style='float: left; margin-right: 0.3em;'></span>
                                Data berhasil disimpan.</p>
                        </div>"
            };

            return(Json(resultx, JsonRequestBehavior.AllowGet));
            //}

            //return View("Status");
        }
        public static RegistrationFormViewModel CreateRegistrationFormViewModel(IMCustomerRepository mCustomerRepository, string customerId)
        {
            RegistrationFormViewModel viewModel = new RegistrationFormViewModel();

            viewModel.CanEditId = true;


            MCustomer  customer = null;
            RefPerson  person   = new RefPerson();
            RefAddress address  = new RefAddress();

            if (!string.IsNullOrEmpty(customerId))
            {
                customer            = mCustomerRepository.Get(customerId);
                person              = customer.PersonId;
                address             = customer.AddressId;
                viewModel.CanEditId = false;
            }
            if (customer == null)
            {
                customer = new MCustomer();

                customer.PersonId = person;

                customer.AddressId = address;
            }
            viewModel.Customer = customer;

            //fill gender
            var values = from EnumGender e in Enum.GetValues(typeof(EnumGender))
                         select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.GenderList = new SelectList(values, "Id", "Name", person.PersonGender);

            ////get letters to list
            //var letters = from EnumLetterTo e in Enum.GetValues(typeof(EnumLetterTo))
            //              select new { ID = e, Name = CommonHelper.GetStringValue(e) };
            //viewModel.LetterList = new SelectList(letters, "Id", "Name");

            //get education list
            var edus = from EnumEducation e in Enum.GetValues(typeof(EnumEducation))
                       select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.EducationList = new SelectList(edus, "Id", "Name", person.PersonLastEdu);

            //get married status list
            var merrieds = from EnumMarriedStatus e in Enum.GetValues(typeof(EnumMarriedStatus))
                           select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.MarriedStatusList = new SelectList(merrieds, "Id", "Name", person.PersonMarriedStatus);

            //get card type list
            var idcards = from EnumIdCardType e in Enum.GetValues(typeof(EnumIdCardType))
                          select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.IdCardTypeList = new SelectList(idcards, "Id", "Name", person.PersonIdCardType);

            //get card type list
            var bloods = from EnumBloodType e in Enum.GetValues(typeof(EnumBloodType))
                         select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.BloodTypeList = new SelectList(bloods, "Id", "Name", person.PersonBloodType);

            //get religions list
            var religions = from EnumReligion e in Enum.GetValues(typeof(EnumReligion))
                            select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.ReligionList = new SelectList(religions, "Id", "Name", person.PersonReligion);

            //get occupations list
            var occupations = from EnumOccupation e in Enum.GetValues(typeof(EnumOccupation))
                              select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.OccupationList = new SelectList(occupations, "Id", "Name", person.PersonOccupation);

            //get hobbys list
            var hobbys = from EnumHobby e in Enum.GetValues(typeof(EnumHobby))
                         select new { ID = e, Name = CommonHelper.GetStringValue(e) };

            viewModel.HobbyList = new SelectList(hobbys, "Id", "Name", person.PersonHobby);
            return(viewModel);
        }