| | |
| | | using System; |
| | | using DevExpress.Utils; |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraEditors.Controls; |
| | | using DevExpress.XtraGrid; |
| | | using DevExpress.XtraGrid.Columns; |
| | | using DevExpress.XtraGrid.Menu; |
| | | using DevExpress.XtraGrid.Views.Grid; |
| | | using DevExpress.XtraGrid.Views.Grid.ViewInfo; |
| | | using DevExpress.XtraTab; |
| | | using DevExpress.XtraTreeList; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.UserControl; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data; |
| | |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using DevExpress.DataAccess.Native.EntityFramework; |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraEditors.Controls; |
| | | using DevExpress.XtraGrid; |
| | | using DevExpress.XtraGrid.Columns; |
| | | using DevExpress.XtraGrid.Menu; |
| | | using DevExpress.XtraGrid.Views.Grid; |
| | | using DevExpress.XtraTab; |
| | | using DevExpress.XtraTreeList; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.UserControl; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System.Windows.Forms.VisualStyles; |
| | | using UserControls.Data; |
| | | using static System.Windows.Forms.Control; |
| | | |
| | |
| | | { |
| | | private static readonly string WebApiUrl = |
| | | ConfigurationManager.AppSettings["WebApiUrl"]; |
| | | |
| | | |
| | | public static async Task<string> UploadFileAsync(string filePath) |
| | | { |
| | |
| | | if (cols.Length > 0) |
| | | { |
| | | var colType = cols[0]; |
| | | |
| | | if (colType is LookUpEdit) |
| | | { |
| | | var txt = colType as LookUpEdit; |
| | |
| | | else |
| | | txt.Text = strVal; |
| | | txt.ReadOnly = isEdt; |
| | | continue; |
| | | } |
| | | if (colType is ButtonEdit) |
| | | { |
| | | var txt = colType as ButtonEdit; |
| | | if (txt != null) |
| | | txt.Text = strVal; |
| | | txt.Enabled = !isEdt; |
| | | continue; |
| | | } |
| | | //文本 |
| | |
| | | txt.Text = strVal; |
| | | } |
| | | } |
| | | |
| | | //自定义仓库 |
| | | if (colType is UcLookCk) |
| | | { |
| | |
| | | txt.ReadOnly = isEdt; |
| | | continue; |
| | | } |
| | | if (ctrl is ButtonEdit) |
| | | { |
| | | var txt = ctrl as ButtonEdit; |
| | | txt.Text = ""; |
| | | txt.Enabled = !isEdt; |
| | | txt.ReadOnly = isEdt; |
| | | continue; |
| | | } |
| | | //文本 |
| | | if (ctrl is TextEdit) |
| | | { |
| | |
| | | txt.IsReadly = isEdt; |
| | | continue; |
| | | } |
| | | |
| | | |
| | | //自定部门 |
| | | if (ctrl is UcLookDepartment) |
| | | { |
| | |
| | | } |
| | | foreach (Control ctrl in controls) |
| | | { |
| | | //下拉 |
| | | if (ctrl is ComboBoxEdit) |
| | | { |
| | | var txt = ctrl as ComboBoxEdit; |
| | | txt.ReadOnly = isEdt; |
| | | continue; |
| | | } |
| | | if (ctrl is ButtonEdit) |
| | | { |
| | | var txt = ctrl as ButtonEdit; |
| | | txt.Enabled = !isEdt; |
| | | continue; |
| | | } |
| | | //文本 |
| | | if (ctrl is TextEdit) |
| | | { |
| | |
| | | txt.ReadOnly = isEdt; |
| | | continue; |
| | | } |
| | | |
| | | //日期 |
| | | if (ctrl is DateTimePicker) |
| | | { |
| | | ctrl.Enabled = !isEdt; |
| | | continue; |
| | | } |
| | | |
| | | //单选 |
| | | if (ctrl is CheckBox) |
| | | { |
| | |
| | | txt.IsReadly = isEdt; |
| | | continue; |
| | | } |
| | | |
| | | |
| | | //自定部门 |
| | | if (ctrl is UcLookDepartment) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | public static bool ToCheck(string str) |
| | | { |
| | | if (str.ToUpper() == "true".ToUpper()) |
| | | return true; |
| | | if (str.ToUpper() == "1".ToUpper()) |
| | | return true; |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取grid的当前行 |
| | |
| | | /// <param name="fileName">字段</param> |
| | | /// <param name="icoName">图标路径</param> |
| | | /// <param name="action"></param> |
| | | public static void SetGridViewParameter(GridView gridView1, PictureBox picCheckBox = null, Form fm = null, string fileName = "checkStatus", string icoName = "", DelegateGetModel action = null) |
| | | public static void SetGridViewParameter(GridView gridView1, PictureBox picCheckBox = null, Form fm = null, string fileName = "checkStatus", string icoName = "", DelegateGetModel action = null, DevExpress.Utils.ToolTipController tips = null, bool isPostSearch = true) |
| | | { |
| | | gridView1.PopupMenuShowing += (s, e) => |
| | | { |
| | |
| | | } |
| | | } |
| | | }; |
| | | gridView1.OptionsView.ShowGroupPanel = false; |
| | | gridView1.OptionsCustomization.AllowGroup = false; |
| | | // gridView1.Appearance.HeaderPanel.ForeColor = DevExpress.LookAndFeel.DXSkinColors.ForeColors.ControlText; |
| | | gridView1.OptionsView.ColumnAutoWidth = false;//自动调整列宽 |
| | | |
| | | if (isPostSearch == true) |
| | | { |
| | | gridView1.OptionsView.ShowGroupPanel = false; |
| | | gridView1.OptionsCustomization.AllowGroup = false; |
| | | gridView1.OptionsFilter.AllowAutoFilterConditionChange = DevExpress.Utils.DefaultBoolean.False; |
| | | gridView1.OptionsView.ShowAutoFilterRow = true; |
| | | gridView1.OptionsFilter.AllowFilterEditor = false; |
| | | gridView1.OptionsFilter.ShowCustomFunctions = DevExpress.Utils.DefaultBoolean.False; |
| | | gridView1.OptionsFilter.AllowColumnMRUFilterList = false; |
| | | gridView1.OptionsFilter.AllowMRUFilterList = false; |
| | | gridView1.OptionsCustomization.AllowFilter = false; |
| | | gridView1.OptionsFind.ShowSearchNavButtons = false; |
| | | gridView1.OptionsView.ShowGroupPanel = false; |
| | | //是否显示底部的过滤条 |
| | | // gridView1.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never; |
| | | } |
| | | |
| | | // gridView1.Appearance.HeaderPanel.ForeColor = DevExpress.LookAndFeel.DXSkinColors.ForeColors.ControlText; |
| | | foreach (GridColumn column in gridView1.Columns) |
| | | { |
| | | column.MinWidth = 10; |
| | | column.MaxWidth = 0; |
| | | |
| | | column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near; |
| | | column.OptionsColumn.AllowEdit = true; |
| | | // column.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains; |
| | |
| | | column.OptionsColumn.ReadOnly = false; |
| | | else |
| | | column.OptionsColumn.ReadOnly = true; |
| | | if (column.Tag == null || column.Tag.ToString().Length <= 0) |
| | | column.OptionsFilter.AllowAutoFilter = false; |
| | | |
| | | //if(isPostSearch==false) |
| | | // column.OptionsColumn.ReadOnly = true; |
| | | |
| | | if (isPostSearch == true) |
| | | { |
| | | if (column.Tag == null || column.Tag.ToString().Length <= 0) |
| | | column.OptionsFilter.AllowAutoFilter = false; |
| | | } |
| | | } |
| | | gridView1.OptionsFilter.AllowAutoFilterConditionChange = DevExpress.Utils.DefaultBoolean.False; |
| | | gridView1.OptionsView.ShowAutoFilterRow = true; |
| | | gridView1.OptionsFilter.AllowFilterEditor = false; |
| | | gridView1.OptionsFilter.ShowCustomFunctions = DevExpress.Utils.DefaultBoolean.False; |
| | | gridView1.OptionsFilter.AllowColumnMRUFilterList = false; |
| | | gridView1.OptionsFilter.AllowMRUFilterList = false; |
| | | gridView1.OptionsCustomization.AllowFilter = false; |
| | | gridView1.OptionsFind.ShowSearchNavButtons = false; |
| | | gridView1.OptionsView.ShowGroupPanel = false; |
| | | //是否显示底部的过滤条 |
| | | // gridView1.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never; |
| | | |
| | | gridView1.IndicatorWidth = 50; |
| | | gridView1.CustomDrawRowIndicator += (s, e) => |
| | | { |
| | |
| | | //} |
| | | } |
| | | }; |
| | | |
| | | |
| | | if (tips != null) |
| | | { |
| | | tips.Appearance.BackColor = Color.LightBlue; // 设置背景颜色 |
| | | tips.Appearance.ForeColor = Color.Black; // 设置前景色(文字颜色) |
| | | gridView1.MouseMove += (s, e) => |
| | | { |
| | | try |
| | | { |
| | | GridHitInfo hi = gridView1.CalcHitInfo(new Point(e.X, e.Y)); |
| | | if (hi.InRowCell) |
| | | { |
| | | int cuRowHandle = hi.RowHandle; |
| | | if (cuRowHandle < 0) |
| | | return; |
| | | DataRow curRow = gridView1.GetDataRow(cuRowHandle); |
| | | var column = hi.Column; |
| | | string showTxt = curRow[column.FieldName].ToString(); |
| | | ToolTipControllerShowEventArgs aa = new ToolTipControllerShowEventArgs(); |
| | | aa.AllowHtmlText = DefaultBoolean.True; |
| | | aa.Title = column.Caption; //HTML, 粗体 |
| | | aa.ToolTip = showTxt; //断行 |
| | | aa.ShowBeak = true; |
| | | aa.Rounded = true; ////圆角 |
| | | aa.RoundRadius = 7; //圆角率 |
| | | // aa.ToolTipType = ToolTipType.SuperTip; //超级样式,可多行或显示图标 |
| | | aa.ToolTipType = ToolTipType.Standard;//标准样式,可显示鸟嘴。 |
| | | aa.IconType = ToolTipIconType.Information; //消息图标 |
| | | aa.IconSize = ToolTipIconSize.Small; //大图标 |
| | | tips.ShowHint(aa); |
| | | } |
| | | else |
| | | tips.HideHint(); |
| | | } |
| | | catch (Exception exception) |
| | | { |
| | | } |
| | | }; |
| | | } |
| | | } |
| | | private static void ActiveEditor_MouseUp(object sender, MouseEventArgs e) |
| | | { |
| | |
| | | { |
| | | // column.DefaultCellStyle.Alignment = true; |
| | | column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near; |
| | | column.MinWidth = 10; |
| | | column.MaxWidth = 0; |
| | | } |
| | | gridView1.OptionsView.ColumnAutoWidth = false;//自动调整列宽 |
| | | gridView1.OptionsFilter.AllowFilterEditor = false; |
| | |
| | | Regex regex = new Regex("^[0-9]+$"); |
| | | return regex.IsMatch(str); |
| | | } |
| | | public static bool IsNumeric2(string str) |
| | | { |
| | | string input = str; |
| | | decimal number; |
| | | bool isNumeric = decimal.TryParse(input, out number); |
| | | return isNumeric; |
| | | } |
| | | |
| | | public static void PrintJiSuan(DevExpress.XtraEditors.TextEdit box1, DevExpress.XtraEditors.TextEdit box2, string sum, DevExpress.XtraEditors.RadioGroup rd) |
| | | { |
| | | if (rd.SelectedIndex == 2) |
| | | return; |
| | | try |
| | | { |
| | | string t1 = box1.Text.Trim(); |
| | | string t2 = box2.Text.Trim(); |
| | | if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric2(t1)) |
| | | return; |
| | | decimal? dc = Gs.DevApp.ToolBox.UtilityHelper.GetDecimal(sum); |
| | | decimal? dc1 = Gs.DevApp.ToolBox.UtilityHelper.GetDecimal(t1); |
| | | |
| | | int dividend = int.Parse(sum); // 被除数 |
| | | int divisor = int.Parse(t1); // 除数 |
| | | |
| | | int quotient = dividend / divisor; // 整数部分 |
| | | int remainder = dividend % divisor; // 余数 |
| | | |
| | | box2.Text = quotient.ToString(); |
| | | |
| | | if (rd.SelectedIndex == 0) |
| | | rd.Properties.Items[0].Description = "全自动【" + remainder.ToString() + "】"; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message); |
| | | } |
| | | |
| | | } |
| | | public static void PrintAuto(DevExpress.XtraEditors.TextEdit txt_psnQty_1, DevExpress.XtraEditors.TextEdit txt_iCount_1, DevExpress.XtraEditors.RadioGroup radOut) |
| | | { |
| | | txt_psnQty_1.Text = ""; |
| | | txt_iCount_1.Text = ""; |
| | | radOut.Properties.Items[0].Description = "全自动"; |
| | | if (radOut.SelectedIndex == 2) |
| | | txt_iCount_1.ReadOnly = false; |
| | | else |
| | | txt_iCount_1.ReadOnly = true; |
| | | } |
| | | public static decimal PrintYuLiang(DevExpress.XtraEditors.RadioGroup rd) |
| | | { |
| | | decimal dc = 0; |
| | | if (rd.SelectedIndex != 0) |
| | | return 0; |
| | | string txt = rd.Properties.Items[0].Description;// = "全自动【" + remainder.ToString() + "】"; |
| | | txt = txt.Trim().Replace("全自动【", ""); |
| | | txt = txt.Replace("】", ""); |
| | | if (string.IsNullOrEmpty(txt)) |
| | | return 0; |
| | | return decimal.Parse(txt); |
| | | } |
| | | |
| | | |
| | | #region 绘制表头全选勾选框 |
| | | /// <summary> |
| | | /// 绘制表头全选勾选框 |
| | | /// </summary> |
| | | // private Rectangle checkBoxColumnHeaderRect = Rectangle.Empty; |
| | | // private GridColumn checkBoxColumn = null; |
| | | public static void CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e) |
| | | { |
| | | |
| | | Rectangle checkBoxColumnHeaderRect = new Rectangle(51, 1, 37, 57); |
| | | if (e.Column != null && e.Column.AbsoluteIndex == 0) |
| | | { |
| | | //X = 51 Y = 1 Width = 37 Height = 57 |
| | | e.Column.Caption = "."; |
| | | checkBoxColumnHeaderRect = e.Bounds; |
| | | // checkBoxColumn = e.Column; |
| | | //须把列头标题设置为空 |
| | | e.Painter.DrawObject(e.Info); |
| | | //在列头中心显示复选框 |
| | | int x = e.Bounds.X + (int)((e.Bounds.Width - CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal).Width) * 0.5); |
| | | int y = e.Bounds.Y + (int)((e.Bounds.Height - CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal).Height) * 0.5); |
| | | Point location = new Point(x, y); |
| | | CheckBoxState checkBoxState; |
| | | if (e.Column.Tag != null && e.Column.Tag.ToString() == "1") |
| | | checkBoxState = CheckBoxState.CheckedPressed; |
| | | else |
| | | checkBoxState = CheckBoxState.UncheckedNormal; |
| | | CheckBoxRenderer.DrawCheckBox(e.Graphics, location, checkBoxState); |
| | | e.Handled = true; |
| | | } |
| | | } |
| | | |
| | | public static void CustomMouseUp(object sender, MouseEventArgs e, DevExpress.XtraGrid.GridControl gcMain, DevExpress.XtraGrid.Views.Grid.GridView gridView1) |
| | | { |
| | | GridColumn checkBoxColumn = gridView1.Columns[0]; |
| | | Rectangle checkBoxColumnHeaderRect = new Rectangle(51, 1, 37, 57); |
| | | if (checkBoxColumnHeaderRect != Rectangle.Empty) |
| | | { |
| | | if (e.X > checkBoxColumnHeaderRect.X && e.X < (checkBoxColumnHeaderRect.X + checkBoxColumnHeaderRect.Width) && e.Y > checkBoxColumnHeaderRect.Y && e.Y < (checkBoxColumnHeaderRect.Y + checkBoxColumnHeaderRect.Height)) |
| | | { |
| | | DataTable _Table = (DataTable)gcMain.DataSource; |
| | | if (checkBoxColumn.Tag != null && checkBoxColumn.Tag.ToString() == "1") |
| | | { |
| | | checkBoxColumn.Tag = "0"; |
| | | foreach (DataRow row in _Table.Rows) |
| | | { |
| | | row["chkInt"] = false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | checkBoxColumn.Tag = "1"; |
| | | foreach (DataRow row in _Table.Rows) |
| | | { |
| | | row["chkInt"] = true; |
| | | } |
| | | } |
| | | gcMain.BindingContext = new BindingContext(); |
| | | gcMain.DataSource = _Table; |
| | | gcMain.ForceInitialize(); |
| | | gridView1.CloseEditor(); |
| | | gridView1.PostEditor(); |
| | | gridView1.UpdateCurrentRow(); |
| | | gridView1.InvalidateColumnHeader(checkBoxColumn); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | |
| | | /// <summary> |