/// <summary> /// 查看Excel文件并显示在界面上操作 /// </summary> private void ViewData() { if (this.txtFilePath.Text == "") { MessageDxUtil.ShowTips("请选择指定的Excel文件"); return; } try { myDs.Tables.Clear(); myDs.Clear(); this.gridControl1.DataSource = null; string error = ""; AsposeExcelTools.ExcelFileToDataSet(this.txtFilePath.Text, out myDs, out error); this.gridControl1.DataSource = myDs.Tables[0]; this.gridView1.PopulateColumns(); } catch (Exception ex) { LogTextHelper.Error(ex); MessageDxUtil.ShowError(ex.Message); } }
private void btnSaveData_Click(object sender, EventArgs e) { if (worker.IsBusy) { return; } if (this.txtFilePath.Text == "") { MessageDxUtil.ShowTips("请选择指定的Excel文件"); return; } if (MessageDxUtil.ShowYesNoAndWarning("该操作将把数据导入到系统数据库中,您确定是否继续?") == DialogResult.Yes) { if (myDs != null && myDs.Tables[0].Rows.Count > 0) { DataTable dt = myDs.Tables[0]; this.progressBar1.Visible = true; //创建所需的事务对象 if (OnCreateTransaction != null) { transaction = OnCreateTransaction(); } worker.RunWorkerAsync(); } } }
/// <summary> /// 绑定图片的操作,触发绑定事件处理 /// </summary> /// <param name="id">记录ID</param> public void BindPicture(string id) { try { this.ID = id; //设置控件的ID值 #region 更新图片显示操作 if (OnBindPortait == null) { MessageDxUtil.ShowTips("控件未指定OnBindPortait事件处理"); return; } byte[] imageBytes = OnBindPortait(id, ImageType); if (imageBytes != null) { this.picPortrait.Image = ImageHelper.ImageFromBytes(imageBytes); } else { ResetDefaultImage(ImageType); } #endregion //this.lblPictureTips.Text = "全部图片更新成功!"; } catch (Exception ex) { MessageDxUtil.ShowError(ex.Message); LogTextHelper.Error(ex); } }
/// <summary> /// 校验输入控件是否为空,为空则提示对话框 /// </summary> /// <param name="baseEdit">输入控件</param> /// <returns></returns> public static bool ValidateEditNull(this BaseEdit baseEdit) { bool result; if (string.IsNullOrEmpty(baseEdit.Text)) { MessageDxUtil.ShowTips("{0}不能为空", baseEdit.Tag); baseEdit.Focus(); result = true; } else { result = false; } return(result); }
private void lnkExcel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { string templateFile = this.lnkExcel.Tag.ToString(); if (string.IsNullOrEmpty(templateFile)) { MessageDxUtil.ShowTips("导入操作未指定模板文件"); return; } Process.Start(templateFile); } catch (Exception) { MessageDxUtil.ShowWarning("文件打开失败"); } }
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { this.progressBar1.Visible = false; this.progressBar1.Value = 0; if (OnRefreshData != null) { OnRefreshData(null, null); } string tips = e.Result as string; if (!string.IsNullOrEmpty(tips)) { MessageDxUtil.ShowTips(tips); if (tips == "操作成功") { this.gridControl1.DataSource = null; } } }
private void btnPrint_Click(object sender, EventArgs e) { if (this.txtPrinter.Text.Length == 0) { MessageDxUtil.ShowTips("请选择或输入打印机名称"); this.txtPrinter.Focus(); return; } //保存配置并返回 try { config.AppConfigSet(SaveConfigName, this.txtPrinter.Text); this.DefaultPrinterName = this.txtPrinter.Text; this.DialogResult = System.Windows.Forms.DialogResult.OK; } catch (Exception ex) { MessageDxUtil.ShowTips(ex.Message); } }
/// <summary> /// 保存操作的统一入口 /// </summary> /// <param name="close">关闭窗体</param> public virtual void SaveEntity(bool close) { // 检查输入的有效性 if (this.CheckInput()) { // 设置鼠标繁忙状态 this.Cursor = Cursors.WaitCursor; try { if (this.SaveEntity()) { ProcessDataSaved(this.btnOK, new EventArgs()); MessageDxUtil.ShowTips("保存成功"); if (close) { this.DialogResult = DialogResult.OK; this.Close(); } else { this.ClearScreen(); } } } catch (Exception ex) { this.ProcessException(ex); } finally { // 设置鼠标默认状态 this.Cursor = Cursors.Default; } } }
/// <summary> /// 保存图片到服务器 /// </summary> public bool SavePicture(string id) { this.ID = id;//设置控件的ID值 if (string.IsNullOrEmpty(id)) { MessageDxUtil.ShowTips("记录ID未指定,无法保存,请先保存数据!"); return(false); } if (OnSavePortrait == null) { MessageDxUtil.ShowTips("控件未指定OnSavePortrait处理事件!"); return(false); } if (picPortrait.Image != null) { try { byte[] imageBytes = ImageHelper.ImageToBytes(this.picPortrait.Image); bool sucess = false; if (OnSavePortrait != null) { sucess = OnSavePortrait(this.ID, imageBytes, ImageType); } return(sucess); } catch (Exception ex) { MessageDxUtil.ShowError(ex.Message); LogTextHelper.Error(ex); } } return(false); }
private void btnSave_Click(object sender, EventArgs e) { bool sucess = SavePicture(this.ID); MessageDxUtil.ShowTips(sucess ? "图片保存成功!" : "保存失败!"); }