예제 #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 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"));
        }
예제 #3
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"));
        }
예제 #4
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"));
        }
예제 #5
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"));
        }
예제 #6
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"));
        }
예제 #7
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"));
        }
예제 #8
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"));
        }
예제 #9
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"));
        }
예제 #10
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"));
        }
예제 #11
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");
        }