/// <summary> /// 获取数据库操作接口 /// </summary> /// <returns>返回是否成功获取数据库操作接口</returns> public static IDBOperate GetDBOperatorOfDepotManagement() { m_dbOperatorOfDepotManagement = DBFactory.Init(DBFactory.DBType.SQL, GlobalObject.GlobalParameter.StorehouseConnectionString, DatabaseNameOfDepotManagement); return(m_dbOperatorOfDepotManagement); }
/// <summary> /// 检测是否能进行试验 /// </summary> /// <param name="productCode">箱号</param> /// <param name="error">出错时返回错误信息</param> /// <returns>允许试验返回true</returns> public bool CanOffLineTest(string productCode, out string error) { error = null; Hashtable paramTable = new Hashtable(); DataSet ds = new DataSet(); paramTable.Add("@ProductNumber", productCode); IDBOperate dbOperate = CommentParameter.GetDBOperatorOfDepotManagement(); Dictionary <OperateCMD, object> dicOperateCMD = dbOperate.RunProc_CMD("ZPX_AllowOffLineTest", ds, paramTable); DataTable dataTable = ds.Tables[0]; if (dataTable.Rows[0][0].ToString() == "允许") { return(true); } error = dataTable.Rows[0][0].ToString(); if (dataTable.Columns.Count == 1) { return(false); } return(false); }
public static IDBOperate InitDBOperate(string connType) { switch (connType) { case "GineCore.Entity": dbOperate = new DBOperateMySql(userConnect); break; } return(dbOperate); }
/// <summary> /// 检测是否能进行试验 /// </summary> /// <param name="productCode">箱号</param> /// <param name="error">出错时返回错误信息</param> /// <returns>允许试验返回true</returns> public bool CanOffLineTest(string productCode, out string error) { error = null; Hashtable paramTable = new Hashtable(); DataSet ds = new DataSet(); paramTable.Add("@ProductNumber", productCode); IDBOperate dbOperate = CommentParameter.GetDBOperatorOfDepotManagement(); Dictionary <OperateCMD, object> dicOperateCMD = dbOperate.RunProc_CMD("ZPX_AllowOffLineTest", ds, paramTable); DataTable dataTable = ds.Tables[0]; if (dataTable.Rows[0][0].ToString() == "允许") { return(true); } error = dataTable.Rows[0][0].ToString(); if (dataTable.Columns.Count == 1) { return(false); } DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.ZPX_CVTOffLineTestResultLog where a.ProdutCode == productCode select a; if (varData.Count() == 0) { ZPX_CVTOffLineTestResultLog lnqLog = new ZPX_CVTOffLineTestResultLog(); lnqLog.ProdutCode = productCode; lnqLog.Z08FinishTime = Convert.ToDateTime(dataTable.Rows[0][1]); ctx.ZPX_CVTOffLineTestResultLog.InsertOnSubmit(lnqLog); } else if (varData.Count() == 1) { ZPX_CVTOffLineTestResultLog lnqLog = varData.Single(); lnqLog.Z08FinishTime = Convert.ToDateTime(dataTable.Rows[0][1]); } ctx.SubmitChanges(); return(false); }
public IDBOperate GetDbOperate() { IDBOperate iDBOperate = null; switch (m_config.OperatorType) { case DBOperatorType.EsriOperator: switch (m_config.ConnectType) { case DBType.ESRIGDB: break; case DBType.ESRIPDB: break; case DBType.ESRISDEOracle: break; case DBType.ESRISDESqlServer: break; } break; case DBOperatorType.ODBC: switch (m_config.ConnectType) { case DBType.ODBCMDB: iDBOperate = new MDBOperate(m_config); break; case DBType.ODBCORACLE: break; case DBType.ODBCPOST: break; case DBType.ODBCSQL: iDBOperate = new SQLServerOperate(m_config); break; } break; } return(iDBOperate); }
private void buttonXOK_Click(object sender, EventArgs e) { switch (m_DBoType) { case DBOperatorType.EsriOperator: dicDbconfig["server"] = txtEsriServer.Text; dicDbconfig["serverice"] = txtService.Text; dicDbconfig["database"] = txtEsriDb.Text; dicDbconfig["user"] = txtEsriUser.Text; dicDbconfig["password"] = txtEsriPassword.Text; break; case DBOperatorType.ODBC: dicDbconfig["server"] = txtODBCServer.Text; dicDbconfig["database"] = txtODBCDb.Text; dicDbconfig["user"] = txtODBCUser.Text; dicDbconfig["password"] = txtODBCPassword.Text; dicDbconfig["serverport"] = txtODBCPort.Text; break; } m_dbConfig.SetConfig(m_DBoType, m_dbType, dicDbconfig); DBOperatorFactory pFac = new DBOperatorFactory(m_dbConfig); m_DbOp = pFac.GetDbOperate(); if (m_DbOp != null) { if (!m_DbOp.TestConnect()) { MessageBox.Show("无法连接数据库,请检查设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { m_dbConfig.SaveConfig(Fan.Common.ModuleConfig.m_ConnectFileName); this.DialogResult = DialogResult.OK; } } else { MessageBox.Show("无法连接数据库,请检查设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void Check_LeaveType(string typeCode, decimal hours, int?billID) { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; IDBOperate m_dbOperate = CommentParameter.GetDBOperatorOfDepotManagement(); HR_LeaveType leaveType = GetLeaveType(ctx, typeCode); Hashtable paramTable = new Hashtable(); paramTable.Add("@TypeCode", leaveType.TypeCode); paramTable.Add("@Hours", hours); paramTable.Add("@WorkID", BasicInfo.LoginID); paramTable.Add("@BillID", billID == null ? 0 : billID); Dictionary <OperateCMD, object> dicOperateCMD = m_dbOperate.RunProc_CMD("HR_LeaveBill_Type_Check", paramTable); if (!Convert.ToBoolean(dicOperateCMD[OperateCMD.Return_OperateResult])) { throw new Exception(Convert.ToString(dicOperateCMD[OperateCMD.Return_Errmsg])); } }
/// <summary> /// 台帐 /// </summary> /// <param name="productName">查询方式</param> /// <param name="startDate">开始时间</param> /// <param name="endDate">结束时间</param> /// <param name="storageID">库房ID</param> /// <param name="showTable">返回table数据集</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool GetAllGather(string productName, DateTime startDate, DateTime endDate, string storageID, out DataTable showTable, out string error) { IDBOperate dbOperate = CommentParameter.GetDBOperatorOfDepotManagement(); error = null; showTable = null; try { Hashtable paramTable = new Hashtable(); if (productName == "pro_B_GoodsListGather") { paramTable.Add("@StartDate", startDate); paramTable.Add("@EndDate", endDate); } DataSet ds = new DataSet(); Dictionary <OperateCMD, object> dicOperateCMD = dbOperate.RunProc_CMD(productName, ds, paramTable); if (!Convert.ToBoolean(dicOperateCMD[OperateCMD.Return_OperateResult])) { error = Convert.ToString(dicOperateCMD[OperateCMD.Return_Errmsg]); return(false); } showTable = ds.Tables[0]; return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 角色类 /// </summary> /// <param name="strRoleID"></param> /// <param name="iDbOperate"></param> public Role(string strRoleID, IDBOperate iDbOperate) { m_RoleID = strRoleID; m_DbOperate = iDbOperate; }
/// <summary> /// 用户操作 /// </summary> /// <param name="iDBOperate"></param> public User(IDBOperate iDBOperate) { m_dbOperate = iDBOperate; }
public SysFunction(string strFID, IDBOperate dBOperate) { }
/// <summary> /// 保存CVT下线试验数据 /// </summary> /// <param name="testInfo">CVT下线试验信息</param> /// <returns>返回操作是否成功的标志</returns> public bool SaveCVTExpData(CvtTestInfo testInfo) { if (testInfo == null) { throw new ArgumentException("试验数据参数不允许为空"); } if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.CvtNumber)) { throw new Exception("CVT编号不允许为空"); } string[] cvtNumber = testInfo.CvtNumber.Split(new char[] { ' ' }); if (cvtNumber.Length != 2) { throw new Exception("CVT编号格式不正确"); } if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.OilType)) { throw new Exception("油品类型不允许为空"); } if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.TestDevice)) { throw new Exception("试验设备名称不允许为空"); } if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.TestResult)) { throw new Exception("试验结果不允许为空"); } if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.Tester)) { throw new Exception("实验员不允许为空"); } if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.PreassemblyPersonnel)) { throw new Exception("预装员不允许为空"); } if (testInfo.TestData == null || testInfo.TestData.Rows.Count == 0) { throw new Exception("试验项目表不允许为空"); } string error = null; Hashtable paramTable = new Hashtable(); paramTable.Add("@ProductType", cvtNumber[0]); paramTable.Add("@CvtNumber", cvtNumber[1]); paramTable.Add("@TestDevice", testInfo.TestDevice); paramTable.Add("@OilType", testInfo.OilType); paramTable.Add("@TestResult", testInfo.TestResult); paramTable.Add("@Tester", testInfo.Tester); paramTable.Add("@PreassemblyPersonnel", testInfo.PreassemblyPersonnel); paramTable.Add("@Remark", testInfo.Remark); IDBOperate dbOperate = AccessDB.GetIDBOperate("DepotManagement"); string[] lstCmd = new string[testInfo.TestData.Rows.Count + 1]; Hashtable[] lstParam = new Hashtable[testInfo.TestData.Rows.Count + 1]; Hashtable[] outParams = new Hashtable[testInfo.TestData.Rows.Count + 1]; lstCmd[0] = "ZPX_InsertCVTTestInfo"; lstParam[0] = paramTable; for (int i = 0; i < testInfo.TestData.Rows.Count; i++) { lstCmd[i + 1] = "ZPX_InsertCVTTestDataItems"; paramTable = new Hashtable(); paramTable.Add("@TestType", testInfo.TestData.Rows[i]["TestType"].ToString()); paramTable.Add("@TestItemName", testInfo.TestData.Rows[i]["TestItemName"].ToString()); paramTable.Add("@TestCondition", testInfo.TestData.Rows[i]["TestCondition"].ToString()); paramTable.Add("@TestRequirement", testInfo.TestData.Rows[i]["TestRequirement"].ToString()); paramTable.Add("@TestData", testInfo.TestData.Rows[i]["TestData"].ToString()); paramTable.Add("@TestResult", testInfo.TestData.Rows[i]["TestResult"].ToString()); lstParam[i + 1] = paramTable; } Dictionary <OperateCMD, object> dicOperateCMD = dbOperate.Transaction_CMD(lstCmd, lstParam, ref outParams); if (!AccessDB.GetResult(dicOperateCMD, out error)) { throw new Exception(error); } else { return(true); } }
public SysConfig(IDBOperate dBOperate) { m_Dboperate = dBOperate; InitializeConfig(); }
/// <summary> /// 用户读取 /// </summary> /// <param name="usercodeStr"></param> /// <param name="userPasswordStr"></param> /// <param name="iDBOperate"></param> public User(string usercodeStr, string userPasswordStr, IDBOperate iDBOperate) { m_UserCode = usercodeStr; m_UserPassword = userPasswordStr; m_dbOperate = iDBOperate; }
/// <summary> /// 获取数据库操作接口 /// </summary> /// <returns>返回是否成功获取数据库操作接口</returns> public static IDBOperate GetDBOperate() { m_dboperate = DBFactory.Init(DBFactory.DBType.SQL, GlobalObject.GlobalParameter.WebServerConnectionString, DatabaseName); return(m_dboperate); }
/// <summary> /// 设置当前使用的数据库操作接口 /// </summary> /// <param name="dbName">数据库名称</param> /// <returns>成功则返回true,失败返回false</returns> public static bool SetDBOperate(string dbName) { m_dboperate = DBFactory.Init(DBFactory.DBType.SQL, GetDBConnString(dbName), dbName); return(m_dboperate == null); }
/// <summary> /// 获取由属性指定的数据库的操作接口 /// </summary> /// <returns>成功则返回获取到的操作操作,失败返回null</returns> public static IDBOperate GetIDBOperate() { m_dboperate = DBFactory.Init(DBFactory.DBType.SQL, GetDBConnString(m_databaseName), DatabaseName); return(m_dboperate); }
/// <summary> /// 获取数据库操作接口 /// </summary> /// <param name="dbName">数据库名称</param> /// <returns>成功则返回获取到的操作操作,失败返回null</returns> public static IDBOperate GetIDBOperate(string dbName) { IDBOperate dboperate = DBFactory.Init(DBFactory.DBType.SQL, GetDBConnString(dbName), dbName); return(dboperate); }