| | |
| | | using DevExpress.DataAccess.Wizard.Model; |
| | | using DevExpress.XtraGrid.Views.Grid; |
| | | using DevExpress.XtraGrid.Views.Grid.ViewInfo; |
| | | using DevExpress.XtraLayout.Customization; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.ToolBox; |
| | | using Gs.DevApp.UserControl; |
| | |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.IO; |
| | | using System.Net.Http; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Controls; |
| | | using System.Net; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace Gs.DevApp.DevFrm |
| | |
| | | toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick; |
| | | toolBarMenu1.btnJianYanClick += ToolBarMenu1_btnJianYanClick; |
| | | gcMain.MouseDoubleClick += GcMain_MouseDoubleClick; |
| | | gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged; |
| | | gcMx1.MouseClick += GcMx1_MouseClick; |
| | | getPageList(1, UtilityHelper.GetPageSize()); |
| | | pageBar1.PagerEvent += PageBar1_PagerEvent; |
| | | gridView1.CustomDrawRowIndicator += (s, e) => |
| | |
| | | Rectangle r = new Rectangle(gridView1.GridControl.Width / 2 - 100, e.Bounds.Top + 45, e.Bounds.Right - 5, e.Bounds.Height - 5); |
| | | e.Graphics.DrawString(str, f, Brushes.Gray, r); |
| | | }; |
| | | //上传附件 |
| | | btnUpSelect.Click += BtnUpSelect_Click; |
| | | btnUp.Click += BtnUp_Click; |
| | | //初始化物料选择和各种下拉 |
| | | gvMx2.OptionsFind.ShowSearchNavButtons = false; |
| | | gvMx2.OptionsView.ShowGroupPanel = false; |
| | | _setIno(); |
| | | gvMx3.OptionsFind.ShowSearchNavButtons = false; |
| | | gvMx3.OptionsView.ShowGroupPanel = false; |
| | | txt_itemId.KeyFile = "id"; |
| | | txt_suppId.KeyFile = "id"; |
| | | txt_itemId.EditChanged += (s, e) => |
| | | { |
| | | txt_itemModel.Text = this.txt_itemId.GetModel(); |
| | | txt_itemNo.Text = this.txt_itemId.GetCode(); |
| | | }; |
| | | txtJianYan.KeyDown += TxtJianYan_KeyDown; |
| | | this.btnLoad.Click += BtnLoad_Click; |
| | | ucUpFile1.UpChanged += UcUpFile1_UpChanged; |
| | | xtraTabControl2.SelectedPageChanged += XtraTabControl2_SelectedPageChanged; |
| | | } |
| | | |
| | | private void GcMx1_MouseClick(object sender, MouseEventArgs e) |
| | | { |
| | | string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gvMx1, e, "guid"); |
| | | if (string.IsNullOrEmpty(rowGuid)) |
| | | return; |
| | | getList12(rowGuid); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 重新加载检验 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void BtnLoad_Click(object sender, EventArgs e) |
| | | { |
| | | if (!MsgHelper.AskQuestion("确定重新加载检验项目吗?")) |
| | | if (!MsgHelper.AskQuestion("确定重新加载检验项目吗,该操作将会清空之前的检验记录?")) |
| | | return; |
| | | string strGuid = lbGuid.Text.Trim(); |
| | | if (string.IsNullOrEmpty(strGuid)) |
| | |
| | | } |
| | | var _obj = new |
| | | { |
| | | guid = strGuid,//主建 |
| | | guid = strGuid, |
| | | }; |
| | | try |
| | | { |
| | | string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetCheckResultList15Reload", JsonConvert.SerializeObject(_obj)); |
| | | string strJson = UtilityHelper.HttpPost("", _webServiceName + "ReloadModel5", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowInformation(_rtn.rtnMsg); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | dynamic dy = _rtn.rtnData; |
| | |
| | | gcMx1.BindingContext = new BindingContext(); |
| | | gcMx1.DataSource = dt; |
| | | gcMx1.ForceInitialize(); |
| | | getList12(dt.Rows[0]["guid"].ToString()); |
| | | } |
| | | else |
| | | { |
| | | Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1); |
| | | } |
| | | } |
| | | else |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 输入检验事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void TxtJianYan_KeyDown(object sender, KeyEventArgs e) |
| | | { |
| | | int intHandle = this.gvMx1.FocusedRowHandle; |
| | | if (intHandle < 0) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:请选择检验项目!"); |
| | | return; |
| | | } |
| | | if (e.KeyCode == Keys.Enter) |
| | | { |
| | | string guid5 = this.gvMx1.GetDataRow(intHandle)["guid"].ToString(); |
| | | string _strCmd = txtJianYan.Text.Trim().ToUpper(); |
| | | string _strOK = "OK"; |
| | | string _strNG = "NG"; |
| | | if (!(_strCmd.StartsWith(_strOK) || _strCmd.StartsWith(_strNG))) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError("命令输入错误:请正确使用OK 或 NG 命令!"); |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError("命令输入错误:请正确使用OK 或 NG 命令!"); |
| | | return; |
| | | } |
| | | if (!_strCmd.Contains("-")) |
| | |
| | | int n; |
| | | if (int.TryParse(_str2, out n)) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | if (row != null) |
| | | lst.Add(new MesQaItemsDetectDetail12() |
| | | { |
| | | ParentGuid= UtilityHelper.ToGuid(labCurrentGuid.Text.Trim()), |
| | | ParentGuid = UtilityHelper.ToGuid(guid5), |
| | | Guid = UtilityHelper.ToGuid(row["guid"].ToString()), |
| | | FcheckResu = row["fcheckResu"].ToString(), |
| | | //Fstand = row["fstand"].ToString(), |
| | | FcheckItem = labCurrentItem.Text.Trim(), |
| | | GrandpaGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), |
| | | }); |
| | | } |
| | |
| | | try |
| | | { |
| | | var strJson = UtilityHelper.HttpPost("", |
| | | _webServiceName + "EdtModelDetail12", |
| | | _webServiceName + "EdtModel12", |
| | | JsonConvert.SerializeObject(_obj)); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | _filterList = e.FilterList; |
| | | getPageList(1, pageBar1.RowsCount); |
| | | } |
| | | /// <summary> |
| | | /// 日志事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnLogClick(object sender, EventArgs e) |
| | | { |
| | | toolBarMenu1.guidKey = ""; |
| | |
| | | toolBarMenu1.guidKey = rowGuid; |
| | | } |
| | | /// <summary> |
| | | /// 检验 |
| | | ///检验事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) |
| | | { |
| | | UtilityHelper.JumpToTab(xtraTabControl1, 0); |
| | | getPageList(1, UtilityHelper.GetPageSize()); |
| | | if (xtraTabControl1.SelectedTabPageIndex == 1) |
| | | getModel(lbGuid.Text.Trim(), false, 999); |
| | | else |
| | | getPageList(1, UtilityHelper.GetPageSize()); |
| | | } |
| | | /// <summary> |
| | | /// 修改事件 |
| | |
| | | private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e) |
| | | { |
| | | toolBarMenu1.isSetBtn = false; |
| | | //if (string.IsNullOrEmpty(txt_account.Text.Trim())) |
| | | if (string.IsNullOrEmpty(txt_fngDesc.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("登录账号不能为空!"); |
| | | // txt_account.Focus(); |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("不良描述不能为空!"); |
| | | txt_fngDesc.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txt_lotNo1.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("备注能为空!"); |
| | | txt_fngDesc.Focus(); |
| | | return; |
| | | } |
| | | var _obj = new |
| | | { |
| | | guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建 |
| | | fngDesc = txt_fngDesc.Text.Trim(), |
| | | lotNo1 = txt_lotNo1.Text.Trim(), |
| | | }; |
| | | try |
| | | { |
| | |
| | | } |
| | | _loading.Stop(); |
| | | } |
| | | private void getModel(string strGuid, bool isEdit, int tabIdx) |
| | | private async void getModel(string strGuid, bool isEdit, int tabIdx) |
| | | { |
| | | if (string.IsNullOrEmpty(strGuid)) |
| | | { |
| | |
| | | return; |
| | | } |
| | | UtilityHelper.JumpToTab(xtraTabControl1, tabIdx); |
| | | UcLoading _loading = new UcLoading(); |
| | | var _obj = new |
| | | { |
| | | guid = strGuid,//主建 |
| | | }; |
| | | try |
| | | { |
| | | string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); |
| | | string strJson = await UtilityHelper.HttpPostAsync("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | |
| | | gcMx1.BindingContext = new BindingContext(); |
| | | gcMx1.DataSource = dt; |
| | | gcMx1.ForceInitialize(); |
| | | ucUpFile1.parentGuid = lbGuid.Text.Trim(); |
| | | getList12(dt.Rows[0]["guid"].ToString()); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | |
| | | _loading.Stop(); |
| | | } |
| | | |
| | | |
| | | |
| | | #region 文件上传 |
| | | |
| | | /// <summary> |
| | | /// 选择上传文件 |
| | | /// 选项卡切换 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void BtnUpSelect_Click(object sender, EventArgs e) |
| | | private void XtraTabControl2_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e) |
| | | { |
| | | var openFileDialog = new OpenFileDialog(); |
| | | // 设置初始目录 |
| | | openFileDialog.InitialDirectory = "c:\\"; |
| | | // 设置文件过滤选项,如:"文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*" |
| | | openFileDialog.Filter = "文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*"; |
| | | // 设置标题 |
| | | openFileDialog.Title = "选择文件"; |
| | | // 显示对话框 |
| | | var result = openFileDialog.ShowDialog(); |
| | | // 确认用户没有取消操作 |
| | | if (result == DialogResult.OK) |
| | | if (e.Page.Name == "xtraTabPage3") |
| | | { |
| | | // 获取选中的文件路径 |
| | | var filePath = openFileDialog.FileName; |
| | | Console.WriteLine($"选中的文件: {filePath}"); |
| | | txtUpUrl.Text = filePath; |
| | | getFileList(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 确定上传 |
| | | /// 上传后刷新文件列表 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private async void BtnUp_Click(object sender, EventArgs e) |
| | | private void UcUpFile1_UpChanged(object sender, EventArgs e) |
| | | { |
| | | var WebApiUrl = ConfigurationSettings.AppSettings.Get("WebApiUrl"); |
| | | var address = WebApiUrl + "Upload/UploadFile"; |
| | | var filePath = txtUpUrl.Text.Trim(); |
| | | var apiUrl = address; // 替换为你的API地址 |
| | | await UploadFileAsync(apiUrl, filePath); |
| | | getFileList(); |
| | | } |
| | | |
| | | private async Task UploadFileAsync(string url, string filePath) |
| | | private void getFileList() |
| | | { |
| | | UcLoading _loading = new UcLoading(); |
| | | using (var httpClient = new HttpClient()) |
| | | using (var form = new MultipartFormDataContent()) |
| | | System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder(); |
| | | _sbSqlWhere.Append(" and parent_Guid='" + lbGuid.Text.Trim() + "'"); |
| | | PageQueryModel pgq = new PageQueryModel(1, 100, "create_date", "asc", "", _sbSqlWhere.ToString()); |
| | | string json = JsonConvert.SerializeObject(pgq); |
| | | try |
| | | { |
| | | httpClient.DefaultRequestHeaders.Add("token", |
| | | UtilityHelper.GetBasicAuthTicket()); |
| | | using (var fs = File.OpenRead(filePath)) |
| | | using (var streamContent = new StreamContent(fs)) |
| | | string strReturn = UtilityHelper.HttpPost("", "MesFile/GetListPage", json); |
| | | ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn); |
| | | if (dd.rtnCode > 0) |
| | | { |
| | | form.Add(streamContent, "file", Path.GetFileName(filePath)); |
| | | var response = await httpClient.PostAsync(url, form); |
| | | var responseString = |
| | | await response.Content.ReadAsStringAsync(); |
| | | MessageBox.Show(responseString); |
| | | DataTable dt = dd.rtnData.list; |
| | | gcMx3.BindingContext = new BindingContext(); |
| | | gcMx3.DataSource = dt; |
| | | gcMx3.ForceInitialize(); |
| | | } |
| | | else |
| | | { |
| | | ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg); |
| | | } |
| | | } |
| | | _loading.Close(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | private void _setIno() |
| | | { |
| | | txt_itemId.KeyFile = "id"; |
| | | txt_itemId.EditChanged += (s, e) => |
| | | catch (Exception ex) |
| | | { |
| | | txt_itemModel.Text = this.txt_itemId.GetModel(); |
| | | txt_itemNo.Text = this.txt_itemId.GetCode(); |
| | | }; |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 读取检验结果 |
| | | /// 根据检验项目读取抽样结果 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void GvMx1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) |
| | | /// <param name="guid5"></param> |
| | | private async void getList12(string guid5) |
| | | { |
| | | var myDataRow = gvMx1.GetDataRow(e.FocusedRowHandle); |
| | | if (myDataRow == null) return; |
| | | labCurrentItem.Text = myDataRow["fcheckItem"].ToString(); |
| | | labCurrentGuid.Text = myDataRow["guid"].ToString(); |
| | | UcLoading _loading = new UcLoading(); |
| | | var _obj = new |
| | | { |
| | | parentGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建 |
| | | guid = UtilityHelper.ToGuid(myDataRow["guid"].ToString()), //主建 |
| | | //id = myDataRow["id"].ToString(), |
| | | id = -1, |
| | | checkQyt = myDataRow["checkQyt"].ToString(), |
| | | chkItem = myDataRow["fcheckItem"].ToString() |
| | | guid = UtilityHelper.ToGuid(guid5), //主建 |
| | | }; |
| | | try |
| | | { |
| | | var strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetCheckResultList12", JsonConvert.SerializeObject(_obj)); |
| | | var strReturn = await UtilityHelper.HttpPostAsync("", _webServiceName + "GetModel12", JsonConvert.SerializeObject(_obj)); |
| | | var dd = UtilityHelper.ReturnToList(strReturn); |
| | | var dt = dd.rtnData; |
| | | gcMx2.BindingContext = new BindingContext(); |
| | |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | _loading.Stop(); |
| | | } |
| | | |
| | | private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) |
| | | { |
| | | var rowhandle = gvMx3.FocusedRowHandle; |
| | | if (rowhandle < 0) |
| | | return; |
| | | if (e.Button.Index == 0) |
| | | { |
| | | var dr = gvMx3.GetDataRow(rowhandle); |
| | | var mxGuid = dr["guid"].ToString(); |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?")) |
| | | return; |
| | | var strJson = ""; |
| | | var lst = new List<string>(); |
| | | lst.Add(mxGuid); |
| | | try |
| | | { |
| | | strJson = UtilityHelper.HttpPost("", "MesFile/DeleteModel", |
| | | JsonConvert.SerializeObject(lst)); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) gvMx3.DeleteRow(rowhandle); |
| | | MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void repositoryItemButtonEdit2_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) |
| | | { |
| | | var rowhandle = gvMx3.FocusedRowHandle; |
| | | if (rowhandle < 0) |
| | | return; |
| | | if (e.Button.Index == 0) |
| | | { |
| | | try |
| | | { |
| | | var dr = gvMx3.GetDataRow(rowhandle); |
| | | var urlPath = dr["urlPath"].ToString(); |
| | | Gs.DevApp.UserControl.ShowFile frm = new ShowFile(urlPath); |
| | | frm.ShowDialog(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | private void repositoryItemButtonEdit3_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) |
| | | { |
| | | var rowhandle = gvMx3.FocusedRowHandle; |
| | | if (rowhandle < 0) |
| | | return; |
| | | if (e.Button.Index == 0) |
| | | { |
| | | try |
| | | { |
| | | var dr = gvMx3.GetDataRow(rowhandle); |
| | | var urlPath = dr["urlPath"].ToString(); |
| | | using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) |
| | | { |
| | | folderBrowserDialog.Description = "选择导出文件的保存路径"; |
| | | DialogResult dialogResult = folderBrowserDialog.ShowDialog(); |
| | | if (dialogResult == DialogResult.OK) |
| | | { |
| | | string _folder = folderBrowserDialog.SelectedPath; |
| | | string _folderName = _folder + "\\" + urlPath; |
| | | string _url = ConfigurationManager.AppSettings["WebApiUrl"].ToString() + "upload/" + urlPath; |
| | | using (WebClient client = new WebClient()) |
| | | { |
| | | client.DownloadFile(_url, _folderName); |
| | | } |
| | | ToolBox.MsgHelper.ShowInformation("下载成功!"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |