/////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //for delete
        public void DeleteLedgerMaster(int LedgerMasterId)
        {
            GL_Ledgers result = ent.GL_Ledgers.Where(x => x.LedgerId == LedgerMasterId).FirstOrDefault();

            ent.DeleteObject(result);
            ent.SaveChanges();
        }
        public void UpdateGeneralLegder(BranchOfficeManagementModel model)
        {
            GL_Ledgers led = ent.GL_Ledgers.Where(x => x.Id == model.BranchOfficeId && x.AccTypeId == 8).FirstOrDefault();

            led.LedgerName = model.BranchOffice + " " + model.BranchOfficeCode;
            ent.ApplyCurrentValues(led.EntityKey.EntitySetName, led);
            ent.SaveChanges();
        }
        public void UpdateGeneralLegder(DistributorManagementModel model)
        {
            GL_Ledgers led = entity.GL_Ledgers.Where(x => x.Id == model.DistributorId && x.AccTypeId == 9).FirstOrDefault();

            led.LedgerName = model.DistributorName + " " + model.DistributorCode;
            entity.ApplyCurrentValues(led.EntityKey.EntitySetName, led);
            entity.SaveChanges();
        }
        public long AddLedgerMaster(GL_Ledgers obj)
        {
            ent.AddToGL_Ledgers(obj);
            ent.SaveChanges();

            //to return the primary key
            return(obj.LedgerId);
        }
        //for delete
        public void DeleteLedgerMaster(int ID)
        {
            GL_Ledgers result = ent.GL_Ledgers.Where(x => x.Id == ID).FirstOrDefault();

            if (result != null)
            {
                ent.DeleteObject(result);
                ent.SaveChanges();
            }
        }
        //to get ledger name
        public string GetLedgerDetail(int id)
        {
            GL_Ledgers result = ent.GL_Ledgers.Where(x => x.LedgerId == id).FirstOrDefault();

            LedgerMasterModel model = new LedgerMasterModel();

            model.LedgerId   = (int)result.LedgerId;
            model.LedgerName = result.LedgerName;

            return(model.LedgerName);
        }
        public void EditLedgerInfo(GL_Ledgers obj)
        {
            EntityModel ent    = new EntityModel();
            var         result = ent.GL_Ledgers.Where(x => x.Id == obj.Id).FirstOrDefault();

            if (result != null)
            {
                obj.LedgerId = result.LedgerId;
                ent.ApplyCurrentValues(result.EntityKey.EntitySetName, obj);
                ent.SaveChanges();
            }
        }
        //for edit
        public void EditLedgerMaster(LedgerMasterModel model)
        {
            GL_Ledgers result = ent.GL_Ledgers.Where(x => x.LedgerId == model.LedgerId).FirstOrDefault();

            result.LedgerId      = model.LedgerId;
            result.ProductId     = model.ProductId;
            result.AccGroupId    = model.AccGroupId;
            result.AccSubGroupId = model.AccSubGroupId;
            result.AccTypeId     = model.AccTypeId;
            result.Id            = model.ddlAirLines;
            result.LedgerName    = model.LedgerName;

            ent.ApplyCurrentValues(result.EntityKey.EntitySetName, result);
            ent.SaveChanges();
        }
        //for adding into GL_Ledgers Table
        public void LedgerAdd(LedgerMasterModel modelToSave)
        {
            GL_Ledgers datamodel = new GL_Ledgers
            {
                ProductId     = modelToSave.ProductId,
                AccGroupId    = modelToSave.AccGroupId,
                AccSubGroupId = modelToSave.AccSubGroupId,
                AccTypeId     = modelToSave.AccTypeId,
                Id            = modelToSave.ddlAirLines,
                LedgerName    = modelToSave.LedgerName,
                CreatedDate   = DateTime.Now,
            };

            ent.AddToGL_Ledgers(datamodel);
            ent.SaveChanges();
        }
        public GL_Ledgers GetLedgerInfoByLedgerId(int LedgerId)
        {
            EntityModel ent    = new EntityModel();
            GL_Ledgers  result = ent.GL_Ledgers.Where(x => x.LedgerId == LedgerId).FirstOrDefault();


            if (result != null)
            {
                return(result);
            }
            // return result;
            else
            {
                return(result);
            }
        }
        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 void SaveBranchOfficeLedger(int BranchOfficeId, int ProductId, int CreatedBy)
        {
            var        BranchOfficeDetails = GetBranchOfficeInfo(BranchOfficeId);
            GL_Ledgers datamodel           = new GL_Ledgers
            {
                Id            = BranchOfficeId,
                ProductId     = ProductId,
                AccGroupId    = 1,
                AccSubGroupId = 1,
                AccTypeId     = 8,
                LedgerName    = BranchOfficeDetails.BranchOfficeName + " " + BranchOfficeDetails.BranchOfficeCode,
                CreatedBy     = CreatedBy,
                CreatedDate   = DateTime.Now,
            };

            ent.AddToGL_Ledgers(datamodel);
            ent.SaveChanges();
        }
Esempio n. 13
0
        public void SaveAgentGeneralLedger(int agentid, int ProductId, int CreatedBy)
        {
            var        agentdetails = GetAgentInfo(agentid);
            GL_Ledgers datamodel    = new GL_Ledgers
            {
                Id            = agentid,
                ProductId     = ProductId,
                AccGroupId    = 1,
                AccSubGroupId = 1,
                AccTypeId     = 2,
                LedgerName    = "A/C  " + agentdetails.AgentName,
                CreatedBy     = CreatedBy,
                CreatedDate   = DateTime.Now,
            };

            ent.AddToGL_Ledgers(datamodel);
            ent.SaveChanges();
        }
        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);
            }
        }
        public void SaveDistributorLedger(DistributorManagementModel model)
        {
            DistributorManagementModel distributorsDetails = GetDistributorsDetailsModel(model.DistributorId);

            GL_Ledgers datamodel = new GL_Ledgers
            {
                Id            = model.DistributorId,
                ProductId     = 1,
                AccGroupId    = 1,
                AccSubGroupId = 1,
                AccTypeId     = 9,
                LedgerName    = distributorsDetails.DistributorName + " " + distributorsDetails.DistributorCode,
                CreatedBy     = model.CreatedBy,
                CreatedDate   = DateTime.UtcNow,
            };

            entity.AddToGL_Ledgers(datamodel);
            entity.SaveChanges();
        }
Esempio n. 16
0
        ////////////////////////////////////////////////for detail/////////////////////////////////////////////
        public LedgerMasterModel Detail(int id)
        {
            GL_Ledgers        result = ent.GL_Ledgers.Where(x => x.LedgerId == id).FirstOrDefault();
            LedgerMasterModel model  = new LedgerMasterModel();

            model.LedgerId        = (int)result.LedgerId;
            model.ProductId       = result.ProductId;
            model.ProductName     = result.Core_Products.ProductName;
            model.AccGroupId      = result.AccGroupId;
            model.AccGroupName    = result.GL_AccGroups.AccGroupName;
            model.AccSubGroupId   = result.AccSubGroupId;
            model.AccSubGroupName = result.GL_AccSubGroups.AccSubGroupName;
            model.AccTypeId       = result.AccTypeId;
            model.AccTypeName     = result.GL_AccTypes.AccTypeName;
            model.ddlAirLines     = result.Id;
            model.LedgerName      = result.LedgerName;
            model.MapTable        = result.GL_AccTypes.MapTable;
            model.ValueMember     = result.GL_AccTypes.ValueMember;
            model.DisplayMember   = result.GL_AccTypes.DisplayMember;


            return(model);
        }
Esempio n. 17
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));
        }
 public int getLedgerId(int AirlineId)
 {
     return((int)GL_Ledgers.Where(x => x.Id == AirlineId && x.AccTypeId == 1).Select(x => x.LedgerId).FirstOrDefault());
 }
Esempio n. 19
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"));
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public Int64 AddLedger(GL_Ledgers obj)
        {
            ent.AddToGL_Ledgers(obj);
            ent.SaveChanges();
            return(obj.LedgerId);
        }