示例#1
0
        /// <summary>
        /// 遍历检索控件中值
        /// </summary>
        /// <returns></returns>
        protected Dictionary <string, object> GetControlData()
        {
            if (string.IsNullOrWhiteSpace(tableName))
            {
                return(null);
            }

            DataTable dt = Tmo_FakeEntityClient.Instance.GetTableStruct(tableName);

            if (dt == null)
            {
                return(null);
            }

            Dictionary <string, object> dic = new Dictionary <string, object>();
            List <Control> listControl      = TmoComm.FindControl(panelControlMain);

            foreach (Control ctrl in listControl)
            {
                string fieldName = ctrl.Name;
                if (!dt.Columns.Contains(fieldName))
                {
                    continue;                                   //跳过不在表中的控件
                }
                object fieldValue = null;
                if (ctrl is Label)
                {
                    fieldValue = ((Label)ctrl).Text;
                }
                else if (ctrl is TextBox)
                {
                    fieldValue = ((TextBox)ctrl).Text;
                }
                else if (ctrl is ComboBox)
                {
                    fieldValue = ((ComboBox)ctrl).SelectedItem;
                }
                else if (ctrl is DevExpress.XtraEditors.DateEdit)
                {
                    fieldValue = ((DevExpress.XtraEditors.DateEdit)ctrl).DateTime;
                }
                else if (ctrl is DevExpress.XtraEditors.LabelControl)
                {
                    fieldValue = ((DevExpress.XtraEditors.LabelControl)ctrl).Text;
                }
                else if (ctrl is DevExpress.XtraEditors.BaseEdit)
                {
                    fieldValue = ((DevExpress.XtraEditors.BaseEdit)ctrl).EditValue;
                }

                if (fieldName != null && fieldValue != null)
                {
                    if (!dic.ContainsKey(fieldName))
                    {
                        dic.Add(fieldName, fieldValue);
                    }
                }
            }
            return(dic);
        }
示例#2
0
        public LogoForm()
        {
            InitializeComponent();

            #region 加载版本号
            lblVersion.Text = string.Format("版本 {0}", TmoComm.GetAppVersion());
            #endregion

            this.Load += LogoForm_Load;
            InitSkin();                                           //加载皮肤配置
            TmoComm.SyncContext = SynchronizationContext.Current; //获得UI线程同步上下文

            TCPClient.Instance.DataReceived            += Instance_DataReceived;
            TCPClient.Instance.ServerConnectionChanged += Instance_ServerConnectionChanged;
            TCPClient.Instance.StartService(TmoServiceClient.Ip, TmoServiceClient.Port + 1);   //启动TCP服务

            #region 加载自定义Logo画面
            string logoPath = TmoShare.GetRootPath() + "\\Images\\logo.jpg";
            if (!File.Exists(logoPath))
            {
                logoPath = TmoShare.GetRootPath() + "\\Images\\logo.png";
            }
            if (!File.Exists(logoPath))
            {
                return;
            }

            this.BackgroundImage = Image.FromFile(logoPath);
            this.Width           = this.BackgroundImage.Width + 4;
            this.Height          = this.BackgroundImage.Height + 4;
            #endregion
        }
        //验证控件值
        public static bool Validate(XtraTabPage tabPage)
        {
            if (tabPage == null)
            {
                return(false);
            }

            List <Control> childrens = TmoComm.GetChildrenControl(tabPage, true);

            foreach (Control children in childrens)
            {
                if (children is UCQuestion)
                {
                    UCQuestion ucq = (UCQuestion)children;

                    if (ucq.Enabled && !ucq.ValidateValue())
                    {
                        //ucq._valueControls.ForEach(x => x.Focus());
                        ucq.Focus();
                        tabPage.Select();
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#4
0
        /// <summary>
        /// 初始化服务器
        /// </summary>
        public void Init()
        {
            #region 界面控件添加

            //Remoting
            UCServiceServer.Instance.Dock = DockStyle.Fill;
            tpRemoting.Controls.Add(UCServiceServer.Instance);
            tpRemoting.Text = UCServiceServer.Instance.ServiceName;
            // Tcp服务器
            UcTcpServer.Instance.Dock = DockStyle.Fill;
            tpTCP.Controls.Add(UcTcpServer.Instance);
            //设备同步
            UcSyncTcpServer.Instance.Dock = DockStyle.Fill;
            tpSyncServer.Controls.Add(UcSyncTcpServer.Instance);
            //数据推送
            UCPushData.Instence.Dock = DockStyle.Fill;
            tpPushData.Controls.Add(UCPushData.Instence);

            this.lblVer.Text = string.Format("版本 {0}", TmoComm.GetAppVersion());

            #endregion

            #region  务注册

            //Remoting
            ServieRemoting.StatusChanged      = StatusCheck; //事件赋值
            ServieRemoting.StartServiceMethod = UCServiceServer.Instance.StartServices;
            ServieRemoting.StopServiceMethod  = UCServiceServer.Instance.StopServices;
            //DataBase
            ServieDataBase.StatusChanged      = StatusCheck;
            ServieDataBase.StartServiceMethod = TmoConfigManager.Instance.CheckConnection;
            ServieDataBase.StopServiceMethod  = () => true;
            //PushData
            ServiePushData.StatusChanged      = StatusCheck;
            ServiePushData.StartServiceMethod = UCPushData.Instence.StartService;
            ServiePushData.StopServiceMethod  = UCPushData.Instence.StopService;
            //PlanService
            ServiePlan.StatusChanged      = StatusCheck;
            ServiePlan.StartServiceMethod = PlanService.Instence.StartService;
            ServiePlan.StopServiceMethod  = PlanService.Instence.StopService;
            //TcpService
            ServieTCP.StatusChanged      = StatusCheck;
            ServieTCP.StartServiceMethod = UcTcpServer.Instance.StartServeice;
            ServieTCP.StopServiceMethod  = UcTcpServer.Instance.StopService;
            //DevService
            ServiceDev.StatusChanged      = StatusCheck;
            ServiceDev.StartServiceMethod = UcSyncTcpServer.Instance.StartServeice;
            ServiceDev.StopServiceMethod  = UcSyncTcpServer.Instance.StopService;

            #endregion

            //启动服务
            if (!Debugger.IsAttached)
            {
                StartServices();
            }
        }
示例#5
0
 /// <summary>
 /// 初始化窗体数据
 /// </summary>
 public override void Init()
 {
     SkinHelper.InitSkinGallery(rgbiSkin, true);
     Text = ConfigHelper.GetConfigString("title");
     if (string.IsNullOrWhiteSpace(Text))
     {
         Text = "客户端";
     }
     bbtnVer.Caption = "版本 " + TmoComm.GetAppVersion();
 }
示例#6
0
        string GetDataJsonString()
        {
            List <Control> list = TmoComm.GetChildrenControl(xtraTabControlMain, true);
            Dictionary <string, object> listdata = new Dictionary <string, object>();

            if (_aclb_id != -1)
            {
                listdata.Add("aclb_id", _aclb_id);
            }

            list.ForEach(x =>
            {
                if (x.Tag != null)
                {
                    string key = x.Tag.ToString();
                    if (x is BaseEdit)
                    {
                        BaseEdit be  = (BaseEdit)x;
                        object value = null;
                        if (x is DateEdit)
                        {
                            if (be.EditValue != null)
                            {
                                value = be.EditValue;
                            }
                            else
                            {
                                value = default(DateTime);
                            }
                        }
                        else
                        {
                            value = be.EditValue == null ? "" : be.EditValue;
                        }

                        listdata.Add(key, value);
                    }
                    else if (x is CheckedListBoxControl)
                    {
                        CheckedListBoxControl chkControl = (CheckedListBoxControl)x;
                        string str = GetCheckedListBoxChecked(chkControl);
                        if (!string.IsNullOrEmpty(str))
                        {
                            listdata.Add(key, str);
                        }
                    }
                    else if (x is DateTimePicker)
                    {
                        DateTimePicker dateTimeControl = (DateTimePicker)x;
                        listdata.Add(key, dateTimeControl.Value);
                    }
                }
            });
            return(TmoShare.SetValueToJson(listdata));
        }
示例#7
0
        void SetDataFromJsonString()
        {
            Dictionary <string, object> listdata = new Dictionary <string, object>();

            if (!string.IsNullOrWhiteSpace(_jsonData))
            {
                listdata = TmoShare.GetValueFromJson <Dictionary <string, object> >(_jsonData);
            }

            if (listdata.ContainsKey("aclb_id"))
            {
                int.TryParse(listdata["aclb_id"].ToString(), out _aclb_id);
            }

            List <Control> list = TmoComm.GetChildrenControl(xtraTabControlMain, true);

            list.ForEach(x =>
            {
                if (x is RadioGroup)
                {
                    RadioGroup rg  = (RadioGroup)x;
                    rg.MouseClick += rg_MouseClick; //右键清楚选择
                }

                if (x.Tag != null)
                {
                    string key = x.Tag.ToString();
                    if (listdata.ContainsKey(key))
                    {
                        object value = listdata[key];
                        if (x is BaseEdit)
                        {
                            BaseEdit be = (BaseEdit)x;
                            //if (x is DateEdit)
                            //{
                            //    if (be.EditValue != null)
                            //        value = be.EditValue;
                            //    else
                            //        value = default(DateTime);
                            //}
                            //else
                            {
                                be.EditValue = value;
                            }
                        }
                        else if (x is CheckedListBoxControl)
                        {
                            CheckedListBoxControl chkControl = (CheckedListBoxControl)x;
                            SetCheckedListBoxChecked(chkControl, value.ToString());
                        }
                    }
                }
            });
        }
示例#8
0
 private TCPClient()
 {
     _ver = TmoComm.GetAppVersion();
 }
示例#9
0
        /// <summary>
        /// 为控件赋值
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        protected bool SetControlData(DataRow dr)
        {
            try
            {
                List <Control> listControl = TmoComm.FindControl(panelControlMain);
                foreach (Control ctrl in listControl)
                {
                    string fieldName = ctrl.Name;

                    if (!dr.Table.Columns.Contains(fieldName))
                    {
                        continue;                                         //跳过不在表中的控件
                    }
                    object fieldValue    = dr[fieldName];
                    string fieldValueStr = fieldValue?.ToString();
                    if (fieldValueStr != null && fieldValue is DateTime)
                    {
                        fieldValueStr = ((DateTime)fieldValue).ToFormatDateTimeStr();
                    }

                    if (ctrl is Label)
                    {
                        ((Label)ctrl).Text = fieldValueStr;
                    }
                    else if (ctrl is TextBox)
                    {
                        TextBox tb = (TextBox)ctrl;
                        tb.Text = fieldValueStr;
                        if (dbOperaType == DBOperateType.View)
                        {
                            tb.ReadOnly = true;
                        }
                    }
                    else if (ctrl is ComboBox)
                    {
                        ComboBox cb = (ComboBox)ctrl;
                        cb.SelectedItem = fieldValue;
                    }
                    else if (ctrl is DevExpress.XtraEditors.DateEdit)
                    {
                        DevExpress.XtraEditors.DateEdit de = (DevExpress.XtraEditors.DateEdit)ctrl;
                        de.EditValue = fieldValue;
                        if (dbOperaType == DBOperateType.View)
                        {
                            de.ReadOnly = true;
                        }
                    }
                    else if (ctrl is DevExpress.XtraEditors.LabelControl)
                    {
                        ((DevExpress.XtraEditors.LabelControl)ctrl).Text = fieldValueStr;
                    }
                    else if (ctrl is DevExpress.XtraEditors.BaseEdit)
                    {
                        DevExpress.XtraEditors.BaseEdit be = (DevExpress.XtraEditors.BaseEdit)ctrl;
                        be.EditValue = fieldValue;
                        if (dbOperaType == DBOperateType.View)
                        {
                            be.ReadOnly = true;
                        }
                    }
                    else
                    {
                    }
                }
                string[] other = { "province_id", "city_id", "eare_id" };
                foreach (string item in other)
                {
                    Control ctrl = listControl.Find((Control x) => x.Name == item);
                    if (ctrl != null)
                    {
                        if (ctrl is DevExpress.XtraEditors.BaseEdit)
                        {
                            ((DevExpress.XtraEditors.BaseEdit)ctrl).EditValue = dr[item].ToString();
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                LogHelper.Log.Error("SetControlData(DataRow dr)错误", ex);
                return(false);
            }
        }
示例#10
0
 protected override void OnLoad(EventArgs e)
 {
     lblVer.Text = "V" + TmoComm.GetAppVersion();
     base.OnLoad(e);
 }
示例#11
0
        /// <summary>
        /// 主动设置值
        /// </summary>
        /// <param name="value"></param>
        public void SetValue(object value)
        {
            int length = _valueControls.Count;

            if (length == 0)
            {
                return;
            }

            try
            {
                Array valuearray = value as Array;
                if (valuearray == null && length == 1)
                {
                    valuearray = new[] { value }
                }
                ;

                for (var i = 0; i < length; i++)
                {
                    Control valueControl = _valueControls[i];
                    object  val          = valuearray.GetValue(i);
                    if (valueControl is TextBox)
                    {
                        var vc = (TextBox)valueControl;
                        vc.Text = TmoComm.Convert2Type <string>(val);
                    }
                    else if (valueControl is UcRadioGroup <bool?> )
                    {
                        var vc = (UcRadioGroup <bool?>)valueControl;
                        vc.Value = TmoComm.Convert2Type <bool?>(val);
                    }
                    else if (valueControl is UcRadioGroup <DateTime> )
                    {
                        var vc = (UcRadioGroup <DateTime>)valueControl;
                        vc.Value = TmoComm.Convert2Type <DateTime>(val);
                    }
                    else if (valueControl is CheckBoxGroup <int> )
                    {
                        var vc = (CheckBoxGroup <int>)valueControl;
                        vc.Value = (List <int>)valuearray.GetValue(i);
                    }
                    else if (valueControl is UcRadioGroup <float> )
                    {
                        var vc = (UcRadioGroup <float>)valueControl;
                        if (val == null)
                        {
                            val = -1;
                        }
                        vc.Value = TmoComm.Convert2Type <float>(val);
                    }
                    else if (valueControl is UcRadioGroup <string> )
                    {
                        var vc = (UcRadioGroup <string>)valueControl;
                        vc.Value = (string)valuearray.GetValue(i);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }