using Lskj.Business.Impl; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Timers; using System.Windows.Forms; namespace Lskj.Control { public partial class FrmProgressBar : BaseForm { public ProgressBar progressBar { get { return this.progressBarTotal; }} public System.Timers.Timer ProgressBarTimer = new System.Timers.Timer(); public System.Timers.Timer SqlTimer = new System.Timers.Timer(); public int result ; public string SqlValue; public SqlParameter[] Parameters; public FrmProgressBar() { InitializeComponent(); this.progressBarTotal.Value = 0; this.ProgressBarTimer.Interval = 200; this.ProgressBarTimer.Elapsed += new System.Timers.ElapsedEventHandler(ProgressBarTimerTick); System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; this.ProgressBarTimer.Start(); } public FrmProgressBar(string sqlValue, SqlParameter[] parameters) { InitializeComponent(); this.ProgressBarTimer.Interval = 200; this.ProgressBarTimer.Elapsed += new System.Timers.ElapsedEventHandler(ProgressBarTimerTick); this.SqlTimer.Interval = 100; this.SqlTimer.Elapsed += new System.Timers.ElapsedEventHandler(SqlTimerTimerTick); System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; SqlValue = sqlValue; Parameters = parameters; this.SqlTimer.Start(); } //public int save(string masterSql, string detailSql, string detailTable, ref string billNo, string detailGuid, string billSeq, int billWay, int comfirm, out string tipMsg, int auditFlag = 0, int newVer = 0) //{ // InitializeComponent(); // this.ProgressBarTimer.Interval = 200; // this.ProgressBarTimer.Elapsed += new System.Timers.ElapsedEventHandler(ProgressBarTimerTick); // int result = BillImpl.BillSave(masterSql, detailSql, BillModel.DetailTable, ref billNo, detailGuid, BillModel.BillSeq, BillModel.SaveState ? 2 : 1, comfirm, out tipMsg, 0, this.BillModel.NewVer); // return result; //} private void SqlTimerTimerTick(object sender, ElapsedEventArgs e) { this.SqlTimer.Stop(); ShowForm(SqlValue, Parameters); } /// /// 显示 /// public void ShowForm(string sqlValue, SqlParameter[] parameters) { this.progressBarTotal.Value = 0; this.ProgressBarTimer.Start(); //执行sql result = MainImpl.ExecProcedure(sqlValue, parameters.ToArray());; complete(); this.Close(); } /// /// 自动增长进度条的进度 /// /// /// private void ProgressBarTimerTick(object sender, EventArgs e) { int value = this.progressBarTotal.Value+1; if (value <= 99) { this.progressBarTotal.Value = value; } else { this.ProgressBarTimer.Stop(); } } /// /// 进度完成 /// public void complete() { this.progressBarTotal.Value = 100; this.ProgressBarTimer.Stop(); } } }