public ActionResult SetBurdenForFinancial(long id)
        {
            if (id > 0)
            {
                T_ProducerFinancialStatements tcfs = db.T_ProducerFinancialStatements.Find(id);
                int    ProducerID = tcfs.ProducerID;
                string FromDate   = tcfs.FromDate.Substring(0, 10);
                string ToDate     = tcfs.ToDate.Substring(0, 10);

                //int ProducerID = db.T_ProducerFinancialStatements.Where(m => m.ProducerFinancialStatementID == id).ToList()[0].ProducerID;
                var burdeninformations = db.T_BurdenInformations.Where(m => m.T_TransportPrices.ProducerID == ProducerID && m.PFSID == null && m.UnLoadDateTime.Substring(0, 10).CompareTo(FromDate) >= 0 && m.UnLoadDateTime.Substring(0, 10).CompareTo(ToDate) <= 0).ToList();

                foreach (var item in burdeninformations)
                {
                    item.PFSID = id;
                }


                db.SaveChanges();

                return(RedirectToAction("Details", new { id = id }));
            }

            return(View());
        }
        public ActionResult DeleteConfirmed(long id)
        {
            T_ProducerFinancialStatements t_producerfinancialstatements = db.T_ProducerFinancialStatements.Find(id);

            db.T_ProducerFinancialStatements.Remove(t_producerfinancialstatements);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //
        // GET: /Management/ProducerFinancialStatement/Delete/5

        public ActionResult Delete(long id = 0)
        {
            T_ProducerFinancialStatements t_producerfinancialstatements = db.T_ProducerFinancialStatements.Find(id);

            if (t_producerfinancialstatements == null)
            {
                return(HttpNotFound());
            }
            return(View(t_producerfinancialstatements));
        }
 public ActionResult Edit(T_ProducerFinancialStatements t_producerfinancialstatements)
 {
     if (ModelState.IsValid)
     {
         db.Entry(t_producerfinancialstatements).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.StateID    = new SelectList(db.T_FinancialStates, "StateID", "StateName", t_producerfinancialstatements.StateID);
     ViewBag.ProducerID = new SelectList(db.T_Producers, "ProducerID", "CompanyName", t_producerfinancialstatements.ProducerID);
     return(View(t_producerfinancialstatements));
 }
        //
        // GET: /Management/ProducerFinancialStatement/Edit/5

        public ActionResult Edit(long id = 0)
        {
            T_ProducerFinancialStatements t_producerfinancialstatements = db.T_ProducerFinancialStatements.Find(id);

            if (t_producerfinancialstatements == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StateID    = new SelectList(db.T_FinancialStates, "StateID", "StateName", t_producerfinancialstatements.StateID);
            ViewBag.ProducerID = new SelectList(db.T_Producers, "ProducerID", "CompanyName", t_producerfinancialstatements.ProducerID);
            return(View(t_producerfinancialstatements));
        }
        public ActionResult Create(T_ProducerFinancialStatements t_producerfinancialstatements)
        {
            if (ModelState.IsValid)
            {
                db.T_ProducerFinancialStatements.Add(t_producerfinancialstatements);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StateID    = new SelectList(db.T_FinancialStates, "StateID", "StateName", t_producerfinancialstatements.StateID);
            ViewBag.ProducerID = new SelectList(db.T_Producers.Where(m => m.StateID == true), "ProducerID", "CompanyName", t_producerfinancialstatements.ProducerID);
            return(View(t_producerfinancialstatements));
        }
        //
        // GET: /Management/ProducerFinancialStatement/Details/5

        public ActionResult Details(long id = 0)
        {
            T_ProducerFinancialStatements t_producerfinancialstatements = db.T_ProducerFinancialStatements.Find(id);

            if (t_producerfinancialstatements == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Burdens = db.T_BurdenInformations.Where(m => m.PFSID == id);
            ViewBag.Pays    = db.T_ProducersPays.Where(m => m.PFSID == id);


            return(View(t_producerfinancialstatements));
        }
        public ActionResult ShowReportSearch(T_ProducerFinancialStatements t_confinans, FormCollection frm)
        {
            if (frm["ProducerID"].ToString() != "" || frm["FromDate"].ToString() != "" || frm["ToDate"].ToString() != "")
            {
                long ProducerID = 0;

                string fromDate = "", toDate = "";

                try
                {
                    ProducerID = long.Parse(frm["ProducerID"].ToString());
                }
                catch
                {
                }


                try
                {
                    fromDate = frm["FromDate"].ToString();
                }
                catch
                {
                }
                try
                {
                    toDate = frm["ToDate"].ToString();
                }
                catch
                {
                }



                return(RedirectToAction("ShowSearch", "ProducerFinancialStatement", new { ProducerID = ProducerID, FromDate = fromDate, ToDate = toDate }));
            }
            else
            {
                ViewBag.ProducerID = new SelectList(db.T_Producers.ToList(), "ProducerID", "CompanyName");

                return(View());
            }



            // return View();
        }
        public ActionResult GetReportSnapshotAccountant(long id = 0)
        {
            if (id != 0)
            {
                T_ProducerFinancialStatements pfs = db.T_ProducerFinancialStatements.Find(id);


                StiReport report = new StiReport();
                string    path   = Server.MapPath("~/Reports/pfs-pay.mrt");
                report.Load(path);

                report.Dictionary.Databases.Clear();


                string con = System.Configuration.ConfigurationManager.ConnectionStrings[Session["ReportConnection"].ToString()].ConnectionString;

                report.Dictionary.Databases.Add(new StiSqlDatabase("Maase", con));

                //string con = System.Configuration.ConfigurationManager.ConnectionStrings["MaaseDBEntities"].ConnectionString;
                //report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Maase", con));

                Image img = Image.FromFile(Server.MapPath(@"~/Images/logomaster.png"));
                report.Compile();
                string p = Server.MapPath(@"~/TFont");
                report["fontPath"] = p;
                report["logo"]     = img;
                report["PFSID"]    = " where ProducerFinancialStatementID =" + id.ToString();
                report["kol"]      = decimal.Parse(pfs._BurdonsSumPrices.ToString());
                report["albaghi"]  = decimal.Parse(pfs._Creditor.ToString());



                //report.Render();
                report.Render();
                return(StiMvcViewer.GetReportSnapshotResult(report));
            }
            else
            {
                return(RedirectToAction("index"));
            }
        }