Exemple #1
0
        public IActionResult AnnualMeetingOrdinary(CompanyShareViewModel model)
        {
            if (!string.IsNullOrEmpty(model.JalaliFromDate) && !string.IsNullOrEmpty(model.JalaliToDate))
            {
                DateTime?fromDate = model.JalaliFromDate.ToDateTime();
                DateTime?toDate   = model.JalaliToDate.ToDateTime();

                ViewBag.JalaliFromDate = model.JalaliFromDate;
                ViewBag.JalaliToDate   = model.JalaliToDate;
                ViewBag.FromDate       = model.JalaliFromDate.ToDateTime();
                ViewBag.ToDate         = model.JalaliToDate.ToDateTime();

                var items = _companyAnnualRepository.GetAsQueryable(x => HasAccess(x.CompanyId) && (x.Date >= fromDate && x.Date <= toDate), includeProperties: "Company,PrimaryAuditor,SecondaryAuditor,Newspaper").ToList();

                IEnumerable <CompanyAnnualMeetingViewModel> models = items.Select(woak => new CompanyAnnualMeetingViewModel
                {
                    CompanyTitle          = woak.Company.Title,
                    AccountingRight       = (double)woak.AccountingRight,
                    SocialResponsibility  = (double)woak.SocialResponsibility,
                    HoldingShares         = woak.HoldingShares,
                    DividedProfit         = woak.DividedProfit,
                    BoardBonus            = woak.BoardBonus,
                    PrimaryAuditorTitle   = woak.PrimaryAuditor.Title,
                    SecondaryAuditorTitle = woak.SecondaryAuditor.Title,
                    BoardRight            = woak.BoardRight,
                    NewspaperTitle        = woak.Newspaper.Title,
                });

                return(View(models));
            }
            return(RedirectToAction("AnnualMeetingOrdinary"));
        }
Exemple #2
0
        public IActionResult CompanyAnnualMeeting(CompanyShareViewModel model)
        {
            if (!string.IsNullOrEmpty(model.JalaliFromDate) && !string.IsNullOrEmpty(model.JalaliToDate))
            {
                DateTime?fromDate = model.JalaliFromDate.ToDateTime();
                DateTime?toDate   = model.JalaliToDate.ToDateTime();

                ViewBag.JalaliFromDate = model.JalaliFromDate;
                ViewBag.JalaliToDate   = model.JalaliToDate;
                ViewBag.FromDate       = model.JalaliFromDate.ToDateTime();
                ViewBag.ToDate         = model.JalaliToDate.ToDateTime();

                var items = _companyAnnualRepository.GetAsQueryable(x => HasAccess(x.CompanyId) && (x.Date >= fromDate && x.Date <= toDate), includeProperties: "Company").Join(_companyShareRepository.GetAsQueryable(), a => a.CompanyId, b => b.CompanyId, (a, b) => new { meeting = a, companyShare = b }).ToList();

                IEnumerable <CompanyAnnualMeetingViewModel> models = items.Select(woak => new CompanyAnnualMeetingViewModel
                {
                    CompanyTitle   = woak.meeting.Company.Title,
                    CurrentCapital = woak.companyShare.CurrentShares,
                    HoldingShares  = woak.meeting.HoldingShares,
                    DividedProfit  = woak.meeting.DividedProfit,
                    TotalProfit    = woak.meeting.HoldingShares * woak.meeting.DividedProfit,
                    Date           = woak.meeting.Date
                });
                return(View(models));
            }
            return(RedirectToAction("CompanyAnnualMeeting"));
        }
        public async Task <IActionResult> Edit(CompanyShareViewModel model)
        {
            model.SystemUserId = UserId;

            if (!HasAccess(model.CompanyId))
            {
                return(View("Error"));
            }

            if (ModelState.IsValid)
            {
                model.Date = model.JalaliDate.ToDateTime();
                if (model.Date > DateTime.Now)
                {
                    ModelState.AddModelError("", Resources.Messages.InvalidDate);
                    return(View(model));
                }

                var capitalChangePercentage = Math.Round(100 * ((model.CurrentCapital - model.PreviousCapital) / (double)model.PreviousCapital), 2);
                var sumOfCapitalIncrease    = model.CapitalIncreaseFromAccumulatedProfits + model.CapitalIncreaseFromAssetsRevaluation +
                                              model.CapitalIncreaseFromCash + model.CapitalIncreaseFromShareholderReceivables;



                //if (Math.Round((Math.Round(100 * Math.Abs(capitalChangePercentage), 2) / 100), 2) != (Math.Round(100 * Math.Abs(sumOfCapitalIncrease), 2) / 100))
                //{
                //    ModelState.AddModelError("", $"جمع آورده ها با درصد تغییرات سرمایه محاسبه شده یعنی {Math.Round((Math.Round(100 * Math.Abs(capitalChangePercentage), 2) / 100), 2) } باید یکی باشد");
                //    return View(model);
                //}

                var item   = _mapper.Map <CompanyShareViewModel, CompanyShare>(model);
                var result = await _companyShareRepository.UpdateAsync(item);

                //await ReCalculatePortfo();

                ErrorMessage = Resources.Messages.ChangesSavedSuccessfully;

                if (Request.Form.Keys.Contains("SaveAndReturn"))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Edit", new { id = item.Id }));
                }
            }
            return(View(model));
        }
Exemple #4
0
        public IActionResult CompanyShare(CompanyShareViewModel model)
        {
            if (!string.IsNullOrEmpty(model.JalaliFromDate) && !string.IsNullOrEmpty(model.JalaliToDate))
            {
                DateTime?fromDate = model.JalaliFromDate.ToDateTime();
                DateTime?toDate   = model.JalaliToDate.ToDateTime();

                ViewBag.JalaliFromDate = model.JalaliFromDate;
                ViewBag.JalaliToDate   = model.JalaliToDate;
                ViewBag.FromDate       = model.JalaliFromDate.ToDateTime();
                ViewBag.ToDate         = model.JalaliToDate.ToDateTime();

                var items = _companyShareRepository.GetAsQueryable(x => HasAccess(x.CompanyId) && (x.CurrentCapital != x.PreviousCapital) && (x.Date >= fromDate && x.Date <= toDate), includeProperties: "Company").ToList();

                var res = _mapper.Map <IEnumerable <CompanyShare>, IEnumerable <CompanyShareViewModel> >(items);
                return(View(res));
            }
            return(RedirectToAction("CompanyShare"));
        }
Exemple #5
0
        public IActionResult CompanyShareEx(CompanyShareViewModel model)
        {
            if (!string.IsNullOrEmpty(model.JalaliFromDate) && !string.IsNullOrEmpty(model.JalaliToDate))
            {
                DateTime?fromDate = model.JalaliFromDate.ToDateTime();
                DateTime?toDate   = model.JalaliToDate.ToDateTime();

                ViewBag.JalaliFromDate = model.JalaliFromDate;
                ViewBag.JalaliToDate   = model.JalaliToDate;
                ViewBag.FromDate       = model.JalaliFromDate.ToDateTime();
                ViewBag.ToDate         = model.JalaliToDate.ToDateTime();

                PersianCalendar pc = new PersianCalendar();

                int yearFrom = pc.GetYear((DateTime)fromDate);
                int yearTo   = pc.GetYear((DateTime)toDate);

                int    monthFrom = pc.GetMonth((DateTime)fromDate);
                int    monthTo   = pc.GetMonth((DateTime)toDate);
                string query     = "";


                query = String.Format(@" with cte as (
            SELECT CompanyID,ShareholderId 
            ,(Select Title from [dbo].[Companies] c where c.id=CompanyID) CompanyTitle
            ,(Select Title from [dbo].Shareholders c where c.id=ShareholderId) ShareHolderTitle
            ,shares
            ,ROW_NUMBER() over( partition by CompanyID,ShareholderId order by year,month ) RankShare,
            year,month
              FROM [KavoshFrameWorkWebApplication].[dbo].[CompanyShareholders] P
              where p.IsDeleted=0
            ), cte2 as (
	            Select CompanyID,ShareholderId,CompanyTitle,ShareHolderTitle ,	
	            (Select Year from cte c where c.RankShare=(Select Max(RankShare) from cte cc where cc.CompanyId=cte.CompanyId and cc.ShareholderId=cte.ShareholderId) and c.CompanyId=cte.CompanyId and c.ShareholderId=cte.ShareholderId) as NewYear, 
		            (Select Month from cte c where c.RankShare=(Select Max(RankShare) from cte cc where cc.CompanyId=cte.CompanyId and cc.ShareholderId=cte.ShareholderId) and c.CompanyId=cte.CompanyId and c.ShareholderId=cte.ShareholderId) as NewMonth, 
	            (Select shares from cte c where c.RankShare=(Select Max(RankShare) from cte cc where cc.CompanyId=cte.CompanyId and cc.ShareholderId=cte.ShareholderId) and c.CompanyId=cte.CompanyId and c.ShareholderId=cte.ShareholderId) as NewShare,
	             (Select Year from cte c where c.RankShare=(Select Max(RankShare) from cte cc where cc.CompanyId=cte.CompanyId and cc.ShareholderId=cte.ShareholderId)-1 and c.CompanyId=cte.CompanyId and c.ShareholderId=cte.ShareholderId) as OldYear,
	               (Select Month from cte c where c.RankShare=(Select Max(RankShare) from cte cc where cc.CompanyId=cte.CompanyId and cc.ShareholderId=cte.ShareholderId)-1 and c.CompanyId=cte.CompanyId and c.ShareholderId=cte.ShareholderId) as OldMonth,
	             (Select shares from cte c where c.RankShare=(Select Max(RankShare) from cte cc where cc.CompanyId=cte.CompanyId and cc.ShareholderId=cte.ShareholderId)-1 and c.CompanyId=cte.CompanyId and c.ShareholderId=cte.ShareholderId) as OldShare
	            from cte
		 group by CompanyID,ShareholderId ,CompanyTitle,ShareHolderTitle)
		 Select * from cte2		  
		 where NewYear>={0}  and NewYear<={0} 
		 and NewMonth>={1}  and NewMonth<={1}
		  and OldShare is not null"        , yearTo, monthTo);

                if (User.IsInRole("Admin"))
                {
                }
                else
                {
                    if (CompanyIds.Count == 0)
                    {
                        return(View("Error"));
                    }

                    query += " And CompanyId In(";
                    foreach (int id in CompanyIds)
                    {
                        query += id + " ,";
                    }
                    query  = query.Remove(query.Length - 1);
                    query += ")";
                }



                string strCnn = Configuration.GetConnectionString("ConnectionString");
                System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(query, strCnn);
                DataTable dt = new DataTable();
                da.Fill(dt);

                List <CompanyShareholderReport> models = new List <CompanyShareholderReport>();
                foreach (DataRow woak in dt.Rows)
                {
                    models.Add(new CompanyShareholderReport()
                    {
                        CompanyTitle     = woak["CompanyTitle"].ToString(),
                        ShareholderTitle = woak["ShareHolderTitle"].ToString(),
                        OldShares        = Convert.ToInt64(woak["OldShare"]),
                        Shares           = Convert.ToInt64(woak["NewShare"]),
                        Year             = Convert.ToInt32(woak["NewYear"] == null ? "0" : woak["NewYear"]),
                        Month            = Convert.ToInt32(woak["NewMonth"] == null ? "0" : woak["NewMonth"]),
                        YearOld          = Convert.ToInt32(woak["OldYear"] == null ? "0" : woak["OldYear"]),
                        MonthOld         = Convert.ToInt32(woak["OldMonth"] == null ? "0" : woak["OldMonth"]),
                    });
                }
                return(View(models));
            }
            return(RedirectToAction("CompanyShareEx"));
        }