private void frmApoAct_Load(object sender, EventArgs e) { Ctrl.DbConStrFactory conFactory = Ctrl.DbConStrFactory.CreateInstance(); Ctrl.FileCtrl fileCtrl = Ctrl.FileCtrl.CreateInstance(conFactory.GetSqlConStr("defaultSqlDb"), conFactory.GetAccessConStr("defaultAccessDb")); List <Model.TableModel.Apo_act> list = fileCtrl.GetFileFlow(_fileNo); dgvApoAct.Rows.Clear(); int i = 0; if (list == null) { return; } if (list.Count <= 0) { return; } foreach (Model.TableModel.Apo_act item in list) { dgvApoAct.Rows.Add(); dgvApoAct.Rows[i].Cells["colApoActStep"].Value = item.act_step; dgvApoAct.Rows[i].Cells["colApoActUser"].Value = item.act_user_name; dgvApoAct.Rows[i].Cells["colApoActName"].Value = item.apo_item_name; dgvApoAct.Rows[i].Cells["colApoActTime"].Value = item.act_time; i++; } }
/// <summary> /// 私有方法,加载BOM型号 /// </summary> private void LoadPartTypeData() { Ctrl.DbConStrFactory conFactory = Ctrl.DbConStrFactory.CreateInstance(); Ctrl.FileCtrl fileCtrl = Ctrl.FileCtrl.CreateInstance(conFactory.GetSqlConStr("defaultSqlDb"), conFactory.GetAccessConStr("defaultAccessDb")); cmbType.DataSource = null; cmbType.DataSource = fileCtrl.LoadType(cmbWkc.SelectedValue.ToString()); }
/// <summary> /// 类的单例创建函数 /// </summary> /// <param name="sqlConStr">sqlServer连接字符串</param> /// <param name="accessConStr">access连接字符串</param> /// <returns>创建类的构造函数</returns> public static FileCtrl CreateInstance(string sqlConStr, string accessConStr) { // 当第一个线程运行到这里时,此时会对locker对象 "加锁", // 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁 // lock语句运行完之后(即线程运行完之后)会对该对象"解锁" // 双重锁定只需要一句判断就可以了 if (_fileCtrl == null) { lock (_locker) { // 如果类的实例不存在则创建,否则直接返回 if (_fileCtrl == null) { _fileCtrl = new FileCtrl(); } } } _fileCtrl.SqlConStr = sqlConStr; _fileCtrl.AccessConStr = accessConStr; return(_fileCtrl); }
private void LoadBom(object state) { Dictionary <string, string> pms = state as Dictionary <string, string>; Ctrl.DbConStrFactory conFactory = Ctrl.DbConStrFactory.CreateInstance(); Ctrl.FileCtrl fileCtrl = Ctrl.FileCtrl.CreateInstance(conFactory.GetSqlConStr("defaultSqlDb"), conFactory.GetSqlConStr("defaultAccessDb")); DataTable dt = fileCtrl.LoadBom(pms["condition"], pms["eqmNo"]); if (dgvBom.InvokeRequired == true) { dgvBom.Invoke(new Action <object>(LoadBom), state); } else { dgvBom.DataSource = null; dgvBom.DataSource = dt; for (int i = 0; i < dgvBom.Columns.Count; i++) { dgvBom.Columns[i].HeaderText = dt.Columns[i].Caption; } } }
/// <summary> /// 加载文件列表 /// </summary> private void LoadFile() { string fileTypeNo = GetFileTypeNo(); string eqmNo = GetCmbEqmValue(); Ctrl.DbConStrFactory conFactory = Ctrl.DbConStrFactory.CreateInstance(); Ctrl.FileCtrl fileCtrl = Ctrl.FileCtrl.CreateInstance(conFactory.GetSqlConStr("defaultSqlDb"), conFactory.GetAccessConStr("defaultAccessDb")); List <Model.TableModel.Dms_file> list = fileCtrl.LoadFile(eqmNo, fileTypeNo); dgvFileFlow.Rows.Clear(); int i = 0; foreach (Model.TableModel.Dms_file item in list) { dgvFileFlow.Rows.Add(); dgvFileFlow.Rows[i].Cells["colPeFileName"].Value = item.file_name + item.file_extension; string fileTime; string crtUser = fileCtrl.GetFileCreatorAndTime(item.file_no, out fileTime); dgvFileFlow.Rows[i].Cells["colPeFileDateTime"].Value = fileTime; dgvFileFlow.Rows[i].Cells["colPeFileCreater"].Value = crtUser; dgvFileFlow.Rows[i].Tag = item.file_no; i++; } }