public ActionResult Create([Bind(Include = "BankAccountId,TransactionTypeId,BudgetItemId,Description,Amount,Type")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                var houseId = db.BankAccounts.Find(transaction.BankAccountId).HouseholdId;
                transaction.Created     = DateTime.Now;
                transaction.EnteredById = User.Identity.GetUserId();
                db.Transactions.Add(transaction);
                db.SaveChanges();


                //Adjust my Bank Account Balance based on the Transaction type and amount
                BankAccountHelper.AdjustBalance(transaction.Id);

                //Adjust my Budget Balance based on the Transaction type and amount
                BudgetHelper.AdjustBalance(transaction.Id);

                //Adjust my BudgetItem Balance based on the Transaction type and amount
                BudgetItemHelper.AdjustBalance(transaction.Id);

                return(RedirectToAction("Dashboard", "Households", new { id = houseId }));
            }

            ViewBag.BudgetItemId = new SelectList(db.BudgetItems, "Id", "Name", transaction.BudgetItemId);
            return(View(transaction));
        }
Beispiel #2
0
        public async Task <ActionResult> ShowProjectsExceedBudget(string Id)
        {
            ViewBag.User = db.Users.Find(Id);
            var model = new IndexViewModel
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await UserManager.GetPhoneNumberAsync(Id),
                TwoFactor         = await UserManager.GetTwoFactorEnabledAsync(Id),
                Logins            = await UserManager.GetLoginsAsync(Id),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(Id),
                Projects          = BudgetHelper.GetProjectsExceedBudget(db),
            };

            return(View("Index", model));
        }
Beispiel #3
0
        private void BindBudgetEntryJqgrid(HotelDataEntryLib.HotelBudget hotelEntry)
        {
            var userPermission = Session["permission"].ToString();
            var dataEntryList  = BudgetHelper.ListBudgetEntryByYear(hotelEntry);

            JqGridBudgetEntry.DataSource = dataEntryList;
            AppendTotal(dataEntryList);
            JqGridBudgetEntry.DataBind();
            if (!string.IsNullOrEmpty(userPermission))
            {
                if (Convert.ToInt32(userPermission) < 2)
                {
                    JqGridBudgetEntry.ToolBarSettings.ShowEditButton = false;
                }
            }
        }
Beispiel #4
0
        private void ShowData(int propertyId, string y)
        {
            if (string.IsNullOrEmpty(y) || propertyId <= 0)
            {
                lbError.Visible    = true;
                lbCalendar.Visible = true;
                lbCompany.Visible  = true;
            }
            else
            {
                lbError.Visible               = false;
                lbCalendar.Visible            = false;
                lbCompany.Visible             = false;
                divJqgrid.Attributes["style"] = "";

                var username = Session["UserSession"].ToString();
                var user     = UserHelper.GetUser(username);

                if (user.PropertyId == 15)//OHG ID
                {
                    divExportAllData.Attributes["style"] = "";
                }

                var hotelEntry = new HotelDataEntryLib.HotelBudget()
                {
                    PropertyId = propertyId,
                    Year       = Convert.ToInt32(y)
                };

                if (HotelBudgetHelper.ExistYear(hotelEntry))
                {
                    var exsitEntry = HotelBudgetHelper.GetHotelEntry(hotelEntry);
                    BindBudgetEntryJqgrid(exsitEntry);
                }
                else
                {
                    var newEntry = HotelBudgetHelper.AddHotelEntryListByYear(hotelEntry);
                    BudgetHelper.AddBudgetEntryListByYear(newEntry, Session["UserSession"].ToString());
                    BindBudgetEntryJqgrid(newEntry);
                }
            }
        }
Beispiel #5
0
 public ActionResult Void(Transaction transaction)
 {
     if (ModelState.IsValid)
     {
         if (transaction.ReconciledAmount > 0)
         {
             BudgetHelper.VoidAdjustBalance(transaction.ReconciledAmount);
             BankAccountHelper.VoidAdjustBalance(transaction.ReconciledAmount);
         }
         else
         {
             BudgetHelper.VoidAdjustBalance(transaction.TransactionAmount);
             BankAccountHelper.VoidAdjustBalance(transaction.TransactionAmount);
         }
         db.Entry(transaction).State = EntityState.Modified;
         transaction.Void            = true;
         transaction.VoidedById      = User.Identity.GetUserId();
         transaction.VoidTime        = DateTime.Now;
         db.SaveChanges();
         return(RedirectToAction("Details", "Household"));
     }
     return(RedirectToAction("Details", "Household"));
 }
Beispiel #6
0
        protected void JqGridDataEntry_RowEditing(object sender, JQGridRowEditEventArgs e)
        {
            var budgetEntryId = e.RowKey;
            var hotelEntryId  = e.RowData["HotelEntryId"] == "" ? 0 : Convert.ToInt32(e.RowData["HotelEntryId"]);
            var roomBudget    = string.IsNullOrEmpty(e.RowData["RoomBudget"]) ? 0.00 : Convert.ToDouble(e.RowData["RoomBudget"]);
            var fbBudget      = string.IsNullOrEmpty(e.RowData["FBBudget"]) ? 0.00 : Convert.ToDouble(e.RowData["FBBudget"]);
            var spa           = string.IsNullOrEmpty(e.RowData["SpaBudget"]) ? 0.00 : Convert.ToDouble(e.RowData["SpaBudget"]);
            var others        = string.IsNullOrEmpty(e.RowData["Others"]) ? 0.00 : Convert.ToDouble(e.RowData["Others"]);
            var occupancyRoom = 0.0;

            if (string.IsNullOrEmpty(e.RowData["OccupancyRoom"]))
            {
                occupancyRoom = 0;
            }
            else
            {
                var strOccupancy = "";
                strOccupancy  = e.RowData["OccupancyRoom"].Contains("%") ? e.RowData["OccupancyRoom"].Remove(e.RowData["OccupancyRoom"].Length - 1, 1) : e.RowData["OccupancyRoom"];
                occupancyRoom = Convert.ToDouble(strOccupancy);
            }

            var revenueEntry = new BudgetEntry()
            {
                BudgetId      = Convert.ToInt32(budgetEntryId),
                HotelBudgetId = hotelEntryId,
                OccupancyRoom = occupancyRoom,
                RoomBudget    = roomBudget,
                FBBudget      = fbBudget,
                SpaBudget     = spa,
                Others        = others,
                UpdateUser    = Session["UserSession"].ToString(),
                Total         = roomBudget + fbBudget + spa + others
            };

            BudgetHelper.UpdateBudgetEntry(revenueEntry);
        }
        private void pmPrintData()
        {
            string strErrorMsg = "";

            WS.Data.Agents.cDBMSAgent objSQLHelper = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);

            string strFld = "BGTRANHD.CROWID, BGTRANHD.NAMT ";

            strFld += " , BGTRANHD.CISAPPROVE, BGTRANHD.CAPVSTAT, BGTRANHD.CISAPPROV2 , BGTRANHD.CISPOST ";
            strFld += " , BGTRANHD.CISCORRECT ";
            strFld += " , EMSECT.CCODE as QCSECT, EMSECT.CNAME as QNSECT ";
            strFld += " , EMJOB.CCODE as QCJOB, EMJOB.CNAME as QNJOB ";
            strFld += " , BGTRANHD.DCREATE, BGTRANHD.DLASTUPDBY ";
            strFld += " , EM1.CLOGIN as CLOGIN_ADD";
            strFld += " , EM2.CLOGIN as CLOGIN_UPD";
            strFld += " , EM3.CLOGIN as CLOGIN_APV ";
            strFld += " , EM4.CLOGIN as CLOGIN_CORRECT ";
            strFld += " , EM5.CLOGIN as CLOGIN_APVBY ";
            strFld += " , EM6.CLOGIN as CLOGIN_POST ";
            strFld += " , BGTRANHD.DAPPROVE ";
            strFld += " , BGTRANHD.DISCORRECT ";
            strFld += " , BGTRANHD.DAPV ";
            strFld += " , BGTRANHD.DPOST ";

            string strSQLExec = "select " + strFld + " from {0} BGTRANHD ";

            strSQLExec += " left join EMSECT ON EMSECT.CROWID = BGTRANHD.CSECT";
            strSQLExec += " left join EMJOB ON EMJOB.CROWID = BGTRANHD.CJOB ";
            strSQLExec += " left join {1} EM1 ON EM1.CROWID = BGTRANHD.CCREATEBY ";
            strSQLExec += " left join {1} EM2 ON EM2.CROWID = BGTRANHD.CLASTUPDBY ";
            strSQLExec += " left join {1} EM3 ON EM3.CROWID = BGTRANHD.CAPPROVEBY ";
            strSQLExec += " left join {1} EM4 ON EM4.CROWID = BGTRANHD.CCORRECTBY ";
            strSQLExec += " left join {1} EM5 ON EM5.CROWID = BGTRANHD.CAPVBY ";
            strSQLExec += " left join {1} EM6 ON EM6.CROWID = BGTRANHD.CPOSTBY ";
            strSQLExec += " where BGTRANHD.CCORP = ? and BGTRANHD.CBRANCH = ? and BGTRANHD.CSECT = ? and BGTRANHD.NBGYEAR = ? ";
            strSQLExec += " and EMJOB.CCODE between ? and ? ";

            strSQLExec = string.Format(strSQLExec, new string[] { MapTable.Table.BudTranHD, "APPLOGIN" });

            Report.LocalDataSet.DTSPBGSTAT dtsPreviewReport = new Report.LocalDataSet.DTSPBGSTAT();

            objSQLHelper.SetPara(new object[] { App.ActiveCorp.RowID, this.mstrBranch, this.txtQcSect.Tag.ToString(), this.mintYear, this.txtBegQcProj.Text.TrimEnd(), this.txtEndQcProj.Text.TrimEnd() });
            if (objSQLHelper.SQLExec(ref this.dtsDataEnv, "QBGTran", "BGTRANHD", strSQLExec, ref strErrorMsg))
            {
                string strLogin1 = ""; string strStat1 = "";
                string strLogin2 = ""; string strStat2 = "";
                string strLogin3 = ""; string strStat3 = "";
                string strLogin4 = ""; string strStat4 = "";
                foreach (DataRow dtrPBGTran in this.dtsDataEnv.Tables["QBGTran"].Rows)
                {
                    DataRow dtrPreview = dtsPreviewReport.XRPBGSTAT.NewRow();

                    strLogin1 = ""; strStat1 = "";
                    strLogin2 = ""; strStat2 = "";
                    strLogin3 = ""; strStat3 = "";
                    strLogin4 = ""; strStat4 = "";

                    dtrPreview["cQcJob"] = dtrPBGTran["QcJob"].ToString().TrimEnd();
                    dtrPreview["cQnJob"] = dtrPBGTran["QnJob"].ToString().TrimEnd();
                    //
                    if (dtrPBGTran["CISAPPROVE"].ToString() != SysDef.gc_APPROVE_STEP_WAIT)
                    {
                        strLogin1 = dtrPBGTran["CLOGIN_APV"].ToString();
                        strStat1  = "APPROVE";
                        dtrPreview["dApprove1"] = Convert.ToDateTime(dtrPBGTran["DAPPROVE"]);

                        strLogin2 = "-";
                        strStat2  = "WAIT";
                    }
                    else
                    {
                        strLogin1 = "-";
                        strStat1  = "WAIT";
                    }

                    if (dtrPBGTran["CISCORRECT"].ToString() != SysDef.gc_APPROVE_STEP_WAIT)
                    {
                        strLogin2 = dtrPBGTran["CLOGIN_CORRECT"].ToString();
                        strStat2  = "APPROVE";
                        dtrPreview["dApprove2"] = Convert.ToDateTime(dtrPBGTran["DISCORRECT"]);
                        strLogin3 = "-";
                        strStat3  = "WAIT";
                    }
                    else
                    {
                        //strLogin2 = "";
                        //strStat2 = "";
                    }

                    if (dtrPBGTran["CAPVSTAT"].ToString() != SysDef.gc_APPROVE_STEP_WAIT)
                    {
                        strLogin3 = dtrPBGTran["CLOGIN_APVBY"].ToString();
                        strStat3  = BudgetHelper.GetApproveStepText(BudgetHelper.GetApproveStep(dtrPBGTran["CAPVSTAT"].ToString()));

                        if (dtrPBGTran["CAPVSTAT"].ToString() == SysDef.gc_APPROVE_STEP_APPROVE)
                        {
                            strStat3 = "PASS";
                        }
                        dtrPreview["dApprove3"] = Convert.ToDateTime(dtrPBGTran["DAPV"]);
                        strLogin4 = "-";
                        strStat4  = "WAIT";
                    }
                    else
                    {
                        //strLogin3 = "";
                        //strStat3 = "";
                    }

                    if (dtrPBGTran["CISPOST"].ToString() != SysDef.gc_APPROVE_STEP_WAIT)
                    {
                        strLogin4 = dtrPBGTran["CLOGIN_POST"].ToString();
                        strStat4  = "POST";
                        dtrPreview["dApprove4"] = Convert.ToDateTime(dtrPBGTran["DPOST"]);
                    }
                    else
                    {
                        //strLogin4 = "";
                        //strStat4 = "";
                    }

                    dtrPreview["cLogIn1"] = strLogin1;
                    dtrPreview["cLogIn2"] = strLogin2;
                    dtrPreview["cLogIn3"] = strLogin3;
                    dtrPreview["cLogIn4"] = strLogin4;
                    dtrPreview["cStat1"]  = strStat1;
                    dtrPreview["cStat2"]  = strStat2;
                    dtrPreview["cStat3"]  = strStat3;
                    dtrPreview["cStat4"]  = strStat4;

                    dtsPreviewReport.XRPBGSTAT.Rows.Add(dtrPreview);
                }
            }

            if (dtsPreviewReport.XRPBGSTAT.Rows.Count > 0)
            {
                this.pmPreviewReport(dtsPreviewReport);
            }
            else
            {
                MessageBox.Show(this, "ไม่มีข้อมูล", "Application confirm message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #8
0
        private void pmSetBrowView()
        {
            string strErrorMsg = "";

            WS.Data.Agents.cDBMSAgent pobjSQLUtil = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);

            string strSQLExec = "select * from BGChartHD where cPRBGChart = ? order by BGChartHD.cCode";

            if (this.mstrBGChartGrp != string.Empty)
            {
                this.dtsDataEnv.Tables[this.mstrBrowViewAlias].Rows.Clear();

                //"select cPRBGChart from BGChartHD where cPRBGChart = ? order by BGChartHD.cCode"

                decimal decAmt = 0; decimal decRecvAmt = 0; decimal decUseAmt = 0; decimal decBalAmt = 0;
                DataRow dtrBGChart = null;
                string  strPRChart = "";
                pobjSQLUtil.SetPara(new object[] { this.mstrBGChartGrp });
                if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QGrp1", "BGCHARTHD", "select * from BGChartHD where cRowID = ? ", ref strErrorMsg))
                {
                    dtrBGChart = this.dtsDataEnv.Tables["QGrp1"].Rows[0];
                    strPRChart = dtrBGChart["cPRBGChart"].ToString();
                    if (strPRChart.Trim() == string.Empty)
                    {
                        //Parent Chart เป็นว่าง ๆ แสดงว่าเป็นประเภทหมวดซึ่ง Sum ได้เลย
                        BudgetHelper.SuBeSmartMRPGroup(pobjSQLUtil
                                                       , App.ActiveCorp.RowID, this.mstrBranch, this.mstrType, this.mintBGYear, this.mstrSect, this.mstrJob, dtrBGChart["cCode"].ToString()
                                                       , ref decAmt, ref decRecvAmt, ref decUseAmt, ref decBalAmt);

                        DataRow dtrBrow = this.dtsDataEnv.Tables[this.mstrBrowViewAlias].NewRow();
                        dtrBrow["Type"]      = "1";
                        dtrBrow["QcBGChart"] = dtrBGChart["cCode"].ToString();
                        dtrBrow["QnBGChart"] = dtrBGChart["cName"].ToString();
                        dtrBrow["nBGAmt"]    = decAmt;
                        dtrBrow["nUseAmt"]   = decRecvAmt;
                        dtrBrow["nBalAmt"]   = decBalAmt;
                        this.dtsDataEnv.Tables[this.mstrBrowViewAlias].Rows.Add(dtrBrow);
                    }
                    else
                    {
                        pobjSQLUtil.SetPara(new object[] { strPRChart });
                        if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QGrp1", "BGCHARTHD", "select * from BGChartHD where cRowID = ? ", ref strErrorMsg))
                        {
                            dtrBGChart = this.dtsDataEnv.Tables["QGrp1"].Rows[0];
                            BudgetHelper.SuBeSmartMRPGroup(pobjSQLUtil
                                                           , App.ActiveCorp.RowID, this.mstrBranch, this.mstrType, this.mintBGYear, this.mstrSect, this.mstrJob, dtrBGChart["cCode"].ToString()
                                                           , ref decAmt, ref decRecvAmt, ref decUseAmt, ref decBalAmt);

                            DataRow dtrBrow = this.dtsDataEnv.Tables[this.mstrBrowViewAlias].NewRow();
                            dtrBrow["Type"]      = "1";
                            dtrBrow["QcBGChart"] = dtrBGChart["cCode"].ToString();
                            dtrBrow["QnBGChart"] = dtrBGChart["cName"].ToString();
                            dtrBrow["nBGAmt"]    = decAmt;
                            dtrBrow["nUseAmt"]   = decRecvAmt;
                            dtrBrow["nBalAmt"]   = decBalAmt;
                            this.dtsDataEnv.Tables[this.mstrBrowViewAlias].Rows.Add(dtrBrow);
                        }

                        //กรณีมี Parent จะดึงรหัสใน Parent เดียวกันมาแสดง
                        pobjSQLUtil.SetPara(new object[] { strPRChart });
                        if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QGrp1", "BGCHARTHD", "select * from BGChartHD where cPRBGChart = ? ", ref strErrorMsg))
                        {
                            foreach (DataRow dtrP1Brow in this.dtsDataEnv.Tables["QGrp1"].Rows)
                            {
                                dtrBGChart = dtrP1Brow;
                                BudgetHelper.SuBeSmartMRPGroup(pobjSQLUtil
                                                               , App.ActiveCorp.RowID, this.mstrBranch, this.mstrType, this.mintBGYear, this.mstrSect, this.mstrJob, dtrBGChart["cCode"].ToString()
                                                               , ref decAmt, ref decRecvAmt, ref decUseAmt, ref decBalAmt);

                                DataRow dtrBrow = this.dtsDataEnv.Tables[this.mstrBrowViewAlias].NewRow();
                                dtrBrow["Type"]      = "2";
                                dtrBrow["QcBGChart"] = dtrBGChart["cCode"].ToString();
                                dtrBrow["QnBGChart"] = dtrBGChart["cName"].ToString();
                                dtrBrow["nBGAmt"]    = decAmt;
                                dtrBrow["nUseAmt"]   = decRecvAmt;
                                dtrBrow["nBalAmt"]   = decBalAmt;
                                this.dtsDataEnv.Tables[this.mstrBrowViewAlias].Rows.Add(dtrBrow);
                            }
                        }
                    }
                }
            }
        }
Beispiel #9
0
        protected void btnExcelAll_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            var hb = new HotelBudget();

            if (Session["year"] == null)
            {
                return;
            }
            var year   = Convert.ToInt32(Session["year"].ToString());
            var budget = HotelDataEntryLib.Page.BudgetHelper.GetAllPropertyByHotelBudget(year);

            var attachment = "attachment; filename=All Properties" + " Budget " + _year + ".xls";

            Response.ClearContent();
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/vnd.ms-excel";
            for (var i = 0; i < budget.Count; i++)
            {
                Response.Write("[" + budget[i].CurrencyCode + "] " + budget[i].PropertyName + " Budget " + _year);
                Response.Write("\r\n");
                Response.Write("\r\n");

                Response.Write("Month/Year\t");
                Response.Write("Occupancy(%)\t");
                Response.Write("Room Budget\t");
                Response.Write("F & B Budget\t");
                Response.Write("Spa Budget\t");
                Response.Write("Others\t");
                Response.Write("Total\t");
                Response.Write("\n");

                hb.HotelBudgetId = budget[i].HotelBudgetId;
                var listBudget = BudgetHelper.ListBudgetEntryByYear(hb);
                var total      = CalculateTotal(listBudget);
                for (var j = 0; j < listBudget.Count; j++)
                {
                    Response.Write(listBudget[j].PositionMonth + "\t");
                    Response.Write(listBudget[j].OccupancyRoom.ToString("#,##0.00") + "\t");
                    Response.Write(listBudget[j].RoomBudget.ToString("#,##0.00") + "\t");
                    Response.Write(listBudget[j].FBBudget.ToString("#,##0.00") + "\t");
                    Response.Write(listBudget[j].SpaBudget.ToString("#,##0.00") + "\t");
                    Response.Write(listBudget[j].Others.ToString("#,##0.00") + "\t");
                    Response.Write(listBudget[j].Total.ToString("#,##0.00") + "\t");
                    Response.Write("\n");
                }
                Response.Write("Total" + "\t");
                Response.Write("-" + "\t");
                Response.Write(total[0].ToString("#,##0.00") + "\t");
                Response.Write(total[1].ToString("#,##0.00") + "\t");
                Response.Write(total[2].ToString("#,##0.00") + "\t");
                Response.Write(total[3].ToString("#,##0.00") + "\t");
                Response.Write(total[4].ToString("#,##0.00") + "\t");
                Response.Write("\n");
                Response.Write("\n");
                Response.Write("\n");
            }

            Response.Write("\n");
            Response.Write("Print Date: [" + DateTime.Now + "] ");
            Response.Write("\r\n");
            Response.End();
        }
Beispiel #10
0
        protected void btnPDFAll_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            var hb = new HotelBudget();

            if (Session["year"] == null)
            {
                return;
            }
            var year   = Convert.ToInt32(Session["year"].ToString());
            var budget = HotelDataEntryLib.Page.BudgetHelper.GetAllPropertyByHotelBudget(year);

            var attachment = "attachment; filename= All Properties" + " Budget " + _year + ".pdf";
            var pdfDoc     = new Document(PageSize.A4.Rotate(), 30.0f, 5.0f, 40.0f, 0f);
            var pdfStream  = new MemoryStream();
            var pdfWriter  = PdfWriter.GetInstance(pdfDoc, pdfStream);

            pdfDoc.Open();//Open Document to write

            pdfDoc.NewPage();

            var fontH  = FontFactory.GetFont("ARIAL", 9, Font.BOLD);
            var fontT  = FontFactory.GetFont("ARIAL", 12, Font.BOLD);
            var font8  = FontFactory.GetFont("ARIAL", 8);
            var font8B = FontFactory.GetFont("ARIAL", 8, Font.BOLD);


            var prefacedate = new Paragraph {
                new Paragraph("Print Date: [" + DateTime.Now + "] ", font8B)
            };
            var widths = new float[] { 55, 75f, 75f, 72f, 72f, 72f, 72f };


            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            for (var i = 0; i < budget.Count; i++)
            {
                //Begin table
                var pdfTable = new PdfPTable(7);
                pdfTable.HorizontalAlignment = 0;
                pdfTable.TotalWidth          = 781f;
                pdfTable.LockedWidth         = true;
                pdfTable.SetWidths(widths);
                pdfTable.SpacingBefore = 15f; // Give some space after the text or it may overlap the table

                hb.HotelBudgetId = budget[i].HotelBudgetId;
                var listBudget = BudgetHelper.ListBudgetEntryByYear(hb);
                var total      = CalculateTotal(listBudget);
                var preface    = new Paragraph();
                // Header
                preface.Add(new Paragraph("[" + budget[i].CurrencyCode + "] " + budget[i].PropertyName + " Budget " + year, fontT));
                pdfDoc.Add(preface);

                PdfPCell pdfPCell = null;

                //Add Header of the pdf table
                pdfPCell = new PdfPCell(new Phrase(new Chunk("Month/Year", fontH)));
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk("Occupancy(%)", fontH)));
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk("Room Budget", fontH)));
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk("F & B Budget", fontH)));
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk("Spa Budget", fontH)));
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk("Others", fontH)));
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk("Total", fontH)));
                pdfTable.AddCell(pdfPCell);

                //How add the data from datatable to pdf table
                for (var rows = 0; rows < listBudget.Count; rows++)
                {
                    pdfPCell = new PdfPCell(new Phrase(new Chunk(listBudget[rows].PositionMonth, font8)))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    };
                    pdfTable.AddCell(pdfPCell);
                    pdfPCell = new PdfPCell(new Phrase(new Chunk(listBudget[rows].OccupancyRoom.ToString("#,##0.00"), font8)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    };
                    pdfTable.AddCell(pdfPCell);
                    pdfPCell = new PdfPCell(new Phrase(new Chunk(listBudget[rows].RoomBudget.ToString("#,##0.00"), font8)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    };
                    pdfTable.AddCell(pdfPCell);
                    pdfPCell = new PdfPCell(new Phrase(new Chunk(listBudget[rows].FBBudget.ToString("#,##0.00"), font8)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    };
                    pdfTable.AddCell(pdfPCell);
                    pdfPCell = new PdfPCell(new Phrase(new Chunk(listBudget[rows].SpaBudget.ToString("#,##0.00"), font8)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    };
                    pdfTable.AddCell(pdfPCell);
                    pdfPCell = new PdfPCell(new Phrase(new Chunk(listBudget[rows].Others.ToString("#,##0.00"), font8)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    };
                    pdfTable.AddCell(pdfPCell);
                    pdfPCell = new PdfPCell(new Phrase(new Chunk(listBudget[rows].Total.ToString("#,##0.00"), font8)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    };
                    pdfTable.AddCell(pdfPCell);
                }

                pdfPCell = new PdfPCell(new Phrase(new Chunk("Total", font8B)))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                };
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk("-", font8B)))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                };
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk(total[0].ToString("#,##0.00"), font8B)))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                };
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk(total[1].ToString("#,##0.00"), font8B)))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                };
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk(total[2].ToString("#,##0.00"), font8B)))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                };
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk(total[3].ToString("#,##0.00"), font8B)))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                };
                pdfTable.AddCell(pdfPCell);
                pdfPCell = new PdfPCell(new Phrase(new Chunk(total[4].ToString("#,##0.00"), font8B)))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                };
                pdfTable.AddCell(pdfPCell);

                pdfDoc.Add(pdfTable); // add pdf table to the document

                var newLine = new Paragraph();
                newLine.Add(new Paragraph("", fontT));
                preface.Leading = 50.0f;

                pdfDoc.Add(newLine);
            }

            /////////////////////////////////////////////////////////////////////////////////////////////////////////

            pdfDoc.Add(prefacedate);
            pdfDoc.Close();
            pdfWriter.Close();


            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/pdf";
            Response.AppendHeader("Content-Disposition", attachment);
            Response.BinaryWrite(pdfStream.ToArray());
            Response.End();
        }
Beispiel #11
0
 public void AddDetails()
 {
     BudgetHelper.AddBudgetDetails(User.Identity.Name);
 }
Beispiel #12
0
 private decimal Calculate(string start, string end)
 {
     return(BudgetHelper.CalculateTotalBudget(
                MakeDateRange(start, end),
                _budgetList));
 }
Beispiel #13
0
        private void ShowData(int propertyId, string my)
        {
            if (string.IsNullOrEmpty(my) || propertyId <= 0)
            {
                lbError.Visible               = true;
                lbCalendar.Visible            = true;
                lbCompany.Visible             = true;
                divReport.Attributes["style"] = "display:none";
            }
            else
            {
                lbError.Visible               = false;
                lbCalendar.Visible            = false;
                lbCompany.Visible             = false;
                divReport.Attributes["style"] = "";
                divJqgrid.Attributes["style"] = "";

                var username = Session["UserSession"].ToString();
                var user     = UserHelper.GetUser(username);

                if (user.PropertyId == 15)//OHG ID
                {
                    divExportAllData.Attributes["style"] = "";
                }

                var str = my.Split('/');
                if (!string.IsNullOrEmpty(str[0]) && !string.IsNullOrEmpty(str[1]))
                {
                    Session["PropertyIdReport"] = propertyId;              //for reports.aspx property
                    Session["YearReport"]       = Convert.ToInt32(str[1]); //for reports.aspx year
                    var hotelEntry = new HotelDataEntryLib.HotelRevenue()
                    {
                        PropertyId = propertyId,
                        Month      = Convert.ToInt32(str[0]),
                        Year       = Convert.ToInt32(str[1])
                    };

                    if (HotelRevenueHelper.ExistMothYear(hotelEntry))
                    {
                        var exsitEntry = HotelRevenueHelper.GetHotelEntry(hotelEntry);
                        BindDataEntryJqgrid(exsitEntry);
                    }
                    else
                    {
                        var budgetEntry = new HotelBudget()
                        {
                            PropertyId = hotelEntry.PropertyId,
                            Year       = hotelEntry.Year
                        };
                        if (!HotelBudgetHelper.ExistYear(budgetEntry))
                        {
                            var newBudgetEntry = HotelBudgetHelper.AddHotelEntryListByYear(budgetEntry);
                            BudgetHelper.AddBudgetEntryListByYear(newBudgetEntry, Session["UserSession"].ToString());
                        }
                        var newEntry = HotelRevenueHelper.AddHotelEntryListByMonthYear(hotelEntry);
                        RevenueHelper.AddRevenueEntryListByMonthYear(newEntry, Session["UserSession"].ToString());
                        BindDataEntryJqgrid(newEntry);
                    }
                }
            }
        }
Beispiel #14
0
 public void SetUp()
 {
     _budgetHelper  = new BudgetHelper();
     _budgetBuilder = new BudgetBuilder();
 }