Пример #1
0
        public ActionResult Create()
        {
            var AirlinesModel = new AirLinesModel()
            {
                AirlineTypList        = ser.GetAirlineTypeList(),
                AccTypesList          = ser.GetAllAccTypesList(),
                BSPorConsolidatorList = ser.GetAllGetLedgername(),

                CountryList = ser.GetAllCountriesList(),
            };

            return(View(AirlinesModel));
        }
        public int GetLedgerInformationById(int id)
        {
            GL_Ledgers    result = ent.GL_Ledgers.Where(x => x.Id == id).FirstOrDefault();
            AirLinesModel model  = new AirLinesModel();

            if (result != null)
            {
                model.LedgerId = (int)result.LedgerId;
                model.AccTypes = result.AccTypeId;
                model.LedId    = (int)result.Id;
                return(model.LedgerId);
            }
            else
            {
                return(model.LedgerId);
            }
        }
        public int GetLedgerMasterDetail(int id)
        {
            GL_Ledgers    result = ent.GL_Ledgers.Where(x => x.Id == id).FirstOrDefault();
            AirLinesModel model  = new AirLinesModel();

            if (result != null)
            {
                model.LedgerId   = (int)result.LedgerId;
                model.LedId      = (int)result.Id;
                model.LedgerName = result.LedgerName;

                return(model.LedId);
            }
            else
            {
                return(model.LedId);
            }
        }
Пример #4
0
        public ActionResult Edit(AirLinesModel model, Int32 id, FormCollection fs)
        {
            // ser.EditAirLineInfo(obj);

            //new edit
            Airlines obj = new Airlines();

            if (model.chkSettlement == false)
            {
                obj.AirlineId   = id;
                obj.AirlineCode = model.AirlineCode.Trim();
                obj.AirlineName = model.AirlineName.Trim();

                obj.AirlineTypeId     = model.AirlineTypId;
                obj.isActive          = true;
                obj.SettlmentLedgerId = model.LedgerId;
                obj.CountryId         = Convert.ToInt32(model.CountryId);
                ser.EditAirLineInfo(obj);

                ser.DeleteLedgerMaster(id);
            }
            if (model.chkSettlement == true)
            {
                obj.AirlineId   = id;
                obj.AirlineCode = model.AirlineCode.Trim();
                obj.AirlineName = model.AirlineName.Trim();

                obj.AirlineTypeId     = model.AirlineTypId;
                obj.isActive          = true;
                obj.SettlmentLedgerId = obj.AirlineId;
                obj.CountryId         = obj.CountryId;
                ser.EditAirLineInfo(obj);



                //to get the ID from GL_Ledger
                int LedId = ser.GetLedgerMasterDetail(id);


                GL_Ledgers obj1 = new GL_Ledgers();

                if (LedId == 0)
                {
                    obj1.LedgerId      = id;
                    obj1.ProductId     = 1;
                    obj1.AccGroupId    = 2;
                    obj1.AccSubGroupId = 2;
                    obj1.AccTypeId     = 1;
                    obj1.Id            = id;
                    obj1.LedgerName    = model.AirlineName.Trim();
                    obj1.CreatedDate   = DateTime.Now;
                    ser.AddLedger(obj1);
                }
                else
                {
                    //obj1.LedgerId = id;
                    obj1.ProductId     = 1;
                    obj1.AccGroupId    = 2;
                    obj1.AccSubGroupId = 2;
                    obj1.AccTypeId     = 1;
                    obj1.Id            = id;
                    obj1.LedgerName    = model.AirlineName.Trim();
                    obj1.CreatedDate   = DateTime.Now;
                    ser.EditLedgerInfo(obj1);
                }
            }



            //new edit
            //new edit
            Airlines obj2 = new Airlines();

            if (model.chkSettlement == false)
            {
                obj2.AirlineId   = id;
                obj2.AirlineCode = model.AirlineCode.Trim();
                obj2.AirlineName = model.AirlineName.Trim();

                obj2.AirlineTypeId     = model.AirlineTypId;
                obj2.isActive          = true;
                obj2.SettlmentLedgerId = model.BSPorConsolidatorId;
                obj2.CountryId         = Convert.ToInt32(model.CountryId);
                ser.EditAirLineInfo(obj2);
            }
            if (model.chkSettlement == true)
            {
                GL_Ledgers obj1 = new GL_Ledgers();

                //obj1.LedgerId = id;
                obj1.ProductId     = 1;
                obj1.AccGroupId    = 2;
                obj1.AccSubGroupId = 2;
                obj1.AccTypeId     = 1;
                obj1.Id            = id;
                obj1.LedgerName    = model.AirlineName.Trim();
                obj1.CreatedDate   = DateTime.Now;

                Int64 LedgerId = 0;



                if (!ser.isLedgerExists(id))
                {
                    LedgerId = ser.AddLedger(obj1);
                }
                else
                {
                    ser.EditLedgerInfo(obj1);
                    LedgerId = ser.getLedgerId(id);
                }

                obj2.AirlineId   = id;
                obj2.AirlineCode = model.AirlineCode.Trim();
                obj2.AirlineName = model.AirlineName.Trim();

                obj2.AirlineTypeId     = model.AirlineTypId;
                obj2.isActive          = true;
                obj2.SettlmentLedgerId = (int)LedgerId;
                obj2.CountryId         = Convert.ToInt32(model.CountryId);
                ser.EditAirLineInfo(obj2);
            }


            return(RedirectToAction("Index"));
        }
Пример #5
0
        public ActionResult Edit(Int32 id)
        {
            var LegderModel = ser.GetLedgerInfoById(id);

            // int LegerId = ser.GetLedgerInformationById(id);

            var model = ser.GetAirLineInfoById(id);

            if (LegderModel != null)
            {
                var AirlineModel = new AirLinesModel()
                {
                    AirlineCode    = model.AirlineCode,
                    AirlineName    = model.AirlineName,
                    AirlineId      = model.AirlineId,
                    AirlineTypId   = model.AirlineTypeId,
                    CountryId      = model.CountryId.ToString(),
                    AirlineTypList = ser.GetAirlineTypeList(),

                    AccTypes              = (LegderModel.AccTypeId == 0) ? 0 : LegderModel.AccTypeId,
                    AccTypesList          = ser.GetAllAccTypesList(),
                    BSPorConsolidatorList = ser.GetAllGetLedgername(),
                    CountryList           = ser.GetAllCountriesList(),
                    SettlmentLedgerId     = model.SettlmentLedgerId
                };

                if (AirlineModel.AccTypes == 1 && AirlineModel.SettlmentLedgerId == LegderModel.LedgerId)
                {
                    AirlineModel.chkSettlement       = true;
                    AirlineModel.AccTypes            = 0;
                    AirlineModel.BSPorConsolidatorId = 0;
                }
                else if (AirlineModel.SettlmentLedgerId != null && AirlineModel.SettlmentLedgerId > 0)
                {
                    var m = ser.GetLedgerInfoByLedgerId((int)AirlineModel.SettlmentLedgerId);
                    AirlineModel.AccTypes            = m.AccTypeId;
                    AirlineModel.BSPorConsolidatorId = (int)m.LedgerId;
                }


                return(View(AirlineModel));
            }
            else
            {
                var AirlineModel = new AirLinesModel()
                {
                    AirlineCode  = model.AirlineCode,
                    AirlineName  = model.AirlineName,
                    AirlineId    = model.AirlineId,
                    AirlineTypId = model.AirlineTypeId,
                    // CountryId = (int)model.CountryId==0?0 : (int)model.CountryId,
                    CountryId      = model.CountryId == null ? "" : model.CountryId.ToString(),
                    AirlineTypList = ser.GetAirlineTypeList(),

                    AccTypesList          = ser.GetAllAccTypesList(),
                    BSPorConsolidatorList = ser.GetAllGetLedgername(),
                    CountryList           = ser.GetAllCountriesList(),
                    SettlmentLedgerId     = model.SettlmentLedgerId
                };

                if (AirlineModel.SettlmentLedgerId != null && AirlineModel.SettlmentLedgerId > 0)
                {
                    var m = ser.GetLedgerInfoByLedgerId((int)AirlineModel.SettlmentLedgerId);
                    AirlineModel.AccTypes            = m.AccTypeId;
                    AirlineModel.BSPorConsolidatorId = (int)m.LedgerId;
                }
                return(View(AirlineModel));
            }
        }
Пример #6
0
        public ActionResult Create(AirLinesModel model)
        {
            EntityModel ent   = new EntityModel();
            bool        check = ser.CheckAirlineName(model.AirlineName);

            if (check == true)
            {
                //AirLinesServices.ServiceAirlineClient ser = new AirLinesServices.ServiceAirlineClient();
                try
                {
                    //new save with settlement Condition//
                    Airlines datamodel = new Airlines();


                    if (model.chkSettlement == false)
                    {
                        datamodel.AirlineCode = model.AirlineCode.TrimEnd();
                        datamodel.AirlineName = model.AirlineName.TrimEnd();

                        datamodel.AirlineTypeId = model.AirlineTypId;
                        //datamodel.SettlmentLedgerId = model.LedgerId;
                        datamodel.SettlmentLedgerId = model.LedgerId;
                        datamodel.CountryId         = Convert.ToInt32(model.CountryId);
                        datamodel.isActive          = true;

                        ser.AddAirLine(datamodel);
                    }

                    if (model.chkSettlement == true)
                    {
                        ////////insertng into Airline Table////////////
                        datamodel.AirlineCode = model.AirlineCode.TrimEnd();
                        datamodel.AirlineName = model.AirlineName.TrimEnd();

                        datamodel.AirlineTypeId     = model.AirlineTypId;
                        datamodel.SettlmentLedgerId = model.AirlineId;
                        datamodel.CountryId         = Convert.ToInt32(model.CountryId);
                        datamodel.isActive          = true;

                        int airlineid = ser.AddAirLine(datamodel);

                        // datamodel.SettlmentLedgerId = airlineid;
                        // ser.AddAirLine(datamodel);

                        datamodel.SettlmentLedgerId = airlineid;
                        ser.EditAirLineInfo(datamodel);

                        ///////////inserting into Legder Table////////
                        GL_Ledgers datamodel1 = new GL_Ledgers();
                        // datamodel1.LedgerId = airlineid;
                        datamodel1.ProductId     = 1;
                        datamodel1.AccGroupId    = 2;
                        datamodel1.AccSubGroupId = 2;
                        datamodel1.AccTypeId     = 1;
                        datamodel1.Id            = airlineid;
                        //datamodel1.LedgerName = "A/C" + " " + model.AirlineName.TrimEnd();
                        datamodel1.LedgerName  = model.AirlineName.TrimEnd();
                        datamodel1.CreatedDate = DateTime.Now;

                        ser.AddLedger(datamodel1);
                        //////////////////////////////////////////////////
                    }
                }



                catch
                {
                    //    var AirlineModel = new AirLineModel()
                    //    {
                    //        AirlineTypList = ser.GetAirlineTypeList(),
                    //        AccTypesList = ser.GetAllAccTypesList(),
                    //        BSPorConsolidatorList = ser.GetAllGetLedgername()
                    //    };
                    //    return View(AirlineModel);
                }

                return(RedirectToAction("Index"));
            }
            var viewModel = new AirLinesModel()
            {
                AirlineTypList        = ser.GetAirlineTypeList(),
                AccTypesList          = ser.GetAllAccTypesList(),
                BSPorConsolidatorList = ser.GetAllGetLedgername()
            };

            TempData["Error"] = "Airline Name Already Exists";
            return(View(viewModel));
        }