void lsvInstrument_OnSubitemTextChanged(object sender, SubitemTextEventArgs e)
        {
            ListViewItem               li  = e.ListVItem;
            LQTListViewTag             tag = (LQTListViewTag)li.Tag;
            ForecastCategoryInstrument si;

            if (tag.Id <= 0)
            {
                si = (ForecastCategoryInstrument)_fCategoryInstrument[tag.Index];
            }
            else
            {
                si = _fCategoryInstrument[_fCategoryInstrument.IndexOf(DataRepository.GetFCInstrumentById(tag.Id))];
            }
            try
            {
                if (li.SubItems[1].Text == "0")
                {
                    li.SubItems[1].Text = "100";
                }
                decimal testRun = decimal.Parse(li.SubItems[1].Text);
                if (testRun >= 0)
                {
                    si.TestRunPercentage = testRun;
                }
                else
                {
                    li.SubItems[1].Text = si.TestRunPercentage.ToString();
                }
            }
            catch
            {
                li.SubItems[1].Text = si.TestRunPercentage.ToString();
            }
        }
Пример #2
0
        void lsvProductUsageI_OnSubitemTextChanged(object sender, SubitemTextEventArgs e)
        {
            LQTListViewTag  tag = (LQTListViewTag)e.ListVItem.Tag;
            ListViewItem    li  = e.ListVItem;
            ConsumableUsage cu;// = (ProductUsage)li.Tag;

            if (tag.Id > 0)
            {
                cu = _consum.GetConsumableUsage(tag.Id);
            }
            else
            {
                // cu = _consum.ConsumableUsages[tag.Index];
                cu = _consum.GetPerInstrumentUsage()[tag.Index];
            }


            try
            {
                decimal rate = decimal.Parse(li.SubItems[2].Text);
                cu.ProductUsageRate = rate;
            }
            catch
            {
                li.SubItems[1].Text = cu.ProductUsageRate.ToString();
            }

            if (OnDataUsageEdit != null)
            {
                OnDataUsageEdit(this, new EventArgs());
            }
        }
Пример #3
0
        private void butRemoveI_Click(object sender, EventArgs e)
        {
            LQTListViewTag tag = (LQTListViewTag)lsvProductUsageI.SelectedItems[0].Tag;

            ConsumableUsage cu;

            if (lsvProductUsageI.SelectedItems.Count > 0)
            {
                if ((MessageBox.Show("Are you sure, do you want to remove it?", "Product Usage", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) == DialogResult.Yes)
                {
                    if (tag.Id > 0)
                    {
                        cu = _consum.GetConsumableUsage(tag.Id);
                    }
                    else
                    {
                        // cu = _consum.ConsumableUsages[tag.Index];
                        cu = _consum.GetPerInstrumentUsage()[tag.Index];
                    }
                    _consum.ConsumableUsages.Remove(cu);

                    BindProductUsageI();
                    if (OnDataUsageEdit != null)
                    {
                        OnDataUsageEdit(this, new EventArgs());
                    }
                }
            }
        }
Пример #4
0
        private void BindProcurement()
        {
            lvproductQinstock.Items.Clear();
            lvproductQinstock.BeginUpdate();
            int index = 0;

            foreach (MorbiditySupplyProcurement p in _supplyProcurement)
            {
                LQTListViewTag tag = new LQTListViewTag();
                tag.GroupTitle = (p.PlatformEnum.ToString());
                tag.Id         = p.Id;
                tag.Index      = index;
                MasterProduct product = DataRepository.GetProductById(p.ProductId);

                ListViewItem li = new ListViewItem(product.ProductName)
                {
                    Tag = tag
                };

                li.SubItems.Add(p.PackSize.ToString());
                li.SubItems.Add(product.BasicUnit);
                li.SubItems.Add(p.QuantityNeeded.ToString());
                li.SubItems.Add(p.QuantityInStock.ToString());
                li.SubItems.Add(p.QuantityToPurchase.ToString());
                li.SubItems.Add(string.Format("{0:C}", p.UnitCost).ToString());
                li.SubItems.Add(string.Format("{0:C}", p.TotalCost).ToString());

                LqtUtil.AddItemToGroup(lvproductQinstock, li);

                lvproductQinstock.Items.Add(li);
                index++;
            }

            lvproductQinstock.EndUpdate();
        }
Пример #5
0
        private void BindProductUsageI()
        {
            lsvProductUsageI.BeginUpdate();
            lsvProductUsageI.Items.Clear();

            int index = 0;

            foreach (ConsumableUsage r in _consum.ConsumableUsages)
            {
                if (r.PerInstrument == true)
                {
                    LQTListViewTag tag = new LQTListViewTag();
                    tag.GroupTitle = r.Instrument.InstrumentName;
                    tag.Id         = r.Id;
                    tag.Index      = index;
                    ListViewItem li = new ListViewItem(r.Product.ProductName)
                    {
                        Tag = tag
                    };

                    li.SubItems.Add(r.Period.ToString());
                    li.SubItems.Add(r.ProductUsageRate.ToString());

                    LqtUtil.AddItemToGroup(lsvProductUsageI, li);
                    lsvProductUsageI.Items.Add(li);
                    index++;
                }
            }

            lsvProductUsageI.EndUpdate();
        }
Пример #6
0
        private void PopInstruments()
        {
            lsvInstrument.BeginUpdate();
            lsvInstrument.Items.Clear();

            int index = 0;

            foreach (SiteInstrument s in _site.SiteInstruments)
            {
                LQTListViewTag tag = new LQTListViewTag();
                tag.Id    = s.Id;
                tag.Index = index;

                ListViewItem li = new ListViewItem(s.Instrument.TestingArea.AreaName)
                {
                    Tag = tag
                };
                li.SubItems.Add(s.Instrument.InstrumentName);
                li.SubItems.Add(s.Quantity.ToString());
                li.SubItems.Add(s.TestRunPercentage.ToString());
                lsvInstrument.Items.Add(li);
                index++;
            }
            if (_site.SiteInstruments.Count <= 0)
            {
                lbtRemove.Enabled = false;
            }
            lsvInstrument.EndUpdate();
        }
        private void lbtRemove_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (lsvInstrument.SelectedItems.Count > 0)
            {
                //LQTListViewTag tag = (LQTListViewTag)lsvInstrument.SelectedItems[0].Tag;
                foreach (ListViewItem lvi in lsvInstrument.SelectedItems)
                {
                    LQTListViewTag             tag = (LQTListViewTag)lvi.Tag;
                    ForecastCategoryInstrument si;
                    if (tag.Id > 0)
                    {
                        si = DataRepository.GetForecastCategoryInstrumentById(tag.Id);
                    }
                    else
                    {
                        si = (ForecastCategoryInstrument)_fCategoryInstrument[tag.Index];
                    }
                    //_fCategoryInstrument.Remove(si);
                    DataRepository.DeleteForecastCategoryInstrument(si);
                    // DataRepository.SaveOrUpdateForecastCategoryInstrument(si);
                }

                _fCategoryInstrument = DataRepository.GetFCInstrumentByFinfoId(_Fid);

                PopInstruments();
            }
        }
        private void PopInstruments()
        {
            // _fCategoryInstrument = DataRepository.GetFCInstrumentByFinfoId(_Fid);

            lsvInstrument.BeginUpdate();
            lsvInstrument.Items.Clear();

            int index = 0;

            foreach (ForecastCategoryInstrument s in _fCategoryInstrument)
            {
                LQTListViewTag tag = new LQTListViewTag();
                tag.Id         = s.Id;
                tag.Index      = index;
                tag.GroupTitle = s.Instrument.TestingArea.AreaName;

                ListViewItem li = new ListViewItem(s.Instrument.InstrumentName)
                {
                    Tag = tag
                };
                //i.SubItems.Add(s.Instrument.InstrumentName);
                li.SubItems.Add(s.TestRunPercentage.ToString());
                LqtUtil.AddItemToGroup(lsvInstrument, li);
                lsvInstrument.Items.Add(li);
                index++;
            }
            if (_fCategoryInstrument.Count <= 0)
            {
                lbtRemove.Enabled = false;
            }
            lsvInstrument.EndUpdate();
        }
Пример #9
0
        void lsvInstrument_OnSubitemTextChanged(object sender, SubitemTextEventArgs e)
        {
            ListViewItem   li  = e.ListVItem;// (ListViewItem)sender;
            LQTListViewTag tag = (LQTListViewTag)li.Tag;
            SiteInstrument si;

            if (tag.Id <= 0)
            {
                si = (SiteInstrument)_site.SiteInstruments[tag.Index];
            }
            else
            {
                si = _site.GetSiteInstrumentById(tag.Id);
            }

            try
            {
                int qty = int.Parse(li.SubItems[2].Text);
                if (qty >= 0)
                {
                    si.Quantity = qty;
                }
                else
                {
                    li.SubItems[2].Text = si.Quantity.ToString();
                }

                decimal testRun = decimal.Parse(li.SubItems[3].Text);
                if (testRun >= 0)
                {
                    si.TestRunPercentage = testRun;
                }
                else
                {
                    li.SubItems[3].Text = si.TestRunPercentage.ToString();
                }
            }
            catch
            {
                li.SubItems[3].Text = si.TestRunPercentage.ToString();
                li.SubItems[2].Text = si.Quantity.ToString();
            }

            if (OnDataUsageEdit != null)
            {
                OnDataUsageEdit(this, new EventArgs());
            }
        }
Пример #10
0
        private void lvproductQinstock_SubitemTextChanged(object sender, SubitemTextEventArgs e)
        {
            ListViewItem li = e.ListVItem;

            LQTListViewTag tag = (LQTListViewTag)li.Tag;

            MorbiditySupplyProcurement msp;

            if (tag.Id <= 0)
            {
                msp = (MorbiditySupplyProcurement)_supplyProcurement[tag.Index];
            }
            else
            {
                msp = DataRepository.GetMorbiditySupplyProcurementById(tag.Id);
            }


            double newvalue = double.Parse(li.SubItems[4].Text);

            if (newvalue >= 0)
            {
                msp.QuantityInStock = newvalue;
            }
            else
            {
                li.SubItems[4].Text = msp.QuantityInStock.ToString();
            }

            double QtoPurchase = double.Parse(li.SubItems[3].Text) - double.Parse(li.SubItems[4].Text);

            if (QtoPurchase < 0)
            {
                QtoPurchase = 0;
            }

            li.SubItems[5].Text = QtoPurchase.ToString();

            NumberStyles styles    = NumberStyles.Number | NumberStyles.AllowCurrencySymbol;
            double       totalCost = double.Parse(li.SubItems[6].Text, styles) * double.Parse(li.SubItems[5].Text, styles);

            li.SubItems[7].Text = string.Format("{0:C}", totalCost);

            CalculateTotal();

            _edited = true;
        }
Пример #11
0
        public void PopPanelTests()
        {
            lvTest.BeginUpdate();
            lvTest.Items.Clear();
            int index = 0;

            foreach (PanelTest pt in _panel.PanelPanelTests)
            {
                LQTListViewTag tag = new LQTListViewTag();
                tag.Id    = pt.Id;
                tag.Index = index;
                ListViewItem li = new ListViewItem(pt.TestId.TestName)
                {
                    Tag = tag
                };
                lvTest.Items.Add(li);
                index++;
            }
            lvTest.EndUpdate();
        }
Пример #12
0
        //private void lbtEditins_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        //{
        //    int id = (int)lsvInstrument.SelectedItems[0].Tag;
        //    SiteInstrument si = _site.GetSiteInstrumentById(id);

        //    FrmInput frm = new FrmInput(si.Quantity.ToString(), "Quantity");
        //    frm.ShowDialog();
        //    if (frm.DialogResult == DialogResult.OK)
        //    {
        //        si.Quantity = int.Parse(frm.GetTextValue());
        //        DataRepository.SaveOrUpdateSite(_site);
        //        PopInstruments();
        //    }
        //}

        private void lbtRemove_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LQTListViewTag tag = (LQTListViewTag)lsvInstrument.SelectedItems[0].Tag;
            SiteInstrument si;

            if (tag.Id > 0)
            {
                si = _site.GetSiteInstrumentById(tag.Id);
            }
            else
            {
                si = (SiteInstrument)_site.SiteInstruments[tag.Index];
            }

            _site.SiteInstruments.Remove(si);
            //DataRepository.SaveOrUpdateSite(_site);
            PopInstruments();

            if (OnDataUsageEdit != null)
            {
                OnDataUsageEdit(this, new EventArgs());
            }
        }
Пример #13
0
        private void lbtRemoveTest_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LQTListViewTag tag = (LQTListViewTag)lvTest.SelectedItems[0].Tag;
            PanelTest      pt;

            if (tag.Id > 0)
            {
                pt = _panel.GetPanelTestById(tag.Id);
            }
            else
            {
                pt = (PanelTest)_panel.PanelPanelTests[tag.Index];
            }

            _panel.PanelPanelTests.Remove(pt);

            PopPanelTests();


            //if (OnDataUsageEdit != null)
            //{
            //    OnDataUsageEdit(this, new EventArgs());
            //}
        }
Пример #14
0
        private void UpdateAdjustment()
        {
            int activeid = 0;
            if (_activeCategory != null || _activeFSite != null)
            {
                if (_activeCategory != null)
                    activeid = _activeCategory.Id;
                else if (_activeFSite != null)
                    activeid = _activeFSite.Id;

                int activeIndex = _lvHistData.SelectedItems[0].Index;
                _lvHistData.BeginUpdate();
                _lvHistData.Items.Clear();
                int index = 0;
                foreach (IBaseDataUsage p in _forecastInfo.GetListOfDataUsages(activeid, activeIndex))
                {

                    p.Adjusted = p.AmountUsed;
                    if (p.AmountUsed == 0)
                    {
                        try
                        {
                            Consumption cs = (_forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? GetConsumption(p.Product.Id) : GetConsumption(p.Test.Id));
                            p.Adjusted = Math.Round(cs.TotalConsumption / cs.NoConsumption, 2, MidpointRounding.ToEven);
                        }
                        catch { p.Adjusted = p.AmountUsed; }
                    }

                    if ((p.InstrumentDowntime > 0 || p.StockOut > 0) && p.AmountUsed > 0)//
                        p.Adjusted = LqtUtil.GetAdjustedVolume(p.AmountUsed, p.StockOut + p.InstrumentDowntime, _forecastInfo.PeriodEnum, GetActiveSiteWorkingDays());//b

                    //update listview
                    LQTListViewTag tag = new LQTListViewTag();
                    tag.GroupTitle = (_forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? p.Product.ProductName : p.Test.TestName);
                    tag.Id = p.Id;
                    tag.Index = index;
                    ListViewItem li = new ListViewItem(p.CDuration) { Tag = tag };
                    if (p.AmountUsed == 0 && p.StockOut == 0 && p.InstrumentDowntime == 0)
                    {

                        li.SubItems.Add("-");
                        li.SubItems.Add("-");
                        li.SubItems.Add("-");
                    }
                    else
                    {
                        li.SubItems.Add(p.AmountUsed.ToString());
                        li.SubItems.Add(p.StockOut.ToString());
                        li.SubItems.Add(p.InstrumentDowntime.ToString());
                    }
                    li.SubItems.Add(p.Adjusted.ToString());

                    if (p.AmountUsed != p.Adjusted)
                        li.SubItems.Add("Adjusted");
                    else
                        li.SubItems.Add("");

                    LqtUtil.AddItemToGroup(_lvHistData, li);

                    if (IsHistorical(p.CDuration))
                        li.BackColor = System.Drawing.Color.LightBlue;
                    else
                        li.BackColor = System.Drawing.Color.Green;

                    _lvHistData.Items.Add(li);
                    index++;
                }
                _lvHistData.EndUpdate();
                //end update listview
            }
        }
Пример #15
0
        private IBaseDataUsage GetDataUsage(LQTListViewTag tag)
        {
            IBaseDataUsage idusage = null;

            if (_forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION)
            {
                switch (_forecastInfo.DatausageEnum)
                {
                    case DataUsageEnum.DATA_USAGE1:
                    case DataUsageEnum.DATA_USAGE2:
                        if (tag.Id <= 0)
                            idusage = _activeFSite.SiteProducts[tag.Index];
                        else
                            idusage = _activeFSite.GetSiteProduct(tag.Id);
                        break;
                    case DataUsageEnum.DATA_USAGE3:
                        if (tag.Id <= 0)
                            idusage = _activeCategory.CategoryProducts[tag.Index];
                        else
                            idusage = _activeCategory.GetFCatProduct(tag.Id);
                        break;
                }
            }
            else
            {
                switch (_forecastInfo.DatausageEnum)
                {
                    case DataUsageEnum.DATA_USAGE1:
                    case DataUsageEnum.DATA_USAGE2:
                        if (tag.Id <= 0)
                            idusage = _activeFSite.SiteTests[tag.Index];
                        else
                            idusage = _activeFSite.GetSiteTest(tag.Id);
                        break;
                    case DataUsageEnum.DATA_USAGE3:
                        if (tag.Id <= 0)
                            idusage = _activeCategory.CategoryTests[tag.Index];
                        else
                            idusage = _activeCategory.GetFCatTest(tag.Id);
                        break;
                }
            }

            return idusage;
        }
Пример #16
0
        private void PopInstruments()
        {
            lsvInstrument.BeginUpdate();
            lsvInstrument.Items.Clear();

            int index = 0;
            foreach (SiteInstrument s in _site.SiteInstruments)
            {
                LQTListViewTag tag = new LQTListViewTag();
                tag.Id = s.Id;
                tag.Index = index;

                ListViewItem li = new ListViewItem(s.Instrument.TestingArea.AreaName) { Tag = tag };
                li.SubItems.Add(s.Instrument.InstrumentName);
                li.SubItems.Add(s.Quantity.ToString());
                li.SubItems.Add(s.TestRunPercentage.ToString());
                lsvInstrument.Items.Add(li);
                index++;
            }
            if (_site.SiteInstruments.Count <= 0)
            {
                lbtRemove.Enabled = false;
            }
            lsvInstrument.EndUpdate();
        }
Пример #17
0
        private void BindProductUsage()
        {
            lsvProductUsage.BeginUpdate();
            lsvProductUsage.Items.Clear();

            int index = 0;
            foreach (ProductUsage r in _test.ProductUsages)
            {
                LQTListViewTag tag = new LQTListViewTag();
                tag.GroupTitle = r.Instrument.InstrumentName;
                tag.Id = r.Id;
                tag.Index = index;
                ListViewItem li = new ListViewItem(r.Product.ProductName) { Tag = tag };

                li.SubItems.Add(r.Rate.ToString());
                //li.SubItems.Add(r.ProductUsedIn);
                LqtUtil.AddItemToGroup(lsvProductUsage, li);
                lsvProductUsage.Items.Add(li);
                index++;
            }

            lsvProductUsage.EndUpdate();
        }
Пример #18
0
 public void PopPanelTests()
 {
     lvTest.BeginUpdate();
     lvTest.Items.Clear();
     int index = 0;
     foreach (PanelTest pt in _panel.PanelPanelTests)
     {
         LQTListViewTag tag = new LQTListViewTag();
         tag.Id = pt.Id;
         tag.Index = index;
         ListViewItem li = new ListViewItem(pt.TestId.TestName) { Tag = tag };
         lvTest.Items.Add(li);
         index++;
     }
     lvTest.EndUpdate();
 }
Пример #19
0
        private void BindProcurement()
        {
            lvproductQinstock.Items.Clear();
            lvproductQinstock.BeginUpdate();
            int index = 0;
            foreach (MorbiditySupplyProcurement p in _supplyProcurement)
            {
                LQTListViewTag tag = new LQTListViewTag();
                tag.GroupTitle = (p.PlatformEnum.ToString());
                tag.Id = p.Id;
                tag.Index = index;
                MasterProduct product=DataRepository.GetProductById(p.ProductId);

                ListViewItem li = new ListViewItem(product.ProductName) { Tag = tag };

                li.SubItems.Add(p.PackSize.ToString());
                li.SubItems.Add(product.BasicUnit);
                li.SubItems.Add(p.QuantityNeeded.ToString());
                li.SubItems.Add(p.QuantityInStock.ToString());
                li.SubItems.Add(p.QuantityToPurchase.ToString());
                li.SubItems.Add(string.Format("{0:C}",p.UnitCost).ToString());
                li.SubItems.Add(string.Format("{0:C}",p.TotalCost).ToString());

                LqtUtil.AddItemToGroup(lvproductQinstock, li);

                lvproductQinstock.Items.Add(li);
                index++;
            }

            lvproductQinstock.EndUpdate();
        }
Пример #20
0
        private void BindProductUsageP()
        {
            lsvProductUsageP.BeginUpdate();
            lsvProductUsageP.Items.Clear();

            int index = 0;
            foreach (ConsumableUsage r in _consum.ConsumableUsages)
            {
                if (r.PerPeriod == true)
                {

                    LQTListViewTag tag = new LQTListViewTag();
                    tag.GroupTitle = r.Product.ProductType.TypeName;
                    tag.Id = r.Id;
                    tag.Index = index;
                    ListViewItem li = new ListViewItem(r.Product.ProductName) { Tag = tag };

                    li.SubItems.Add(r.Period.ToString());
                    li.SubItems.Add(r.ProductUsageRate.ToString());

                    LqtUtil.AddItemToGroup(lsvProductUsageP, li);
                    lsvProductUsageP.Items.Add(li);
                    index++;
                }
            }

            lsvProductUsageP.EndUpdate();
        }
Пример #21
0
        private void DisplaySDT()
        {
            lvsysmpDirected.BeginUpdate();
            lvsysmpDirected.Items.Clear();
            int index = 0;
            foreach (PSymptomDirectedTest psdt in _protocol.SymptomDirectedTests)
            {

                LQTListViewTag tag = new LQTListViewTag();
                tag.Id = psdt.Id;
                tag.Index = index;
                tag.GroupTitle = psdt.Test.TestName;

                ListViewItem listViewItem = new ListViewItem(psdt.Test.TestName) { Tag = tag };

                listViewItem.SubItems.Add(psdt.AdultInTreatmeant.ToString());
                listViewItem.SubItems.Add(psdt.PediatricInTreatmeant.ToString());
                listViewItem.SubItems.Add(psdt.AdultPreART.ToString());
                listViewItem.SubItems.Add(psdt.PediatricPreART.ToString());

                lvsysmpDirected.Items.Add(listViewItem);
                index++;
            }
            lvsysmpDirected.EndUpdate();
        }
Пример #22
0
        private void _lvHistData_SubitemTextChanged(object sender, SubitemTextEventArgs e)
        {
            try
            {
                ListViewItem li = new ListViewItem();
                li = e.ListVItem;

                LQTListViewTag tag = new LQTListViewTag();

                tag.GroupTitle = li.Group.ToString();
                tag.Index = e.ColumnIndex;
                tag = (LQTListViewTag)li.Tag;

                //   int id = e.ColumnIndex-1 +tag.Id;
                //tag.Id = id;

                IBaseDataUsage fp = GetDataUsage((LQTListViewTag)li.Tag);
                bool flag = false;

                for (int i = 1; tag.Id < (_forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? productListunsorted : testListunsorted); i++)
                {
                    if (fp != null)
                    {
                        if (e.ListVItem.ListView.Columns[e.ColumnIndex].Text == fp.CDuration && tag.GroupTitle == (_forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? fp.Product.ProductName : fp.Test.TestName))
                        {
                            flag = true;
                            break;
                        }
                        else
                        {
                            tag.Id = 1 + tag.Id;
                            fp = GetDataUsage((LQTListViewTag)li.Tag);
                        }
                    }
                    else
                    {
                        tag.Id = 1 + tag.Id;
                        fp = GetDataUsage((LQTListViewTag)li.Tag);
                    }
                }
                //   }
                if (flag == false)
                {
                    for (int i = 1; ; i++)
                    {
                        if(tag.Id<0)
                        break;

                        if (fp != null)
                        {
                            if (e.ListVItem.ListView.Columns[e.ColumnIndex].Text == fp.CDuration && (tag.GroupTitle == (_forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? fp.Product.ProductName : fp.Test.TestName)))
                            {
                                flag = true;
                                break;
                            }
                            else
                            {
                                tag.Id = tag.Id - 1;
                                fp = GetDataUsage((LQTListViewTag)li.Tag);

                            }
                        }
                        else
                        {
                            tag.Id = tag.Id - 1;
                            fp = GetDataUsage((LQTListViewTag)li.Tag);
                        }
                    }

                }
                if (tag.Id > 0)
                {
                    ListView l1 = _lvHistData;
                    double am = 0, adj = 0, In = 0, St = 0;

                    int k = 0;
                    foreach (ListViewItem item in this._lvHistData.Items)
                    {

                        if (li.Group == item.Group)
                        {
                            if (k == 0)
                            {
                                am = double.Parse((string)item.SubItems[e.ColumnIndex].Text);//st

                            }
                            else if (k == 3)//4
                            {
                                adj = double.Parse((string)item.SubItems[e.ColumnIndex].Text);
                            }
                            else if (k == 2)//3
                            {
                                In = double.Parse((string)item.SubItems[e.ColumnIndex].Text);//am
                            }
                            else if (k == 1)//2
                            {
                                St = double.Parse((string)item.SubItems[e.ColumnIndex].Text);//In
                            }
                            k++;
                        }
                    }

                    decimal oldamount = fp.AmountUsed;
                    fp.AmountUsed = decimal.Parse(am.ToString());
                    fp.Adjusted = decimal.Parse(adj.ToString()); ;
                    fp.InstrumentDowntime = int.Parse(In.ToString());
                    fp.StockOut = int.Parse(St.ToString());

                    if (_forecastInfo.DatausageEnum == DataUsageEnum.DATA_USAGE2)
                        UpdateProductOfNReportedSite(fp);

                    OnForecastInfoDataChanged();
                    int activeid = 0, adjustment = 0;
                    if (_activeCategory != null || _activeFSite != null)
                    {
                        if (_activeCategory != null)
                            activeid = _activeCategory.Id;
                        else if (_activeFSite != null)
                            activeid = _activeFSite.Id;

                        int activeIndex = _lvHistData.SelectedItems[0].Index;
                        foreach (IBaseDataUsage p in _forecastInfo.GetListOfDataUsages(activeid, activeIndex))
                        {
                            if (p.Id == tag.Id)//b
                            {
                                //_lvHistData.BeginUpdate();
                                p.Adjusted = p.AmountUsed;
                                if (p.AmountUsed == 0)
                                {
                                    try
                                    {
                                        Consumption cs = (_forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? GetConsumption(p.Product.Id) : GetConsumption(p.Test.Id));
                                        p.Adjusted = Math.Round(cs.TotalConsumption / cs.NoConsumption, 2, MidpointRounding.ToEven);
                                    }
                                    catch { p.Adjusted = p.AmountUsed; }
                                }

                                if ((p.InstrumentDowntime > 0 || p.StockOut > 0) && p.AmountUsed > 0)//
                                    p.Adjusted = LqtUtil.GetAdjustedVolume(p.AmountUsed, p.StockOut + p.InstrumentDowntime, _forecastInfo.PeriodEnum, GetActiveSiteWorkingDays());//b

                                foreach (ListViewItem item in this._lvHistData.Items)
                                {
                                    if (li.Group == item.Group)
                                    {
                                        if (item.Text == "Adjusted")
                                        {
                                            item.SubItems[e.ColumnIndex].Text = p.Adjusted.ToString();
                                            adjustment++;
                                        }
                                        if (item.Text == "Note")
                                        {
                                            if ((p.InstrumentDowntime > 0 || p.StockOut > 0) && p.AmountUsed > 0)
                                                item.SubItems[e.ColumnIndex].Text = "Adjusted";

                                            adjustment++;
                                        }
                                    }
                                    if (adjustment == 2)
                                        break;
                                }
                                //_lvHistData.EndUpdate();
                                break;
                            }

                        }
                    }
                }
                else
                {
                    int k = 0;
                    foreach (ListViewItem item in this._lvHistData.Items)
                    {

                        if (li.Group == item.Group)
                        {
                            if (k == 0)
                            {
                                item.SubItems[e.ColumnIndex].Text = "-";

                            }
                            else if (k == 3)//4
                            {
                                item.SubItems[e.ColumnIndex].Text = "-";
                            }
                            else if (k == 2)//3
                            {
                                item.SubItems[e.ColumnIndex].Text = "-";
                            }
                            else if (k == 1)//2
                            {
                                item.SubItems[e.ColumnIndex].Text = "-";
                            }
                            k++;
                        }
                    }
                }

            }
            catch (Exception ex)
            { }
            // UpdateAdjustment();
        }
Пример #23
0
        public void BindForecastDataUsage(int siteOrcatid, int activIndex)
        {
            DataRepository.SaveOrUpdateForecastInfo(_forecastInfo);

            _lvHistData.BeginUpdate();
            _lvHistData.Items.Clear();
            List<string> list = new List<string>();
            List<string> plist = new List<string>();
            List<int> plistId = new List<int>();

            if (_activeCategory != null || _activeFSite != null)
            {
                int index = 0;
                int productcount = 0;

                #region MyRegion
                if (_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex).Count > 0)
                {
                    if (_forecastInfo.Methodology == MethodologyEnum.CONSUMPTION.ToString())
                    {
                        if (_forecastInfo.DataUsage == DataUsageEnum.DATA_USAGE3.ToString())
                        {
                            productcatList = (IList<ForecastCategoryProduct>)_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex);
                            productListunsorted = productcatList[0].Id;
                            productcatList.Sort(delegate(ForecastCategoryProduct p1, ForecastCategoryProduct p2) { return p1.DurationDateTime.Value.Date.CompareTo(p2.DurationDateTime.Value.Date); });
                            productcount = productcatList.Count;
                            foreach (ForecastCategoryProduct p in productcatList)
                            {
                                if (list.Contains(p.CDuration) != true)
                                {
                                    list.Add(p.CDuration);
                                }
                                if (plist.Contains(p.Product.ProductName) != true)
                                {
                                    plist.Add(p.Product.ProductName);
                                    plistId.Add(p.Product.Id);
                                }
                                if (productListunsorted < p.Id)
                                    productListunsorted = p.Id;

                            }
                        }
                        else
                        {
                            productsiteList = (IList<ForecastSiteProduct>)_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex);
                            productListunsorted = productsiteList[0].Id;
                            productsiteList.Sort(delegate(ForecastSiteProduct p1, ForecastSiteProduct p2) { return p1.DurationDateTime.Value.Date.CompareTo(p2.DurationDateTime.Value.Date); });
                            productcount = productsiteList.Count;

                            foreach (ForecastSiteProduct p in productsiteList)
                            {
                                if (list.Contains(p.CDuration) != true)
                                {
                                    list.Add(p.CDuration);
                                }
                                if (plist.Contains(p.Product.ProductName) != true)
                                {
                                    plist.Add(p.Product.ProductName);
                                }
                                if (productListunsorted < p.Id)
                                    productListunsorted = p.Id;

                            }

                        }
                    }
                    else
                    {
                        if (_forecastInfo.DataUsage == DataUsageEnum.DATA_USAGE3.ToString())
                        {
                            testcatList = (IList<ForecastCategoryTest>)_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex);
                            testListunsorted = testcatList[0].Id;
                            testcatList.Sort(delegate(ForecastCategoryTest t1, ForecastCategoryTest t2) { return t1.DurationDateTime.Value.Date.CompareTo(t2.DurationDateTime.Value.Date); });
                            productcount = testcatList.Count;

                            foreach (ForecastCategoryTest t in testcatList)
                            {
                                if (list.Contains(t.CDuration) != true)
                                {
                                    list.Add(t.CDuration);
                                }
                                if (plist.Contains(t.Test.TestName) != true)
                                {
                                    plist.Add(t.Test.TestName);
                                    plistId.Add(t.Test.Id);
                                }
                                if (testListunsorted < t.Id)
                                    testListunsorted = t.Id;

                            }
                        }
                        else
                        {
                            testsiteList = (IList<ForecastSiteTest>)_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex);
                            testListunsorted = testsiteList[0].Id;
                            testsiteList.Sort(delegate(ForecastSiteTest t1, ForecastSiteTest t2) { return t1.DurationDateTime.Value.Date.CompareTo(t2.DurationDateTime.Value.Date); });
                            productcount = testsiteList.Count;

                            foreach (ForecastSiteTest t in testsiteList)
                            {
                                if (list.Contains(t.CDuration) != true)
                                {
                                    list.Add(t.CDuration);
                                }
                                if (plist.Contains(t.Test.TestName) != true)
                                {
                                    plist.Add(t.Test.TestName);
                                }
                                if (testListunsorted < t.Id)
                                    testListunsorted = t.Id;

                            }
                        }
                    }

                    if (_forecastInfo.Period == "YEARLY")
                        list.Sort();
                    int count = list.Count;
                    _lvHistData.Columns.Clear();
                    this._lvHistData.Items.Clear();
                    col = new ColumnHeader[count + 1];
                    ColumnHeader u = new ColumnHeader();
                    u.Text = "";
                    col[0] = u;
                    if (_forecastInfo.Period == ForecastPeriodEnum.Yearly.ToString())
                    {
                        for (int i = count; i >= 1; i--)
                        {
                            ColumnHeader c = new ColumnHeader();
                            c.Text = list[i - 1].ToString();
                            col[i] = c;
                        }

                    }

                    if (_forecastInfo.Period == ForecastPeriodEnum.Monthly.ToString())
                    {
                        DateTime last = _forecastInfo.StartDate;
                        for (int i = 1; i <= count; i++)
                        {
                            ColumnHeader c = new ColumnHeader();
                            c.Text = list[i - 1].ToString();
                            col[i] = c;
                        }

                    }
                    if (_forecastInfo.Period == ForecastPeriodEnum.Bimonthly.ToString())
                    {
                        DateTime last = _forecastInfo.StartDate;
                        for (int i = count; i >= 1; i--)
                        {
                            ColumnHeader c = new ColumnHeader();
                            last = last.AddMonths(-2);
                            c.Text = list[i - 1].ToString();
                            col[i] = c;
                        }

                    }
                    if (_forecastInfo.Period == ForecastPeriodEnum.Quarterly.ToString())
                    {
                        int quar = GetQuarter(_forecastInfo.StartDate);
                        int year = _forecastInfo.StartDate.Year;
                        for (int i = count; i >= 1; i--)
                        {
                            if (quar == 1)
                            {
                                quar = 4;
                                year--;
                            }
                            else
                                quar--;
                            ColumnHeader c = new ColumnHeader();
                            c.Text = list[i - 1].ToString();
                            col[i] = c;
                        }
                    }

                    this._lvHistData.Columns.AddRange(col);
                    addData = false;

                    int j = 0, k = 1;
                    ListViewItem l1 = null;
                    ListViewItem l2 = null;
                    ListViewItem l3 = null;
                    ListViewItem l4 = null;
                    ListViewItem l5 = null;
                    List<string> prolist = new List<string>();

                    for (int z = 0; z < plist.Count; z++)
                    {
                        bool flag = false;
                        bool flag1 = false;
                        int insert = 1, rem = 0;
                        j = 0;

                        foreach (IBaseDataUsage p in _forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex))
                        {

                            if (plist[z] ==( _forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? p.Product.ProductName : p.Test.TestName))
                            {
                            LQTListViewTag tag = new LQTListViewTag();
                            tag.GroupTitle = (_forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? p.Product.ProductName : p.Test.TestName);
                            tag.Id = p.Id;
                            tag.Index = index;

                                if (flag1 == false)
                                {

                                    l1 = new ListViewItem("ProductUsed/TestPerformed") { Tag = tag };
                                    l2 = new ListViewItem("StockOut") { Tag = tag };
                                    l3 = new ListViewItem("InstrumentDowntime") { Tag = tag };
                                    l4 = new ListViewItem("Adjusted") { Tag = tag };
                                    l5 = new ListViewItem("Note") { Tag = tag };

                                    for (int f = 1; f <= list.Count; f++)
                                        if (list[f - 1] == p.CDuration)
                                        {
                                            insert = f;

                                            for (int l = 1; l < insert; l++)
                                            {
                                                l1.SubItems.Add("-");
                                                l2.SubItems.Add("-");
                                                l3.SubItems.Add("-");
                                                l4.SubItems.Add("-");
                                                l5.SubItems.Add("-");
                                                l1.SubItems.Insert(l, l1.SubItems[l]);
                                                l2.SubItems.Insert(l, l2.SubItems[l]);
                                                l3.SubItems.Insert(l, l3.SubItems[l]);
                                                l4.SubItems.Insert(l, l4.SubItems[l]);
                                                k = k + 2;
                                            }
                                            break;
                                        }

                                    l1.SubItems.Add(p.AmountUsed.ToString());
                                    l2.SubItems.Add(p.StockOut.ToString());
                                    l3.SubItems.Add(p.InstrumentDowntime.ToString());
                                    l4.SubItems.Add(p.Adjusted.ToString());
                                    if (p.AmountUsed != p.Adjusted)
                                    {
                                        l5.SubItems.Add("Adjusted");
                                    }
                                    else
                                    {
                                        l5.SubItems.Add("-");
                                    }
                                    l1.SubItems.Insert(insert, l1.SubItems[k]);
                                    l2.SubItems.Insert(insert, l2.SubItems[k]);
                                    l3.SubItems.Insert(insert, l3.SubItems[k]);
                                    l4.SubItems.Insert(insert, l4.SubItems[k]);

                                    k = k + 2;
                                    flag1 = true;
                                    rem = insert;
                                    insert++;

                                }
                                else if (j == productcount - 1)
                                {

                                    l1.SubItems.Add(p.AmountUsed.ToString());
                                    l2.SubItems.Add(p.StockOut.ToString());
                                    l3.SubItems.Add(p.InstrumentDowntime.ToString());
                                    l4.SubItems.Add(p.Adjusted.ToString());
                                    if (p.AmountUsed != p.Adjusted)
                                    {
                                        l5.SubItems.Add("Adjusted");
                                    }
                                    else
                                    {
                                        l5.SubItems.Add("-");
                                    }

                                    l1.SubItems.Insert(insert, l1.SubItems[k]);
                                    l2.SubItems.Insert(insert, l2.SubItems[k]);
                                    l3.SubItems.Insert(insert, l3.SubItems[k]);
                                    l4.SubItems.Insert(insert, l4.SubItems[k]);
                                    j = 0;
                                    flag = true;
                                    k = 1;
                                    insert++;
                                    rem = insert;

                                    break;

                                }
                                else
                                {

                                    l1.SubItems.Add(p.AmountUsed.ToString());
                                    l2.SubItems.Add(p.StockOut.ToString());
                                    l3.SubItems.Add(p.InstrumentDowntime.ToString());
                                    l4.SubItems.Add(p.Adjusted.ToString());
                                    if (p.AmountUsed != p.Adjusted)
                                    {
                                        l5.SubItems.Add("Adjusted");
                                    }
                                    else
                                    {
                                        l5.SubItems.Add("-");
                                    }

                                    l1.SubItems.Insert(insert, l1.SubItems[k]);
                                    l2.SubItems.Insert(insert, l2.SubItems[k]);
                                    l3.SubItems.Insert(insert, l3.SubItems[k]);
                                    l4.SubItems.Insert(insert, l4.SubItems[k]);

                                    k = k + 2;
                                    rem = insert;
                                    insert++;

                                }
                            }
                                else if (flag == false && j == productcount - 1)
                                {
                                    if (rem > 1)
                                        for (int l = rem + 1; l <= list.Count; l++)
                                        {
                                            l1.SubItems.Add("-");
                                            l2.SubItems.Add("-");
                                            l3.SubItems.Add("-");
                                            l4.SubItems.Add("-");
                                            l5.SubItems.Add("-");
                                            l1.SubItems.Insert(l, l1.SubItems[k]);
                                            l2.SubItems.Insert(l, l2.SubItems[k]);
                                            l3.SubItems.Insert(l, l3.SubItems[k]);
                                            l4.SubItems.Insert(l, l4.SubItems[k]);
                                            k = k + 2;
                                        }

                                    k = 1;
                                    break;
                                }

                                j++;

                            }

                        if (k == 1)
                        {
                            LqtUtil.AddItemToGroup(_lvHistData, l1);
                            LqtUtil.AddItemToGroup(_lvHistData, l2);
                            LqtUtil.AddItemToGroup(_lvHistData, l3);
                            LqtUtil.AddItemToGroup(_lvHistData, l4);
                            LqtUtil.AddItemToGroup(_lvHistData, l5);
                            index++;
                            _lvHistData.Items.AddRange(new ListViewItem[] { l1, l2, l3, l4, l5 });
                            l1.BackColor = System.Drawing.Color.LightBlue;
                            l2.BackColor = System.Drawing.Color.LightBlue;
                            l3.BackColor = System.Drawing.Color.LightBlue;
                            l4.BackColor = System.Drawing.Color.LightBlue;
                            l5.BackColor = System.Drawing.Color.LightBlue;
                        }

                    }

                }
                #endregion

                _lvHistData.EndUpdate();
            }
        }
        private void PopInstruments()
        {
            // _fCategoryInstrument = DataRepository.GetFCInstrumentByFinfoId(_Fid);

            lsvInstrument.BeginUpdate();
            lsvInstrument.Items.Clear();

            int index = 0;
            foreach (ForecastCategoryInstrument s in _fCategoryInstrument)
            {

                LQTListViewTag tag = new LQTListViewTag();
                tag.Id = s.Id;
                tag.Index = index;
                tag.GroupTitle =s.Instrument.TestingArea.AreaName;

                ListViewItem li = new ListViewItem(s.Instrument.InstrumentName) { Tag =tag };
               //i.SubItems.Add(s.Instrument.InstrumentName);
                li.SubItems.Add(s.TestRunPercentage.ToString());
                 LqtUtil.AddItemToGroup(lsvInstrument, li);
                lsvInstrument.Items.Add(li);
                index++;
            }
            if (_fCategoryInstrument.Count <= 0)
            {
                lbtRemove.Enabled = false;
            }
            lsvInstrument.EndUpdate();
        }