| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using CoreFS.CA06;
- using System.Data;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm;
- using System.Windows.Forms;
- using Infragistics.Win.UltraWinEditors;
- using System.Collections;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- namespace Core.StlMes.Client.Lims.Data.Mat
- {
- /// <summary>
- /// 自定义公共方法类
- /// </summary>
- class PublicMat
- {
- //状态位
- //CHECKCONSIGN_BASEINFO 0委托单位未取样,1委托单位正在送样,2加工已确认
- //CHECKCONSIGN_DETAIL '0', '未下发', '1', '加工已下发', '2', '试验室已确认', '3', '试验室已录入', '4', '试验室已审核'
- public const string chemMax = "ANA_C ANA_SI ANA_MN ANA_P ANA_S ANA_NI ANA_CR ANA_MO ANA_CU ANA_AL ANA_ALS ANA_CA ANA_V ANA_NB ANA_TI ANA_O ANA_N ANA_H ANA_ZN ANA_B ANA_ZR ANA_W ANA_CO ANA_FE ANA_PB ANA_SN ANA_AS ANA_SB ANA_BI";
- public const string chemMin = "C Si Mn P S Ni Cr Mo Cu Al Als Ca V Nb Ti O N H Zn B Zr W Co Fe Pb Sn As Sb Bi";
- /// <summary>
- /// 筛选符合条件的DataTable
- /// </summary>
- /// <param name="dt"></param>源dt
- /// <returns></returns>
- public static DataTable GetSelectDt(DataTable dtSource, string sql)
- {
- if (dtSource != null)
- {
- DataTable dtReturn = dtSource.Clone();
- DataRow[] arrDrSelect = dtSource.Select(sql);
- if (arrDrSelect != null && arrDrSelect.Length > 0)
- {
- foreach (DataRow row in arrDrSelect)
- {
- dtReturn.Rows.Add(row.ItemArray);
- }
- }
- return dtReturn;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 筛选符合条件的DataTable加入排序
- /// </summary>
- /// <param name="dt"></param>源dt
- /// <returns></returns>
- public static DataTable GetSelectDt(DataTable dtSource, string sql, string sort)
- {
- if (dtSource != null)
- {
- DataTable dtReturn = dtSource.Clone();
- DataRow[] arrDrSelect;
- if (sort != "")
- {
- arrDrSelect = dtSource.Select(sql, sort);
- }
- else
- {
- arrDrSelect = dtSource.Select(sql);
- }
- if (arrDrSelect != null && arrDrSelect.Length > 0)
- {
- foreach (DataRow row in arrDrSelect)
- {
- dtReturn.Rows.Add(row.ItemArray);
- }
- }
- return dtReturn;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 比较字符串是否含某元素
- /// </summary>
- /// <param name="chemName"></param>元素名称
- /// <returns></returns>
- public static bool IsHaveChemItems(string chemName, string[] arrChems)
- {
- if (chemName == "" || arrChems.Length == 0)
- {
- return false;
- }
- else
- {
- foreach (string row in arrChems)
- {
- if (chemName == row)
- {
- return true;
- }
- }
- }
- return false;
- }
- /// <summary>
- /// 激活当前操作的列
- ///
- /// </summary>
- /// <param name="ultraGrid"></param>
- /// <param name="strPK"></param>主键
- public static void ActiveOperateRow(UltraGrid ultraGrid, string strPK, string strPKText)
- {
- for (int i = 0; i < ultraGrid.Rows.Count; i++)
- {
- if (ultraGrid.Rows[i].Cells[strPK].Value.ToString() == strPKText)
- {
- ultraGrid.Rows[i].Activated = true;
- }
- }
- }
- /// <summary>
- /// 激活当前操作的列
- ///
- /// </summary>
- /// <param name="ultraGrid"></param>
- /// <param name="strPK"></param>多主键
- public static void ActiveOperateRow(UltraGrid ultraGrid, object[] strPK, object[] strPKText)
- {
- bool isEquals;
- for (int i = 0; i < ultraGrid.Rows.Count; i++)
- {
- isEquals = true;
- for (int j = 0; j < strPK.Length; j++)
- {
- if (ultraGrid.Rows[i].Cells[strPK[j].ToString()].Text != strPKText[j].ToString())
- {
- isEquals = false;
- break;
- }
- }
- if (isEquals == true)
- {
- ultraGrid.Rows[i].Activated = true;
- return;
- }
- }
- }
- //点击Grid编辑区显示基本信息
- public static void ShowBaseInfo(UltraGridRow ur, Panel panel)
- {
- if (ur != null)
- {
- foreach (UltraGridCell uc in ur.Cells)
- {
- if (panel.Controls.ContainsKey("txt" + uc.Column.Key) == true)//判定是否存在text
- {
- ((UltraTextEditor)panel.Controls["txt" + uc.Column.Key]).Text = uc.Text.Trim();
- }
- else if (panel.Controls.ContainsKey("ultra" + uc.Column.Key) == true)//判定是否存在text
- {
- ((UltraComboEditor)panel.Controls["ultra" + uc.Column.Key]).Text = uc.Text.Trim();
- }
- }
- }
- }
- //点击Grid编辑区显示基本信息
- public static void ShowBaseInfo(UltraGridRow ur, Panel panel, string[] cols)
- {
- if (ur != null)
- {
- foreach (UltraGridCell uc in ur.Cells)
- {
- if (panel.Controls.ContainsKey("txt" + uc.Column.Key) == true)//判定是否存在text
- {
- if (cols != null && cols.Contains(uc.Column.Key))
- {
- ((UltraTextEditor)panel.Controls["txt" + uc.Column.Key]).Text = "";
- }
- else
- {
- ((UltraTextEditor)panel.Controls["txt" + uc.Column.Key]).Text = uc.Text.Trim();
- }
- }
- else if (panel.Controls.ContainsKey("ultra" + uc.Column.Key) == true)//判定是否存在text
- {
- if (cols != null && cols.Contains(uc.Column.Key))
- {
- ((UltraComboEditor)panel.Controls["ultra" + uc.Column.Key]).Text = "";
- }
- else
- {
- ((UltraComboEditor)panel.Controls["ultra" + uc.Column.Key]).Text = uc.Text.Trim();
- }
- }
- }
- }
- }
- //点击Grid编辑区显示基本信息
- public static void ShowBaseInfo(UltraGridRow ur, Panel panel, string strRule)
- {
- if (ur != null)
- {
- foreach (UltraGridCell uc in ur.Cells)
- {
- if (panel.Controls.ContainsKey("txt" + uc.Column.Key + strRule) == true)//判定是否存在text
- {
- ((UltraTextEditor)panel.Controls["txt" + uc.Column.Key + strRule]).Text = uc.Text.Trim();
- }
- else if (panel.Controls.ContainsKey("ultra" + uc.Column.Key + strRule) == true)//判定是否存在text
- {
- ((UltraComboEditor)panel.Controls["ultra" + uc.Column.Key + strRule]).Text = uc.Text.Trim();
- }
- }
- }
- }
- //点击Grid编辑区显示基本信息
- public static void ShowDataTaleInfo(DataTable dt, Panel panel)
- {
- foreach (DataColumn dc in dt.Columns)
- {
- if (panel.Controls.ContainsKey("txt" + dc.ColumnName) == true)//判定是否存在text
- {
- ((UltraTextEditor)panel.Controls["txt" + dc.ColumnName]).Text = dt.Rows[0][dc.ColumnName].ToString();
- }
- else if (panel.Controls.ContainsKey("ultra" + dc.ColumnName) == true)//判定是否存在text
- {
- ((UltraComboEditor)panel.Controls["ultra" + dc.ColumnName]).Text = dt.Rows[0][dc.ColumnName].ToString();
- }
- }
- }
- /// <summary>
- /// 隐藏空列
- /// </summary>
- /// <param name="strHidden"></param>本来就隐藏的列名集合
- /// <param name="ug"></param>需要操作的UltraGrid
- /// <param name="dt"></param>需要操作的dt
- private void HideNullColumn(string strHidden, UltraGrid ultraGrid, DataTable dataTable)
- {
- if (strHidden != "")
- {
- foreach (DataColumn dc in dataTable.Columns)
- {
- if (strHidden.IndexOf(dc.ColumnName) >= 0)
- {
- continue;
- }
- foreach (DataRow dr in dataTable.Rows)
- {
- if (dr[dc].ToString() != "")
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = false;
- break;
- }
- else
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = true;
- }
- }
- }
- }
- else
- {
- foreach (DataColumn dc in dataTable.Columns)
- {
- foreach (DataRow dr in dataTable.Rows)
- {
- if (dr[dc].ToString() != "")
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = false;
- break;
- }
- else
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = true;
- }
- }
- }
- }
- }
- /// <summary>
- /// UltraGrid可读
- /// </summary>
- /// <param name="ugr">UltraGrid</param>
- /// <param name="keys">可编辑列</param>
- public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys)
- {
- if (keys == null || keys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- }
- else
- {
- keys.ToArray();
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- if (!keys.Contains(ugc.Key))
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- else
- {
- ugc.CellAppearance.BackColor = System.Drawing.Color.FromArgb(255, 255, 192);//可编辑列设置颜色为浅黄色
- //ugc.CellActivation = Activation.AllowEdit;
- }
- }
- }
- if (ugr.DisplayLayout.Bands[0].Columns.Exists("CHK"))
- {
- ugr.DisplayLayout.Bands[0].Columns["CHK"].DefaultCellValue = "False";
- ugr.DisplayLayout.Bands[0].Columns["CHK"].Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;
- ugr.DisplayLayout.Bands[0].Columns["CHK"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
- }
- }
- /// <summary>
- /// UltraGrid可读
- /// </summary>
- /// <param name="ugr">UltraGrid</param>
- /// <param name="keys">可编辑列</param>
- public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys, int bandNum)
- {
- if (bandNum < 0 || ugr.DisplayLayout.Bands.Count < bandNum + 1)
- {
- return;
- }
- if (keys == null || keys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- }
- else
- {
- keys.ToArray();
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
- {
- if (!keys.Contains(ugc.Key))
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- else
- {
- ugc.CellAppearance.BackColor = System.Drawing.Color.FromArgb(255, 255, 192);//可编辑列设置颜色为浅黄色
- //ugc.CellActivation = Activation.AllowEdit;
- }
- }
- }
- if (ugr.DisplayLayout.Bands[bandNum].Columns.Exists("CHK"))
- {
- ugr.DisplayLayout.Bands[bandNum].Columns["CHK"].DefaultCellValue = "False";
- ugr.DisplayLayout.Bands[bandNum].Columns["CHK"].Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;
- ugr.DisplayLayout.Bands[bandNum].Columns["CHK"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
- }
- }
- /// <summary>
- /// UltraGrid列是否隐藏
- /// </summary>isShow 为true则显示其他隐藏,false则隐藏其他显示
- /// <param name="ugr">UltraGrid</param>
- /// <param name="keys">隐藏列</param>
- public static void setColumnShowOrHidden(UltraGrid ugr, string[] keys, bool isShow)
- {
- if (keys == null || keys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- ugc.Hidden = false;
- }
- }
- else
- {
- keys.ToArray();
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- if (keys.Contains(ugc.Key))
- {
- if (isShow)
- {
- ugc.Hidden = false;
- }
- else
- {
- ugc.Hidden = true;
- }
- }
- else
- {
- if (isShow)
- {
- ugc.Hidden = true;
- }
- }
- }
- }
- }
- /// <summary>
- /// UltraGrid列是否隐藏
- /// </summary>isShow 为true则显示其他隐藏,false则隐藏其他显示
- /// <param name="ugr">UltraGrid</param>
- /// <param name="keys">隐藏列</param>
- public static void setColumnShowOrHidden(UltraGrid ugr, string[] keys, bool isShow, int bandNum)
- {
- if (bandNum < 0 || ugr.DisplayLayout.Bands.Count < bandNum + 1)
- {
- return;
- }
- if (keys == null || keys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
- {
- ugc.Hidden = false;
- }
- }
- else
- {
- keys.ToArray();
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
- {
- if (keys.Contains(ugc.Key))
- {
- if (isShow)
- {
- ugc.Hidden = false;
- }
- else
- {
- ugc.Hidden = true;
- }
- }
- else
- {
- if (isShow)
- {
- ugc.Hidden = true;
- }
- }
- }
- }
- }
- //初始化列
- public static void InitColumns(string[] arrColumns, string[] arrCaption, DataTable dataTable1)
- {
- if (arrColumns.Length == 0 || arrColumns.Length != arrCaption.Length)
- {
- return;
- }
- dataTable1.Columns.Clear();//先清除
- DataColumn dc;
- for (int i = 0; i < arrColumns.Length; i++)
- {
- try
- {
- dc = new DataColumn(arrColumns[i]);
- dc.Caption = arrCaption[i];
- dataTable1.Columns.Add(dc);
- if (dc.ColumnName == "CHK")
- {
- dc.DataType = typeof(bool);
- dc.DefaultValue = "False";
- }
- }
- catch
- {
- continue;
- }
- }
- }
- //初始化列
- public static void InitColumns(string[] arrColumns, string[] chemMax, object[] arrCaption, string[] chemMin, DataTable dataTable1)
- {
- if (arrColumns.Length == 0 || arrColumns.Length != arrCaption.Length || chemMax.Length != chemMin.Length)
- {
- return;
- }
- dataTable1.Columns.Clear();//先清除
- DataColumn dc;
- for (int i = 0; i < arrColumns.Length; i++)
- {
- try
- {
- dc = new DataColumn(arrColumns[i].ToString());
- dc.Caption = arrCaption[i].ToString();
- dataTable1.Columns.Add(dc);
- if (dc.ColumnName == "CHK")
- {
- dc.DataType = typeof(bool);
- dc.DefaultValue = "False";
- }
- }
- catch
- {
- continue;
- }
- }
- for (int i = 0; i < chemMax.Length; i++)
- {
- try
- {
- dc = new DataColumn(chemMax[i]);
- dc.Caption = chemMin[i];
- dataTable1.Columns.Add(dc);
- }
- catch
- {
- continue;
- }
- }
- }
- public static void InitColumns(string[] arrColumns, string[] arrCaption, DataTable dataTable, UltraGrid ultraGrid, string[] show, bool isShow, string[] ope)
- {
- InitColumns(arrColumns, arrCaption, dataTable);
- setColumnShowOrHidden(ultraGrid, show, isShow);
- setOtherColumnReadOnly(ultraGrid, ope);
- }
- //隐藏空列
- /// <summary>
- ///
- ///
- /// </summary>
- /// <param name="strHidden"></param>需要判断的列
- /// <param name="ug"></param>
- public static void HideNullColumn(string strHidden, UltraGrid ug)
- {
- string[] arr = strHidden.Split(',');
- for (int i = 0; i < arr.Length; i++)
- {
- if (!ug.DisplayLayout.Bands[0].Columns.Exists(arr[i]))
- {
- continue;
- }
- foreach (UltraGridRow ur in ug.Rows)
- {
- if (ur.Cells[arr[i]].Text != "")
- {
- ug.DisplayLayout.Bands[0].Columns[arr[i]].Hidden = false;
- break;
- }
- else
- {
- ug.DisplayLayout.Bands[0].Columns[arr[i]].Hidden = true;
- }
- }
- }
- }
- //选择事件
- /// <summary>
- ///
- ///
- /// </summary>
- /// <param name="strHidden"></param>
- /// <param name="ug"></param>
- public static void SelectRow(UltraGrid ultraGrid)
- {
- if (ultraGrid.DisplayLayout.Bands[0].Columns.Exists("CHK"))
- {
- foreach (UltraGridRow uRow in ultraGrid.Selected.Rows)
- {
- if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
- {
- uRow.Cells["CHK"].Value = true;
- }
- }
- }
- }
- public static void ReMoveColumns(DataTable dataTable, int position)
- {
- //从0开始
- int dcNum = dataTable.Columns.Count;
- if (dcNum > position)
- {
- for (int i = 0; i < dcNum - position; i++)
- {
- dataTable.Columns.RemoveAt(position);
- }
- }
- }
- //自适应
- private void RefreshAutoSize(UltraGrid ultraGrid1)
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns[0].Width = 80;
- for (int i = 1; i < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; i++)
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns[i].Width = 60;//设置列宽
- }
- }
- /// <summary>
- /// 设置列宽
- /// </summary>
- /// <param name="dt"></param>需要设置的UltraGrid
- /// <param name="haveNum"></param>不需要清除的列
- /// /// <param name="width"></param>宽度
- public static void ColumnsWidth(UltraGrid ultraGrid, int haveNum, int width)
- {
- int col = ultraGrid.DisplayLayout.Bands[0].Columns.Count;
- for (int i = haveNum; i < col; i++)
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[i].Width = width;//设置列宽
- }
- }
- /// <summary>
- /// 设置列宽
- /// </summary>
- /// <param name="dt"></param>需要设置的UltraGrid
- /// <param name="haveNum"></param>不需要清除的列
- /// /// <param name="width"></param>宽度
- public static void ColumnsWidth(UltraGrid ultraGrid, int haveNum, int width, string[] noSet)
- {
- ArrayList al = new ArrayList();
- for (int i = 0; i < noSet.Length; i++)
- {
- al.Add(noSet[i]);
- }
- int col = ultraGrid.DisplayLayout.Bands[0].Columns.Count;
- for (int i = haveNum; i < col; i++)
- {
- if (!al.Contains(ultraGrid.DisplayLayout.Bands[0].Columns[i].ToString()))
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[i].Width = width;//设置列宽
- }
- }
- }
- /// <summary>
- /// 刷新Grid数据并根据数据调整Grid列宽
- /// </summary>
- /// <param name="ultraGrid">需要处理的Grid</param>
- /// <param name="cols">需要调整的列</param>
- /// <param name="is调整">true则自适应,false则不自适应</param>
- public static void RefreshAndAutoSizeColumns(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid, object[] cols, bool isMove)
- {
- try
- {
- ultraGrid.DataBind();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
- {
- foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
- {
- if (cols != null && cols.Contains(column.Key))
- {
- if (!isMove)
- {
- continue;
- }
- column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);//AllRowsInBand
- }
- else
- {
- if (!isMove)
- {
- column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- }
- }
- }
- }
- ultraGrid.Refresh();
- }
- catch { }
- }
- //改变splitContainer1.Panel1
- public static void ChangeSplit(SplitContainer splitContainer, DataTable dtPhyMax)
- {
- if (dtPhyMax != null && dtPhyMax.Rows.Count > 0)
- {
- splitContainer.Panel1Collapsed = false;
- }
- else
- {
- splitContainer.Panel1Collapsed = true; ;
- }
- }
- //默认试验室数据权限
- public static string[] ValidData()
- {
- string[] arrId = new string[7] { "002001007009", "002001007015", "002001007013", "002001007014", "002001007010", "002001020001", "002001020002" };
- //DECODE(T.DEPT_ID,
- // '002001007009',
- // '力学',
- // '002001007015',
- // '金相',
- // '002001007013',
- // '腐蚀',
- // '002001007014',
- // '工程',
- // '002001007010',
- // '化学',
- // '002001020001',
- // '一快分',
- // '002001020002',
- // '二快分')
- return arrId;
- }
- //解析数据权限
- public static string ValidDataString(string[] arrId)
- {
- string strId = "";
- if (arrId != null)
- {
- foreach (string str in arrId)
- {
- strId += "'" + str + "',";
- }
- }
- strId = strId.Remove(0, 1);
- strId = strId.Remove(strId.Length - 2);
- return strId;
- }
- /// <summary>
- /// 更改文件路径
- /// </summary>
- /// <param name="Department">user_depatment</param>
- /// <returns></returns>
- public static void UpdateFilePosition(string strTableName, string strPath, string strPk, string strPkValue, OpeBase ob)
- {
- try
- {
- string sql = "UPDATE " + strTableName + " SET FILE_POSITION = '" + strPath + "' WHERE " + strPk + " = '" + strPkValue + "'";
- PublicServer.SetData("com.steering.BaseInfo.UpdateFilePosition", new Object[] { sql }, ob);
- }
- catch
- {
- }
- }
- /// <summary>
- /// 更改文件路径
- /// strColumnName 字段名
- /// </summary>
- /// <param name="Department">user_depatment</param>
- /// <returns></returns>
- public static void UpdateFilePosition(string strTableName, string strColumnName, string strPath, string strPk, string strPkValue, OpeBase ob)
- {
- try
- {
- string sql = "UPDATE " + strTableName + " SET " + strColumnName + " = '" + strPath + "' WHERE " + strPk + " = '" + strPkValue + "'";
- PublicServer.SetData("com.steering.BaseInfo.UpdateFilePosition", new Object[] { sql }, ob);
- }
- catch
- {
- }
- }
- /// <summary>
- /// 查看文件路径
- /// </summary>
- /// <param name="Department">user_depatment</param>
- /// <returns></returns>
- public static bool ViewFilePosition(OpeBase _ob, string path)
- {
- bool isSucc = true;
- FormFileDown down = new FormFileDown(_ob, path);
- down.ShowDialog();
- if (down == null || down.CtrlFileDown1 == null || down.CtrlFileDown1.List == null || down.CtrlFileDown1.List.Count == 0)
- {
- isSucc = false;//删除了则更新FILE_POSITION
- }
- return isSucc;
- }
- /// <summary>
- /// 上传文件路径
- /// </summary>
- /// <param name="Department">user_depatment</param>
- /// <returns></returns>
- public static bool UploadFilePosition(OpeBase _ob, string path)
- {
- //var serverFileList = FileHelper.Download(path);
- //if (serverFileList.Count > 0)
- //{
- // MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!");
- // return false;
- //}
- List<FileBean> list = new List<FileBean>();
- FileBean bean = new FileBean();
- OpenFileDialog file = new OpenFileDialog();
- file.Multiselect = false;
- DialogResult drStat;
- drStat = file.ShowDialog();
- if (drStat == DialogResult.OK)
- {
- string filePath = file.FileName;
- string fileName = System.IO.Path.GetFileName(filePath);
- bean = new FileBean();
- bean.setFileName(fileName);
- bean.setPathName(path);
- bean.setFile(FileHelper.FileToArray(filePath));
- list.Add(bean);
- bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
- if (isSuccess)
- {
- MessageUtil.ShowTips("上传成功!");
- }
- else
- {
- MessageUtil.ShowTips("上传失败,请重试!");
- }
- return isSuccess;//成功了则更新FILE_POSITION
- }
- return false;
- }
- public static void GridEdite(UltraGridRow row)
- {
- if (row.GetValue("CHK") == "True")
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.AllowEdit;
- }
- }
- }
- else
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.Key == "CHK") continue;
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- }
- }
|