Beispiel #1
0
        public async Task <JsonResult> GetPartyAddressHistory(int party)
        {
            IAddressHistoryRepository _addressrepo = new AddressHistoryRepository();


            Response result = await _addressrepo.GetAddressHistory(party);

            return(Json(result, JsonRequestBehavior.AllowGet));

            /*
             * if (result.IsError == false)
             * {
             *  AdressHistoryVM Obj = (AdressHistoryVM)result.Value;
             *  return Json(Obj, JsonRequestBehavior.AllowGet);
             * }
             * else {
             *  return Json(result.Message, JsonRequestBehavior.AllowGet);
             * }
             *
             */
        }
Beispiel #2
0
        public async Task <ActionResult> AddDo(DorderVM dorder, FormCollection frm)
        {
            int     saveCopy           = Convert.ToInt32(frm["SaveCopy"]);
            decimal lastDoNumber       = 0;
            decimal lastContractNumber = 0;
            double  totalQty           = 0;
            int     party = (int)dorder.Party;

            if (saveCopy == 1)
            {
                dorder.EcomID      = (int)Session["Comp"];
                dorder.CreatedOn   = DateTime.Today;
                lastDoNumber       = (decimal)dorder.DoNumber;
                lastContractNumber = (decimal)dorder.ContractNumber;
                Response reslut = await _Repository.AddDo(dorder);

                totalQty = (double)dorder.Weight;
                if (!reslut.IsError)
                {
                    ISettingRepository _setting = new SettingRepository();
                    _setting.UpdateDoAutoIncrement(dorder.autoincrement);
                    _setting.UpdateLastContractNumber((decimal)dorder.ContractNumber);
                    _setting.UpdateLastDoNumber((lastDoNumber + 1));


                    IContractRespository _contract = new ContractRepository();
                    ContractVM           contract  = new ContractVM();
                    contract.Party        = party;
                    contract.PartyName    = dorder.PartyName;
                    contract.TotatQty     = totalQty;
                    contract.Unit         = dorder.Unit;
                    contract.EcomID       = (int)Session["Comp"];
                    contract.CreatedOn    = DateTime.Today;
                    contract.ContractType = dorder.ContractType;
                    contract.ContractNo   = dorder.ContractNumber;
                    if (_contract.isInsertable(contract))
                    {
                        await _contract.AddContract(contract);
                    }
                    else
                    {
                        await _contract.UpdateContractQty(contract);
                    }

                    IAddressHistoryRepository _addresHistory = new AddressHistoryRepository();
                    AdressHistory             addressHistory = new AdressHistory();

                    addressHistory.Party          = dorder.Party;
                    addressHistory.EnglisgAddress = dorder.AddressEng;
                    addressHistory.UrduAddress    = dorder.AddressUrd;

                    if (_addresHistory.isInsertable((int)addressHistory.Party))
                    {
                        _addresHistory.AddAddressHistory(addressHistory);
                    }

                    else
                    {
                        _addresHistory.updqateAddressHistory(addressHistory);
                    }
                }
            }

            else
            {
                lastDoNumber = (decimal)dorder.DoNumber;
                for (int i = 0; i < saveCopy; i++)
                {
                    dorder.EcomID      = (int)Session["Comp"];
                    dorder.CreatedOn   = DateTime.Today;
                    dorder.DoNumber    = lastDoNumber;
                    lastContractNumber = (decimal)dorder.ContractNumber;
                    Response reslutloop = await _Repository.AddDo(dorder);

                    totalQty = totalQty + (double)dorder.Weight;
                    lastDoNumber++;
                }

                ISettingRepository _setting = new SettingRepository();
                _setting.UpdateDoAutoIncrement(dorder.autoincrement);
                _setting.UpdateLastContractNumber((decimal)dorder.ContractNumber);
                _setting.UpdateLastDoNumber((lastDoNumber));

                IContractRespository _contract = new ContractRepository();
                ContractVM           contract  = new ContractVM();
                contract.Party        = party;
                contract.PartyName    = dorder.PartyName;
                contract.TotatQty     = totalQty;
                contract.Unit         = dorder.Unit;
                contract.EcomID       = (int)Session["Comp"];
                contract.CreatedOn    = DateTime.Today;
                contract.ContractType = dorder.ContractType;
                contract.ContractNo   = dorder.ContractNumber;

                if (_contract.isInsertable(contract))
                {
                    await _contract.AddContract(contract);
                }
                else
                {
                    await _contract.UpdateContractQty(contract);
                }

                IAddressHistoryRepository _addresHistory = new AddressHistoryRepository();
                AdressHistory             addressHistory = new AdressHistory();

                addressHistory.Party          = dorder.Party;
                addressHistory.EnglisgAddress = dorder.AddressEng;
                addressHistory.UrduAddress    = dorder.AddressUrd;

                if (_addresHistory.isInsertable((int)addressHistory.Party))
                {
                    _addresHistory.AddAddressHistory(addressHistory);
                }

                else
                {
                    _addresHistory.updqateAddressHistory(addressHistory);
                }
            }

            return(RedirectToAction("Index"));
        }