예제 #1
0
 protected void BtnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         int DeleteId = 0;
         if (ViewState["EditID"] != null)
         {
             DeleteId = Convert.ToInt32(ViewState["EditID"]);
         }
         if (DeleteId != 0)
         {
             Entity_SL.StockLocationID = DeleteId;
             Entity_SL.UserId          = Convert.ToInt32(Session["UserID"]);
             Entity_SL.LoginDate       = DateTime.Now;
             Entity_SL.IsDeleted       = true;
             int iDelete = Obj_SL.DeleteRecord(ref Entity_SL, out StrError);
             if (iDelete != 0)
             {
                 obj_Comm.ShowPopUpMsg("Record Deleted Successfully..!", this.Page);
                 MakeEmptyForm();
             }
         }
         Entity_SL = null;
         obj_Comm  = null;
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
예제 #2
0
    protected void BtnUpdate_Click(object sender, EventArgs e)
    {
        int UpdateRow = 0;

        try
        {
            if (ViewState["EditID"] != null)
            {
                Entity_SL.StockLocationID = Convert.ToInt32(ViewState["EditID"]);
            }
            Entity_SL.Location  = TxtCostCentre.Text.Trim();
            Entity_SL.SiteId    = Convert.ToInt32(ddlSite.SelectedValue);
            Entity_SL.TowerId   = Convert.ToInt32(ddlTower.SelectedValue);
            Entity_SL.CompanyId = 0;

            Entity_SL.UserId    = Convert.ToInt32(Session["UserId"]);
            Entity_SL.LoginDate = DateTime.Now;
            UpdateRow           = Obj_SL.UpdateRecord(ref Entity_SL, out StrError);

            if (UpdateRow != 0)
            {
                obj_Comm.ShowPopUpMsg("Record Updated Successfully", this.Page);
                MakeEmptyForm();
                Entity_SL = null;
                obj_Comm  = null;
            }
        }

        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
예제 #3
0
        public async Task <IActionResult> PutCostCentre(int id, CostCentre costCentre)
        {
            if (id != costCentre.Id)
            {
                return(BadRequest());
            }

            _context.Entry(costCentre).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CostCentreExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #4
0
        public async Task <ActionResult <CostCentre> > PostCostCentre(CostCentre costCentre)
        {
            _context.CostCentres.Add(costCentre);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCostCentre", new { id = costCentre.Id }, costCentre));
        }
예제 #5
0
        private void PopulateOPCostCentre()
        {
            DataTable dtOpCC = new DataTable();

            dtOpCC = FlatTypeBL.GetOpCostCentre();

            DataRow dr = null;

            dr = dtOpCC.NewRow();
            dr["CostCentreId"]   = 0;
            dr["CostCentreName"] = "None";
            dr["Typewise"]       = false;
            dtOpCC.Rows.InsertAt(dr, 0);

            if (dtOpCC.Rows.Count > 0)
            {
                CostCentre.DataSource = dtOpCC;
                CostCentre.PopulateColumns();
                CostCentre.DisplayMember = "CostCentreName";
                CostCentre.ValueMember   = "CostCentreId";
                CostCentre.Columns["CostCentreId"].Visible = false;
                CostCentre.Columns["Typewise"].Visible     = false;
                CostCentre.ShowFooter = false;
                CostCentre.ShowHeader = false;
            }
            cboCostCentre.EditValue = 0;
        }
예제 #6
0
 public bool SaveCostCentre(CostCentreModel model)
 {
     try
     {
         if (model != null)
         {
             CostCentre costCentre = new CostCentre
             {
                 costcentrename = model.costcentrename,
                 remark         = model.remark,
                 isActive       = true,
             };
             tRSEntities4.CostCentres.Add(costCentre);
             tRSEntities4.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            CostCentre costCentre = db.CostCentres.Find(id);

            db.CostCentres.Remove(costCentre);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public HttpResponseMessage UpdateCostCentre(HttpRequestMessage request, [FromBody] CostCentre costCentreModel)
        {
            return(GetHttpResponse(request, () =>
            {
                var costCentre = _MPROPEXService.UpdateCostCentre(costCentreModel);

                return request.CreateResponse <CostCentre>(HttpStatusCode.OK, costCentre);
            }));
        }
        public void GivenNullValue_ThenTheCostCentreShouldBeGreater()
        {
            var costCentre1 = new CostCentre()
            {
                Tier1 = "1"
            };
            var result = costCentre1.CompareTo(null) > 0;

            Assert.That(result, Is.True);
        }
예제 #10
0
        public int InsertRecord(ref CostCentre Entity_call, out string strError)
        {
            int iInsert = 0;

            strError = string.Empty;
            try
            {
                SqlParameter pAction   = new SqlParameter(CostCentre._Action, SqlDbType.BigInt);
                SqlParameter pLocation = new SqlParameter(CostCentre._Location, SqlDbType.NVarChar);
                SqlParameter pSiteId   = new SqlParameter(CostCentre._SiteId, SqlDbType.BigInt);
                SqlParameter pTowerId  = new SqlParameter(CostCentre._TowerId, SqlDbType.BigInt);

                SqlParameter pCreatedBy   = new SqlParameter(CostCentre._UserId, SqlDbType.BigInt);
                SqlParameter PCreatedDate = new SqlParameter(CostCentre._LoginDate, SqlDbType.DateTime);
                SqlParameter pIsDeleted   = new SqlParameter(CostCentre._IsDeleted, SqlDbType.Bit);

                pAction.Value   = 1;
                pLocation.Value = Entity_call.Location;
                pSiteId.Value   = Entity_call.SiteId;
                pTowerId.Value  = Entity_call.TowerId;

                pCreatedBy.Value   = Entity_call.UserId;
                PCreatedDate.Value = Entity_call.LoginDate;
                pIsDeleted.Value   = Entity_call.IsDeleted;

                SqlParameter[] param = new SqlParameter[] { pAction, pLocation, pSiteId, pTowerId, pCreatedBy, PCreatedDate, pIsDeleted };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, CostCentre.SP_CostCentre, param);

                if (iInsert > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }

            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }

            finally
            {
                Close();
            }
            return(iInsert);
        }
예제 #11
0
    public static CostCentre[] GetChildren(DataTable dt, string query)
    {
        DataRow[] foundRows = dt.Select(query);
        CostCentre[] children = new CostCentre[foundRows.Length];
        for (int i = 0; i < foundRows.Length; i++)
        {
            CostCentre cc = CostCentreDB.Load(foundRows[i]);
            cc.Children = GetChildren(dt, "parent_id = " + cc.CostCentreID.ToString());
            children[i] = cc;
        }

        return children;
    }
예제 #12
0
    public static CostCentre[] GetChildren(DataTable dt, string query)
    {
        DataRow[] foundRows = dt.Select(query);
        CostCentre[] children = new CostCentre[foundRows.Length];
        for (int i = 0; i < foundRows.Length; i++)
        {
            CostCentre cc = CostCentreDB.Load(foundRows[i]);
            cc.Children = GetChildren(dt, "parent_id = " + cc.CostCentreID.ToString());
            children[i] = cc;
        }

        return children;
    }
예제 #13
0
        //GET
        public ActionResult Create()
        {
            //mock up. todo create and call the WS to get all cost centres
            var c = new CostCentre();

            c.CostCentreId     = "101";
            c.Name             = "Centro1";
            ViewBag.costcentre = new List <CostCentre>()
            {
                c
            };

            return(View());
        }
        public HttpResponseMessage GetCostCentre(HttpRequestMessage request, int costCentreId)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                CostCentre costCentre = _MPROPEXService.GetCostCentre(costCentreId);

                // notice no need to create a seperate model object since CostCentre entity will do just fine
                response = request.CreateResponse <CostCentre>(HttpStatusCode.OK, costCentre);

                return response;
            }));
        }
        // GET: CostCentres/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CostCentre costCentre = db.CostCentres.Find(id);

            if (costCentre == null)
            {
                return(HttpNotFound());
            }
            return(View(costCentre));
        }
예제 #16
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CostCentre = await _context.CostCentres.FirstOrDefaultAsync(m => m.Id == id);

            if (CostCentre == null)
            {
                return(NotFound());
            }
            return(Page());
        }
예제 #17
0
        public int DeleteRecord(ref CostCentre EntityCall, out string StrError)
        {
            int iDelete = 0;

            StrError = string.Empty;
            try
            {
                SqlParameter pAction          = new SqlParameter(CostCentre._Action, SqlDbType.BigInt);
                SqlParameter pStockLocationId = new SqlParameter(CostCentre._StockLocationID, SqlDbType.BigInt);
                SqlParameter pDeletedBy       = new SqlParameter(CostCentre._UserId, SqlDbType.BigInt);
                SqlParameter pDeletedDate     = new SqlParameter(CostCentre._LoginDate, SqlDbType.DateTime);
                SqlParameter pIsDeleted       = new SqlParameter(CostCentre._IsDeleted, SqlDbType.Bit);

                pAction.Value          = 3;
                pStockLocationId.Value = EntityCall.StockLocationID;
                pDeletedBy.Value       = EntityCall.UserId;
                pDeletedDate.Value     = EntityCall.LoginDate;
                pIsDeleted.Value       = EntityCall.IsDeleted;

                SqlParameter[] param = new SqlParameter[] { pAction, pStockLocationId, pDeletedBy, pDeletedDate, pIsDeleted };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iDelete = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, CostCentre.SP_CostCentre, param);

                if (iDelete > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                StrError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iDelete);
        }
        public ActionResult Create([Bind(Include = "Code,CCName,Enbld")] CostCentre costCentre)
        {
            if (ModelState.IsValid)
            {
                Person userperson = db.People.SingleOrDefault(p => p.ID == 0);
                costCentre.Creator  = userperson;
                costCentre.Created  = DateTime.Now;
                costCentre.Modifier = userperson;
                costCentre.Modified = DateTime.Now;
                db.CostCentres.Add(costCentre);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            return(View(costCentre));
        }
예제 #19
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CostCentre = await _context.CostCentres.FindAsync(id);

            if (CostCentre != null)
            {
                _context.CostCentres.Remove(CostCentre);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
예제 #20
0
    private bool ChildrenContains(CostCentre thisNode, int parentID)
    {
        foreach (CostCentre cc in thisNode.Children)
        {
            if (cc.CostCentreID == parentID)
            {
                return(true);
            }

            bool cc2 = ChildrenContains(cc, parentID);
            if (cc2)
            {
                return(true);
            }
        }

        return(false);
    }
예제 #21
0
        protected override OpResult _Store(CostCentre _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "CostCentre object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            _obj.FromDb = true;

            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
예제 #22
0
    private CostCentre GetRoot(CostCentre[] tree, int costCentreID)
    {
        foreach (CostCentre cc in tree)
        {
            if (cc.CostCentreID == costCentreID)
            {
                return(cc);
            }

            CostCentre cc2 = GetRoot(cc.Children, costCentreID);
            if (cc2 != null)
            {
                return(cc2);
            }
        }

        return(null);
    }
        public ActionResult Edit([Bind(Include = "Code,CCName,Enbld")] CostCentre costCentre)
        {
            if (ModelState.IsValid)
            {
                CostCentre ccInDB = db.CostCentres.Single(c => c.Code == costCentre.Code);
                ccInDB.CCName = costCentre.CCName;
                ccInDB.Enbld  = costCentre.Enbld;

                Person userperson = db.People.SingleOrDefault(p => p.ID == 0);
                ccInDB.Modifier = userperson;
                ccInDB.Modified = DateTime.Now;

                //db.Entry(costCentre).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(costCentre));
        }
        public static bool Matches(this CostCentre costCentre, BcrOptions options)
        {
            if (!HasOption(options.Tier1) &&
                !HasOption(options.Tier2) &&
                !HasOption(options.Tier3) &&
                !HasOption(options.Tier4) &&
                !HasOption(options.CostCentre))
            {
                return(true);
            }

            var matchesTier1      = HasOption(options.Tier1) && Matches(options.Tier1, costCentre.Tier1);
            var matchesTier2      = HasOption(options.Tier2) && Matches(options.Tier2, costCentre.Tier2);
            var matchesTier3      = HasOption(options.Tier3) && Matches(options.Tier3, costCentre.Tier3);
            var matchesTier4      = HasOption(options.Tier4) && Matches(options.Tier4, costCentre.Tier4);
            var matchesCostCentre = HasOption(options.CostCentre) && Matches(options.CostCentre, costCentre.Code);

            return(matchesTier1 || matchesTier2 || matchesTier3 || matchesTier4 || matchesCostCentre);
        }
예제 #25
0
 public AccountOpResponse()
 {
     financialInfo        = new FinancialInfoModel();
     costCentre           = new CostCentre();
     eventLogger          = new EventLogger();
     creditAssesOperation = new CreditAssesOperation();
     tempCreditCtrl       = new TempCreditCtrlModel();
     upToDateBal          = new UpToDateBal();
     productDiscount      = new ProductDiscount();
     PaymentTxn           = new PaymentTxn();
     costCentres          = new List <CostCentre>();
     WebSecDepRemarks     = new List <RemarkHistory>();
     creditLimitHistories = new List <CreditLimitHistory>();
     financilInfoItems    = new List <FinancilInfoItemsList>();
     eventLoggers         = new List <EventLogger>();
     productDiscounts     = new List <ProductDiscount>();
     onlineTransactions   = new List <OnlineTransaction>();
     PaymentTxns          = new List <PaymentTxn>();
     BillingItems         = new List <BillingItem>();
 }
예제 #26
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        int InsertRow = 0;

        try
        {
            DS = Obj_SL.ChkDuplicate(TxtCostCentre.Text.Trim(), out StrError);

            if (DS.Tables[0].Rows.Count > 0)
            {
                obj_Comm.ShowPopUpMsg("Cost Location Name Already Exist..!", this.Page);
                TxtCostCentre.Focus();
            }
            else
            {
                Entity_SL.Location  = TxtCostCentre.Text.Trim();
                Entity_SL.SiteId    = Convert.ToInt32(ddlSite.SelectedValue);
                Entity_SL.TowerId   = Convert.ToInt32(ddlTower.SelectedValue);
                Entity_SL.CompanyId = 0;
                Entity_SL.UserId    = Convert.ToInt32(Session["UserId"]);
                Entity_SL.LoginDate = DateTime.Now;
                Entity_SL.IsDeleted = false;
                InsertRow           = Obj_SL.InsertRecord(ref Entity_SL, out StrError);

                if (InsertRow != 0)
                {
                    obj_Comm.ShowPopUpMsg("Record Saved Successfully", this.Page);
                    MakeEmptyForm();
                    Entity_SL = null;
                    obj_Comm  = null;
                }
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
예제 #27
0
파일: Staff.cs 프로젝트: mcep/Mediclinic
 public Staff(int staff_id, int person_id, string login, string pwd, int staff_position_id, int field_id, int costcentre_id,
             bool is_contractor, string tfn, string provider_number, bool is_fired, bool is_commission, decimal commission_percent,
             bool is_stakeholder, bool is_master_admin, bool is_admin, bool is_principal, bool is_provider, bool is_external,
             DateTime staff_date_added, DateTime start_date, DateTime end_date, string comment,
             int num_days_to_display_on_booking_screen, bool show_header_on_booking_screen, int bk_screen_field_id, 
             bool bk_screen_show_key, bool enable_daily_reminder_sms, bool enable_daily_reminder_email, bool hide_booking_notes)
 {
     this.staff_id                      = staff_id;
     this.person                        = new Person(person_id);
     this.login                         = login;
     this.pwd                           = pwd;
     this.staffPosition                 = new StaffPosition(staff_position_id);
     this.field                         = new IDandDescr(field_id);
     this.costCentre                    = new CostCentre(costcentre_id);
     this.is_contractor                 = is_contractor;
     this.tfn                           = tfn;
     this.provider_number               = provider_number;
     this.is_fired                      = is_fired;
     this.is_commission                 = is_commission;
     this.commission_percent            = commission_percent;
     this.is_stakeholder                = is_stakeholder;
     this.is_master_admin               = is_master_admin;
     this.is_admin                      = is_admin;
     this.is_principal                  = is_principal;
     this.is_provider                   = is_provider;
     this.is_external                   = is_external;
     this.staff_date_added              = staff_date_added;
     this.start_date                    = start_date;
     this.end_date                      = end_date;
     this.comment                       = comment;
     this.num_days_to_display_on_booking_screen = num_days_to_display_on_booking_screen;
     this.show_header_on_booking_screen = show_header_on_booking_screen;
     this.bk_screen_field               = bk_screen_field_id == -1 ? null : new IDandDescr(bk_screen_field_id);
     this.bk_screen_show_key            = bk_screen_show_key;
     this.enable_daily_reminder_sms     = enable_daily_reminder_sms;
     this.enable_daily_reminder_email   = enable_daily_reminder_email;
     this.hide_booking_notes            = hide_booking_notes;
 }
예제 #28
0
    protected void GrdCostCentre_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label        lblId     = (Label)GrdCostCentre.Rows[e.RowIndex].FindControl("lblId");
        DropDownList ddlParent = (DropDownList)GrdCostCentre.Rows[e.RowIndex].FindControl("ddlParent");
        TextBox      txtDescr  = (TextBox)GrdCostCentre.Rows[e.RowIndex].FindControl("txtDescr");


        // make sure we are not parent up the line of parent_id
        CostCentre[] tree     = CostCentreDB.GetTree();
        CostCentre   thisNode = GetRoot(tree, Convert.ToInt32(lblId.Text));

        if (ChildrenContains(thisNode, Convert.ToInt32(ddlParent.SelectedValue)))
        {
            lblErrorMessage.Visible = true;
            lblErrorMessage.Text    = "Can not add this parent because this is already a child";
            return;
        }

        CostCentreDB.Update(Convert.ToInt32(lblId.Text), txtDescr.Text, Convert.ToInt32(ddlParent.SelectedValue));

        GrdCostCentre.EditIndex = -1;
        FillGrid();
    }
        public HttpResponseMessage DeleteCostCentre(HttpRequestMessage request, [FromBody] int costCentreId)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                // not that calling the WCF service here will authenticate access to the data
                CostCentre costCentre = _MPROPEXService.GetCostCentre(costCentreId);

                if (costCentre != null)
                {
                    _MPROPEXService.DeleteCostCentre(costCentreId);

                    response = request.CreateResponse(HttpStatusCode.OK);
                }
                else
                {
                    response = request.CreateErrorResponse(HttpStatusCode.NotFound, "No costCentre found under that ID.");
                }

                return response;
            }));
        }
    private CostCentre GetRoot(CostCentre[] tree, int costCentreID)
    {
        foreach (CostCentre cc in tree)
        {
            if (cc.CostCentreID == costCentreID)
                return cc;

            CostCentre cc2 = GetRoot(cc.Children, costCentreID);
            if (cc2 != null)
                return cc2;
        }

        return null;
    }
예제 #31
0
        public DashboardSummary CreateSummary(
            DashboardRequest request,
            SliceDataModel[] sliceData,
            ActivityGroup[] activities,
            CostCentre centre)
        {
            var configuration = Configurations[request.Section];
            var uomLong       = string.Empty;
            var showCo2       = false;
            var groupNodes    = activities.Select(a => a.Node).ToArray();
            var summary       = new DashboardSummary
            {
                costCentre    = centre.Name,
                activityGroup = (request.ActivityGroupId == null)
                    ? configuration.DisplayName
                    : activities[0].Name,
                displayTotal = true
            };
            var slices = sliceData
                         .OrderBy(s => s.OrderId)
                         .Select(s =>
            {
                var slice = new SliceModel
                {
                    activityGroupId = s.ActivityGroupId,
                    color           = s.Color,
                    costCode        = s.CostCode,
                    description     = s.Description,
                    title           = s.Title,
                    sliceId         = CreateSliceId(s.ActivityGroupId, s.CostCode),
                };
                var noUnits =
                    (string.IsNullOrEmpty(s.UomShort)) ||
                    (string.IsNullOrEmpty(s.UomLong));

                if (configuration.ShowCo2 || noUnits)
                {
                    showCo2        = true;
                    slice.co2label = Constants.Constants.Co2LabelShort;
                    slice.amount   = GetTotal(
                        TotalEmissions,
                        request.StartDate,
                        request.EndDate,
                        s.ActivityGroupNode,
                        s.CentreNode,
                        groupNodes) / 1000;
                }
                if (configuration.ShowCo2 && !noUnits)
                {
                    slice.uom   = s.UomShort;
                    slice.units = GetTotal(
                        TotalUnits,
                        request.StartDate,
                        request.EndDate,
                        s.ActivityGroupNode,
                        s.CentreNode,
                        groupNodes);
                }
                if (!configuration.ShowCo2 && !noUnits)
                {
                    slice.co2label = s.UomShort;
                    uomLong        = s.UomLong;
                    slice.amount   = GetTotal(
                        TotalUnits,
                        request.StartDate,
                        request.EndDate,
                        s.ActivityGroupNode,
                        s.CentreNode,
                        groupNodes);
                }
                return(slice);
            }).ToArray();

            decimal lastYearTotal;
            decimal totalAmount;

            if (showCo2)
            {
                totalAmount = GetTotal(
                    TotalEmissions,
                    request.StartDate,
                    request.EndDate,
                    null,
                    centre.Node,
                    groupNodes) / 1000;
                lastYearTotal = GetTotal(
                    TotalEmissions,
                    request.StartDate.AddYears(-1),
                    request.EndDate.AddYears(-1),
                    null,
                    centre.Node,
                    groupNodes) / 1000;
            }
            else
            {
                totalAmount = GetTotal(
                    TotalUnits,
                    request.StartDate,
                    request.EndDate,
                    null,
                    centre.Node,
                    groupNodes);
                lastYearTotal = GetTotal(
                    TotalUnits,
                    request.StartDate.AddYears(-1),
                    request.EndDate.AddYears(-1),
                    null,
                    centre.Node,
                    groupNodes);
            }

            var yoy = (lastYearTotal == 0)
                ? 0
                : ((totalAmount - lastYearTotal) / lastYearTotal) * 100;
            var currencies = GetCurrencies(
                request.StartDate,
                request.EndDate,
                groupNodes,
                centre.Node);

            summary.co2label = (showCo2)
                ? Constants.Constants.Co2LabelLong
                : uomLong;
            summary.currencies = currencies;
            summary.slices     = slices;
            summary.total      = totalAmount;
            summary.yoy        = yoy;
            return(summary);
        }
    private bool ChildrenContains(CostCentre thisNode, int parentID)
    {
        foreach (CostCentre cc in thisNode.Children)
        {
            if (cc.CostCentreID == parentID)
                return true;

            bool cc2 = ChildrenContains(cc, parentID);
            if (cc2)
                return true;
        }

        return false;
    }
예제 #33
0
 private DbUpdateStatement GetQuery_UpdateQuery(CostCentre _obj)
 {
     return(DbMgr.CreateUpdateClause("CostCentres", GetFields(_obj), "CostCentreID", _obj.CostCentreID));
 }
예제 #34
0
        private DbInsertStatement GetQuery_InsertQuery(CostCentre _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

            return(DbMgr.CreateInsertClause("CostCentres", fields));
        }
 public void AddToCostCentres(CostCentre costCentre)
 {
     base.AddObject("CostCentres", costCentre);
 }
 public static CostCentre CreateCostCentre(long ID, global::System.Guid tid, string name, long createdById, long modifiedById, global::System.DateTimeOffset created, global::System.DateTimeOffset modified)
 {
     CostCentre costCentre = new CostCentre();
     costCentre.Id = ID;
     costCentre.Tid = tid;
     costCentre.Name = name;
     costCentre.CreatedById = createdById;
     costCentre.ModifiedById = modifiedById;
     costCentre.Created = created;
     costCentre.Modified = modified;
     return costCentre;
 }
    private ArrayList Flatten(CostCentre[] children, string parent_descr, string parent_id, int level)
    {
        ArrayList list = new ArrayList();
        foreach (CostCentre cc in children)
        {
            Hashtable h = new Hashtable();
            h["costcentre_id"] = cc.CostCentreID;
            h["descr"] = cc.Descr;
            h["parent_id"] = parent_id;
            h["parent_descr"] = parent_descr;
            h["level"] = level;
            list.Add(h);

            CostCentre[] kids = cc.Children;
            ArrayList kidslist = Flatten(kids, cc.Descr, cc.CostCentreID.ToString(), level + 1);
            list.AddRange(kidslist);
        }

        return list;
    }