Beispiel #1
0
        private void SaveGridDataToObject()
        {
            RangeNumberData range = CurrentRange;

            for (int i = 0; i < range.RangeNumbers.Count; i++)
            {
                TextBox box1 = (TextBox)grid.Rows[i].Cells[0].FindControl("tbRangelFrom");
                TextBox box2 = (TextBox)grid.Rows[i].Cells[1].FindControl("tbRangelTo");
                int     value;
                if (int.TryParse(box1.Text, out value))
                {
                    range.RangeNumbers[i].RangelFrom = value;
                }
                if (int.TryParse(box2.Text, out value))
                {
                    range.RangeNumbers[i].RangelTo = value;
                }
                DropDownList ddl = (DropDownList)grid.Rows[i].Cells[2].FindControl("ddlTemplate");
                if (!string.IsNullOrEmpty(ddl.SelectedValue))
                {
                    range.RangeNumbers[i].Template = _service.GetTemplate(Guid.Parse(ddl.SelectedValue));
                }
            }
            CurrentRange = range;
        }
Beispiel #2
0
        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            var rn = new RangeNumberData();

            rn.Id = CurrentRange.Id;
            SetObjValues(rn);
            args.IsValid = !_service.IntersectWithOther(rn);
        }
Beispiel #3
0
        protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
        {
            var rn = new RangeNumberData();

            rn.Id = CurrentRange.Id;
            SetObjValues(rn);
            args.IsValid = rn.RangelFrom <= rn.RangelTo;
        }
        public void Create()
        {
            try
            {
                rt.srz.model.srz.RangeNumber entity = CreateNew();

                object result = manager.Save(entity);

                Assert.IsNotNull(result);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        public void Read()
        {
            try
            {
                rt.srz.model.srz.RangeNumber entityA = CreateNew();
                manager.Save(entityA);

                rt.srz.model.srz.RangeNumber entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA, entityB);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SetButtonsEnable(false);

                var criteria = new SearchSmoCriteria();
                criteria.Take = int.MaxValue;
                criteria.Oid  = Oid.Smo;

                dlSmo.DataSource = regulatoryService.GetSmos(criteria).Rows; //regulatoryService.GetSmosByTfom(fomId);
                dlSmo.DataBind();

                if (Request.QueryString["Id"] == null)
                {
                    CurrentRange = new RangeNumberData();
                }
                else
                {
                    CurrentRange = _service.GetRangeNumber(Guid.Parse(Request.QueryString["Id"]));
                }
                LoadGridData();
                SetPreviousData(true);

                if (Request.QueryString["Id"] == null)
                {
                    lbTitle.Text = "Добавление выделенного диапазона номеров вс";
                    return;
                }
                tbFrom.Text         = CurrentRange.RangelFrom.ToString();
                tbTo.Text           = CurrentRange.RangelTo.ToString();
                dlSmo.SelectedValue = CurrentRange.Smo != null?CurrentRange.Smo.Id.ToString() : null;

                //Редактирование выделенного диапазона номеров вс
                if (CurrentRange.ChangeDate.HasValue)
                {
                    lbTitle.Text = string.Format("Выделенный диапазон номеров временных свидетельств от {0}", CurrentRange.ChangeDate.Value.ToShortDateString());
                }
                else
                {
                    lbTitle.Text = "Выделенный диапазон номеров временных свидетельств";
                }
            }
        }
Beispiel #7
0
        private void AddNewRowToGrid()
        {
            if (CurrentRange == null)
            {
                return;
            }
            RangeNumberData newRow = new RangeNumberData();

            newRow.Id     = Guid.NewGuid();
            newRow.Parent = CurrentRange;
            newRow.Smo    = CurrentRange.Smo;
            RangeNumberData range = CurrentRange;

            range.RangeNumbers.Add(newRow);
            CurrentRange    = range;
            grid.DataSource = CurrentRange.RangeNumbers;
            grid.DataBind();
            SetPreviousData();
        }
        public static RangeNumber CreateNew(int depth = 0)
        {
            rt.srz.model.srz.RangeNumber entity = new rt.srz.model.srz.RangeNumber();

            // You may need to maually enter this key if there is a constraint violation.
            entity.Id = System.Guid.NewGuid();

            entity.RangelFrom = 1;
            entity.RangelTo   = 19;
            entity.ChangeDate = System.DateTime.Now;

            using (rt.srz.business.manager.IRangeNumberManager rangeNumberMemberManager = ObjectFactory.GetInstance <IRangeNumberManager>())
            {
                entity.Parent = null;
            }

            using (rt.srz.business.manager.IOrganisationManager organisationManager = ObjectFactory.GetInstance <IOrganisationManager>())
            {
                var          all       = organisationManager.GetAll(1);
                Organisation entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

                if (entityRef == null && depth < 3)
                {
                    depth++;
                    entityRef = OrganisationTests.CreateNew(depth);
                    ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef);
                }

                entity.Smo = entityRef;
            }

            using (rt.srz.business.manager.ITemplateManager templateManager = ObjectFactory.GetInstance <ITemplateManager>())
            {
                entity.Template = null;
            }

            return(entity);
        }
Beispiel #9
0
        protected void menu_MenuItemClick(object sender, MenuEventArgs e)
        {
            switch (e.Item.Value)
            {
            case "Add":
                SaveGridDataToObject();
                AddNewRowToGrid();
                break;

            case "Delete":
                SaveGridDataToObject();
                List <Guid>     deletedIdRows = GetSelected();
                RangeNumberData range         = CurrentRange;
                range.RangeNumbers = range.RangeNumbers.Where(x => !deletedIdRows.Contains(x.Id)).ToList();
                CurrentRange       = range;
                LoadGridData();
                SetPreviousData(true);
                SetButtonsEnable(false);
                break;
            }
        }
        public void Delete()
        {
            try
            {
                rt.srz.model.srz.RangeNumber entityC = CreateNew();
                manager.Save(entityC);
                manager.Session.GetISession().Flush();
                manager.Session.GetISession().Clear();

                rt.srz.model.srz.RangeNumber entity = GetFirstRangeNumber();

                manager.Delete(entity);

                entity = manager.GetById(entity.Id);
                Assert.IsNull(entity);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        public void Update()
        {
            try
            {
                rt.srz.model.srz.RangeNumber entityC = CreateNew();
                manager.Save(entityC);
                manager.Session.GetISession().Flush();
                manager.Session.GetISession().Clear();

                rt.srz.model.srz.RangeNumber entityA = GetFirstRangeNumber();

                entityA.RangelFrom = 12;

                manager.Update(entityA);

                rt.srz.model.srz.RangeNumber entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA.RangelFrom, entityB.RangelFrom);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Beispiel #12
0
 private void SetObjValues(RangeNumberData obj)
 {
     obj.RangelFrom = int.Parse(tbFrom.Text);
     obj.RangelTo   = int.Parse(tbTo.Text);
     obj.Smo        = regulatoryService.GetOrganisation(Guid.Parse(dlSmo.SelectedValue));
 }