Пример #1
0
 /// <summary>
 /// 加载数据
 /// </summary>
 public void GetData()
 {
     this.ShowWaitingPanel(() =>
     {
         return(GetDataMethod());
     }, x =>
     {
         try
         {
             DataTable dt = x as DataTable;
             if (TmoShare.DataTableIsEmpty(dt))
             {
                 throw new Exception("服务器返回数据为空");
             }
             if (!SetControlData(dt.Rows[0]))
             {
                 throw new Exception("充填控件值失败");
             }
             AfterGetData(dt.Rows[0]);
         }
         catch (Exception ex)
         {
             LogHelper.Log.Error("实体加载数据出错", ex);
             DXMessageBox.btnClick += (object sender, EventArgs e) => { btnCancel_Click(null, null); };
             DXMessageBox.ShowWarning2("数据加载失败!请重试!");
         }
     });
 }
Пример #2
0
        protected override void OnViewClick(DataRow selectedRow)
        {
            base.OnViewClick(selectedRow);
            if (Is_public != 2)
            {
                return;
            }
            string      aclb_id        = selectedRow.GetDataRowStringValue("aclb_id");
            string      aclb_base64Ext = selectedRow.GetDataRowStringValue("aclb_base64Ext");
            string      type_name      = selectedRow.GetDataRowStringValue("type_name");
            string      aclb_title     = selectedRow.GetDataRowStringValue("aclb_title");
            string      title          = type_name + "-" + aclb_title;
            UCWordViews wordViews;

            if (_dicWordViews.ContainsKey(title))
            {
                wordViews = _dicWordViews[title];
            }
            else
            {
                wordViews             = new UCWordViews();
                wordViews.Title       = title;
                wordViews.FormClosed += (sender, e) =>
                {
                    if (_dicWordViews.ContainsKey(wordViews.Title))
                    {
                        _dicWordViews.Remove(wordViews.Title);
                    }
                };
                _dicWordViews.Add(title, wordViews);
            }

            wordViews.ShowForm(() =>
            {
                DataTable dt = Tmo_FakeEntityClient.Instance.GetData(TableName, new string[] { "aclb_base64" }, null, "aclb_id", aclb_id);
                if (TmoShare.DataTableIsEmpty(dt))
                {
                    return(null);
                }
                else
                {
                    string base64    = dt.Rows[0][0].ToString();
                    byte[] fileBytes = StringPlus.DecompressBytes(Convert.FromBase64String(base64));
                    MemoryStream ms  = new MemoryStream(fileBytes);
                    return(ms);
                }
            }, aclb_base64Ext);
        }
Пример #3
0
        /// <summary>
        /// 删除按钮点击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void linkDel_Click(object sender, EventArgs e)
        {
            DataRowView drv = treeList1.GetDataRecordByNode(treeList1.FocusedNode) as DataRowView;

            if (drv != null)
            {
                object dpt_id   = drv["dpt_id"];
                object dpt_name = drv["dpt_name"];
                if (dpt_id != null && !string.IsNullOrWhiteSpace(dpt_id.ToString()))
                {
                    if (dpt_id.ToString() == TmoComm.login_docInfo.doc_department.ToString())
                    {
                        DXMessageBox.ShowInfo("没有权限!");
                        return;
                    }
                    string    dptds = Tmo_CommonClient.Instance.GetChildrenNodeFromTable(TableName, PrimaryKey, "dpt_parent", dpt_id.ToString());
                    DataTable dt    = Tmo_FakeEntityClient.Instance.GetData("tmo_docinfo", new string[] { "count(*) c" }, "doc_department in (" + dptds + ")");
                    if (TmoShare.DataTableIsEmpty(dt))
                    {
                        DXMessageBox.ShowError("删除失败,请重试!"); return;
                    }
                    if (dt.Rows[0].GetDataRowIntValue("c") > 0)
                    {
                        DXMessageBox.ShowWarning2("该部门下分配有健康师,删除被阻止!");
                        return;
                    }
                    DXMessageBox.btnOKClick += (object sender1, EventArgs e1) =>
                    {
                        //删除部门操作
                        bool suc = Tmo_FakeEntityClient.Instance.DeleteData(TableName, PrimaryKey, dpt_id.ToString());
                        if (!suc)
                        {
                            DXMessageBox.ShowError("删除失败,请重试!");
                            return;
                        }
                        //Dictionary<string, object> dic = new Dictionary<string, object>();
                        //dic.Add("doc_department", -1);
                        //suc = Tmo_FakeEntityClient.Instance.SubmitData(DBOperateType.Update, "tmo_docinfo", "doc_department", dpt_id.ToString(), dic);
                        Tmo_CommonClient.Instance.RefreshDocChildrenDpt();
                        GetData();
                        DXMessageBox.Show("部门 [" + dpt_name + "] 删除成功!", true);
                    };
                    DXMessageBox.ShowQuestion("你确定要删除部门 [" + dpt_name + "] 吗?");
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 绑定ComboBox数据项
        /// </summary>
        /// <param name="cmb"></param>
        /// <param name="dtSource"></param>
        /// <param name="displayCol"></param>
        /// <param name="valueCol"></param>
        public static void BindImageComboBox(ImageComboBoxEdit cmb, DataTable dtSource, string filterExpression, string displayCol, string valueCol,
                                             bool showTipItem = false)
        {
            if (TmoShare.DataTableIsEmpty(dtSource) || cmb == null || string.IsNullOrWhiteSpace(displayCol) ||
                string.IsNullOrWhiteSpace(valueCol))
            {
                if (cmb != null)
                {
                    cmb.Properties.Items.Clear();
                }
                return;
            }

            cmb.Properties.Items.Clear();
            if (showTipItem)
            {
                ImageComboBoxItem itemtemp = new ImageComboBoxItem();
                itemtemp.Value       = null;
                itemtemp.Description = "请选择...";
                cmb.Properties.Items.Add(itemtemp);
            }

            DataRow[] rows = dtSource.Select(filterExpression);
            for (int i = 0; i < rows.Length; i++)
            {
                ImageComboBoxItem itemtemp1 = new ImageComboBoxItem();

                itemtemp1.Value       = rows[i][valueCol];
                itemtemp1.Description = rows[i][displayCol].ToString();
                cmb.Properties.Items.Add(itemtemp1);
            }


            if (cmb.Properties.Items.Count > 0)
            {
                if (cmb.SelectedIndex != 0)
                {
                    cmb.SelectedIndex = 0;
                }
            }
            else
            {
                cmb.SelectedIndex = -1;
            }
        }
Пример #5
0
        /// <summary>
        /// 绑定ComboBox数据项
        /// </summary>
        /// <param name="cmb"></param>
        /// <param name="dtSource"></param>
        /// <param name="displayCol"></param>
        /// <param name="valueCol"></param>
        public static void BindRepositoryImageComboBox(RepositoryItemImageComboBox cmb, DataTable dtSource, string displayCol, string valueCol)
        {
            if (TmoShare.DataTableIsEmpty(dtSource) || cmb == null || string.IsNullOrWhiteSpace(displayCol) || string.IsNullOrWhiteSpace(valueCol))
            {
                return;
            }

            cmb.Items.Clear();

            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                ImageComboBoxItem itemtemp1 = new ImageComboBoxItem();

                itemtemp1.Value       = dtSource.Rows[i][valueCol];
                itemtemp1.Description = dtSource.Rows[i][displayCol].ToString();
                cmb.Items.Add(itemtemp1);
            }
        }
Пример #6
0
        /// <summary>
        /// 得到个人信息
        /// </summary>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public Userinfo GetUserinfo(string user_id)
        {
            if (string.IsNullOrWhiteSpace(user_id))
            {
                return(null);
            }
            DataTable dt = Tmo_FakeEntityClient.Instance.GetData("tmo_userinfo", null, null, "user_id", user_id);

            if (TmoShare.DataTableIsEmpty(dt))
            {
                return(null);
            }

            DataRow  row      = dt.Rows[0];
            Userinfo userinfo = ModelConvertHelper <Userinfo> .ConvertToOneModel(row);

            return(userinfo);
        }
Пример #7
0
        protected override void OnRowCellClick(DataRow dr, RowCellClickEventArgs e)
        {
            base.OnRowCellClick(dr, e);
            if (e.Column.Name == "gc_actionplan")
            {
                //健康计划
                int status = dr.GetDataRowIntValue("questionnare_status");

                string   apid = dr.GetDataRowStringValue("apid");
                Userinfo user = ModelConvertHelper <Userinfo> .ConvertToOneModel(dr);

                if (string.IsNullOrWhiteSpace(apid))
                {
                    var ucActionPlanEditor = new UCActionPlanEditor(user);
                    ucActionPlanEditor.ShowDialog(this);
                    ucActionPlanEditor.Dispose();
                    GetData();
                }
                else
                {
                    DataTable dt = TmoServiceClient.InvokeServerMethodT <DataTable>(funCode.GetActionPlan, apid);
                    if (TmoShare.DataTableIsEmpty(dt))
                    {
                        DXMessageBox.ShowWarning2("数据加载失败,请稍后再试!");
                        return;
                    }
                    string content = dt.Rows[0].GetDataRowStringValue("content");
                    if (status <= 3)
                    {
                        var ucActionPlanEditor = new UCActionPlanEditor(user, content);
                        ucActionPlanEditor.ShowDialog(this);
                        ucActionPlanEditor.Dispose();
                        GetData();
                    }
                    else
                    {
                        var ucActionPlan = new UCActionPlan(user, content);
                        ucActionPlan.ShowDialog(this);
                        ucActionPlan.Dispose();
                    }
                }
            }
        }
Пример #8
0
        /// <summary>
        /// 跟据部门ID得到部门名字
        /// </summary>
        /// <returns></returns>
        public string GetDepartmentNamesFromIDs(string ids)
        {
            if (string.IsNullOrWhiteSpace(ids))
            {
                return(string.Empty);
            }
            if (TmoShare.DataTableIsEmpty(tmo_department))
            {
                tmo_department = Tmo_FakeEntityClient.Instance.GetData("tmo_department");
            }
            if (TmoShare.DataTableIsEmpty(tmo_department))
            {
                return(string.Empty);
            }

            string[]      idarray = ids.Split(',');
            List <string> idlist  = new List <string>();

            foreach (string s in idarray)
            {
                if (TmoShare.IsNumricForInt(s))
                {
                    idlist.Add(s);
                }
            }
            ids = StringPlus.GetArrayStr(idlist, ",", "'{0}'");
            if (string.IsNullOrEmpty(ids))
            {
                return(string.Empty);
            }

            DataRow[]     rows = tmo_department.Select("dpt_id in (" + ids + ")");
            StringBuilder sb   = new StringBuilder();

            foreach (DataRow dataRow in rows)
            {
                sb.AppendFormat("{0},", dataRow.GetDataRowStringValue("dpt_name"));
            }
            return(sb.ToString().TrimEnd(','));
        }
Пример #9
0
        /// <summary>
        /// 从表里面获得子节点
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="codeName"></param>
        /// <param name="parentName"></param>
        /// <param name="nodeVal"></param>
        /// <returns></returns>
        public string GetChildrenNodeFromTable(string tableName, string codeName, string parentName, string nodeVal, bool addSelf = true)
        {
            if (string.IsNullOrWhiteSpace(tableName) || string.IsNullOrWhiteSpace(codeName) || string.IsNullOrWhiteSpace(parentName) || string.IsNullOrWhiteSpace(nodeVal))
            {
                return("err_params");
            }

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

            if (TmoShare.DataTableIsEmpty(dt))
            {
                return(null);
            }

            List <string> list = new List <string>();

            list.AddRange(GetChildrenCode(dt, codeName, parentName, nodeVal));
            if (!addSelf)
            {
                list.Remove(nodeVal);
            }
            return(StringPlus.GetArrayStr(list, ","));
        }
Пример #10
0
        private DateTime lastScanTime = DateTime.MinValue; //上次扫描日期

        /// <summary>
        /// 处理无线设备临时接收表里的数据
        /// </summary>
        /// <param name="state"></param>
        private void MoveMonitorReceived(object state)
        {
            try
            {
                if ((DateTime.Now - lastScanTime).TotalMinutes > 5) //每5分钟处理一次
                {
                    List <string> sqlList = new List <string>();
                    DataTable     tmo_monitor_devicebind = MemoryCacheHelper.GetCacheItem <DataTable>("tmo_monitor_devicebind",
                                                                                                      () => MySQLHelper.QueryTable(
                                                                                                          "select a.*,b.is_del from tmo_monitor_devicebind a left join tmo_userinfo b on a.dev_userid=b.user_id where b.is_del!=1"),
                                                                                                      DateTime.Now.AddMinutes(30));
                    if (TmoShare.DataTableIsEmpty(tmo_monitor_devicebind))
                    {
                        return;
                    }
                    DataTable dtstruct = MemoryCacheHelper.GetCacheItem <DataTable>("ts_tmo_monitor", () => MySQLHelper.QueryTableStruct("tmo_monitor").Tables[0],
                                                                                    DateTime.Now.AddHours(24));
                    DataTable tmo_monitor_received =
                        Tmo_FakeEntityManager.Instance.GetData("tmo_monitor_received", null, $"input_time>='{DateTime.Now.AddDays(-30)}'");
                    if (TmoShare.DataTableIsNotEmpty(tmo_monitor_received))
                    {
                        foreach (DataRow row in tmo_monitor_received.Rows)
                        {
                            string user_id = row.GetDataRowStringValue("user_id");

                            //int dev_type = row.GetDataRowIntValue("remark");
                            DataRow[] drs = tmo_monitor_devicebind.Select($"dev_sn = '{user_id}'");
                            if (drs.Length == 0)
                            {
                                if (Regex.IsMatch(user_id, @"^[\s|\S]"))
                                {
                                    user_id = user_id.Substring(user_id.Length - 2, 2) + user_id.Remove(user_id.Length - 2);
                                    drs     = tmo_monitor_devicebind.Select($"dev_sn = '{user_id}'");
                                }
                            }

                            if (drs.Length > 0)
                            {
                                user_id = drs[0].GetDataRowStringValue("dev_userid"); //找到绑定关系
                                Dictionary <string, string> colVals = new Dictionary <string, string>();
                                colVals.Add("user_id", user_id);

                                foreach (DataColumn dc in tmo_monitor_received.Columns)
                                {
                                    string colname = dc.ColumnName;
                                    if (colname.ToLower() == "id" || colname.ToLower() == "input_time")
                                    {
                                        continue;                                                                 //跳过主键
                                    }
                                    if (colVals.ContainsKey(colname))
                                    {
                                        continue;                               //已添加字段跳过
                                    }
                                    if (!dtstruct.Columns.Contains(colname))
                                    {
                                        continue;                                      //非monitor表中字段跳过
                                    }
                                    colVals.Add(colname, row[dc].ToString());
                                }

                                StringBuilder sbsql    = new StringBuilder("insert into tmo_monitor(");
                                StringBuilder sbsqlval = new StringBuilder(" values(");
                                foreach (var item in colVals)
                                {
                                    if (item.Key == "mt_time")
                                    {
                                        try
                                        {
                                            DateTime dt = DateTimeHelper.ToDateTime(item.Value);
                                            sbsql.Append(item.Key + ",");
                                            sbsqlval.AppendFormat("'{0}',", dt.ToFormatDateTimeStr());
                                        }
                                        catch
                                        {
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        sbsql.Append(item.Key + ",");
                                        sbsqlval.AppendFormat("{0},", item.Value == String.Empty ? "null" : $"'{item.Value}'");
                                    }
                                }

                                sbsql.Append("input_time)");
                                sbsqlval.Append("SYSDATE())");
                                sqlList.Add(sbsql.ToString() + sbsqlval.ToString());

                                sqlList.Add("delete from tmo_monitor_received where id=" + row["id"]);
                            }
                        }
                    }

                    if (sqlList.Count != 0)
                    {
                        MySQLHelper.ExecuteSqlTran(sqlList);
                    }
                    lastScanTime = DateTime.Now;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log.Error("临时表保存数据到监测表错误", ex);
            }
            finally
            {
                ((ManualResetEvent)((object[])state)[0]).Set();
            }
        }