예제 #1
0
        internal bool IsMacAddressAllowed(ulong bluetoothAddress, TrainProject project)
        {
            if (currentLimitation == LimitationType.None)
            {
                return(true);
            }
            else if (currentLimitation == LimitationType.OnlyProject)
            {
                foreach (Hub hub in project.RegisteredTrains)
                {
                    if (hub.BluetoothAddress == bluetoothAddress)
                    {
                        return(true);
                    }
                }
            }
            else
            {
                List <string> listStrLineElements = setListOfDevices.Split(
                    new[] { "\r\n", "\r", "\n" },
                    StringSplitOptions.None).ToList();
                string macAddress = string.Format("{0:X}", bluetoothAddress);

                foreach (string address in listStrLineElements)
                {
                    if (address.Trim(' ') == macAddress)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #2
0
        public TrainSectionBehavior(Section section, TrainProject project)
        {
            Section = section;
            Project = project;

            InitializeComponent();

            textBoxMaxSpeed.Text   = Section.MaxSpeed.ToString();
            checkBox2Ahead.Checked = Section.NeedsTwoSectionReleased;

            if (Section.Action == Section.ActionOnRelease.Resume_Speed)
            {
                this.radioButtonResume.Checked = true;
            }
            else
            {
                this.radioButtonExecute.Checked = true;
            }
        }
예제 #3
0
 public PathEditor(TrainProject project)
 {
     this.project = project;
     InitializeComponent();
     RefreshUI();
 }
예제 #4
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            lbErr.Text = "";

            TrainProject tp = new TrainProject();

            if (tbTrainingNub.Text.Trim().Length > 0)
            {
                tp.ProjectCode = tbTrainingNub.Text.Trim();
            }
            else
            {
                lbErr.Text = "项目编号不能为空";
                return;
            }
            if (tbTrainingName.Text.Trim().Length > 0)
            {
                tp.ProjectName = tbTrainingName.Text.Trim();
            }
            else
            {
                lbErr.Text = "项目名称不能为空";
                return;
            }
            tp.Contrator = tbContactName.Text.Trim();
            if (tbTrainingDes.Text.Trim().Length < 45)
            {
                tp.Des = tbTrainingDes.Text.Trim();
            }
            else
            {
                lbErr.Text = "项目描述长度不能超过45";
                return;
            }
            tp.Email = tbContactEMail.Text.Trim();

            if (tbCharges.Text.Trim().Length > 0)
            {
                Decimal dTemp;
                if (Decimal.TryParse(tbCharges.Text.Trim(), out dTemp))
                {
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN");
                    string[] strChanges = tbCharges.Text.Split('.');
                    string strInteger = strChanges[0];
                    string strFloat = "";
                    if (strChanges.Count() > 1)
                    {
                        strFloat = strChanges[1];
                    }
                    if (strFloat.Length > 2 || strInteger.Length > 6)
                    {
                        lbErr.Text = "收费标准输入格式不正确";
                        return;
                    }
                    tp.Fee = dTemp;

                }
                else
                {
                    lbErr.Text = "收费标准输入必须为数字";
                    return;
                }
            }
            if (tbChargesDes.Text.Trim().Length < 45)
            {
                tp.FeeDes = tbChargesDes.Text.Trim();
            }
            else
            {
                lbErr.Text = "收费标准长度不能超过45";
                return;
            }

            tp.Phone = tbContactPhone.Text.Trim();

            int iTemp = 0;
            if (tbLastDays.Text.Trim().Length > 0)
            {
                if (int.TryParse(tbLastDays.Text.Trim(), out  iTemp))
                {
                    tp.PjctConsistDate = iTemp;
                }
                else
                {
                    lbErr.Text = "持续时间必须为数字";
                    return;
                }
            }

            DateTime dtTemp;
            if (tbStartTime.Text.Trim().Length > 0)
            {
                if (DateTime.TryParse(tbStartTime.Text.Trim(), out  dtTemp))
                {
                    tp.PjctStartDate = dtTemp;
                }
                else
                {
                    lbErr.Text = "开始日期格式不正确";
                    return;
                }
            }

            tp.ProjectCate = tbOperationtype.Text.Trim();
            tp.TrainingState = 1;
            try
            {
                tp.Save();
            }
            catch (Exception ex)
            {
                lbErr.Text = ex.Message;
                if (ex.Message.Contains("Index_CTrainCode"))
                {
                    lbErr.Text = "项目编号不能重复";
                }
                return;
            }
            Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('添加成功!');window.document.location = 'TrainingPreview.aspx?id=" + tp.Id.ToString() + "';</script>");
        }