コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _exampleModel = new List<ExampleModel>();

            var exManager = new ExampleManager();
            var knManager = new KnapsackManager();
            var itManager = new ItemManager();

            var idEx = exManager.GetAllExamplesId();

            foreach (var id in idEx)
            {
                string knapsacks = string.Empty;
                string items = string.Empty;

                knManager.GetKnapsacks(id).ForEach(k => knapsacks+=","+k.Capacity);
                itManager.GetItems(id).ForEach(i => items+=","+i.Weight);

                _exampleModel.Add(new ExampleModel
                {
                    Id = id,
                    Error = exManager.GetCalculateError(id),
                    Knapsacks = knapsacks.TrimStart(','),
                    Items = items.TrimStart(',')
                });
            }

            ExamplesGrid.DataSource = _exampleModel;
            ExamplesGrid.DataBind();
        }
コード例 #2
0
        protected void btnCalculate_OnClick(object sender, EventArgs e)
        {
            var exManager = new ExampleManager();

            if (Request.QueryString["idExp"] != null)
            {
                int idEx = Convert.ToInt32(Request.QueryString["idExp"]);
                if (exManager.CheckExists(idEx))
                {
                    TryCalculate(idEx);
                }
            }
        }
コード例 #3
0
        private void TryCalculate(int idEx)
        {
            var calculateModel = new CalculateModel();

            var knManager = new KnapsackManager();
            var itManager = new ItemManager();
            var exManager = new ExampleManager();

            calculateModel.Knapsacks = knManager.GetKnapsacks(idEx);
            calculateModel.Items = itManager.GetItems(idEx);
            calculateModel.CalculateError = exManager.GetCalculateError(idEx);

            _proxy.CalculateCompleted += _proxy_CalculateCompleted;
            _proxy.CalculateAsync(TransportConverter.CalculateModelConverter(calculateModel));
        }
コード例 #4
0
 //        protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
 //        {
 //            var a = KnapsacksGrid.Rows[0].Cells[0].Controls;
 //            if (e.Row.RowType == DataControlRowType.DataRow)
 //            {
 //                var lb = new Label{ID = "LbId"};
 //                var tb = new TextBox {CssClass = "form-control input-sm", ID = "GrIn"};
 //                e.Row.Cells[0].Controls.Add(lb);
 //                e.Row.Cells[1].Controls.Add(tb);
 //            }
 //        }
 protected void btnCalculate_Click(object sender, EventArgs e)
 {
     int idExp = new ExampleManager().AddExample(_knapsacks, _items, _calculateError);
     Response.Redirect("Resault.aspx?idExp="+idExp,true);
 }