| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- using System;
- using System.Data;
- using System.Collections;
- using Core.Mes.ServerFrameWork;
- using Core.Mes.IBaseInterface;
- namespace Core.XgMes.Server.JGKC.SteelPlateManager
- {
- public class Common : Core.Mes.ServerFrameWork.IComponent
- {
- public Common()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- public override int maxValue
- {
- get
- {
- return 100;
- }
- }
- public override int minValue
- {
- get
- {
- return 50;
- }
- }
- public static string CheckNullStr(object obj)
- {
- if (obj == null || obj.GetType() == typeof(System.DBNull))
- {
- return "";
- }
- else
- {
- return Convert.ToString(obj);
- }
- }
- public static object[] FixValues(object[] values)
- {
- for (int i = 0; i < values.Length; i++)
- {
- if (values[i] == null)
- {
- values[i] = DBNull.Value;
- }
- else if (values[i].GetType().FullName == "System.String")
- {
- values[i] = ((string)values[i]).Length != 0 ? values[i] : DBNull.Value;
- }
- }
- return values;
- }
-
- /// <summary>
- /// 对目标对象进行字符串的转换
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public static string ObjToStr(object obj)
- {
- if (obj == null || obj.GetType() == typeof(System.DBNull))
- {
- return "";
- }
- else
- {
- return Convert.ToString(obj);
- }
- }
- /// <summary>
- /// 对目标对象进行数字(小数)的转换
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public static System.Decimal ObjToDecimal(object obj)
- {
- try
- {
- if (obj == null || obj.GetType() == typeof(System.DBNull) || ObjToStr(obj).Length == 0)
- {
- return 0;
- }
- else
- {
- return Convert.ToDecimal(obj);
- }
- }
- catch (System.Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- return 0;
- }
- }
- /// <summary>
- /// 初始化ComboBox,返回哈希表(针对scm_base_info表)
- /// </summary>
- /// <param name="_sortCode ">scm_base_info中sort_code字段</param>
- /// <returns></returns>
- public ReturnObject IniComboBox(string _sortCode)
- {
- string strSql;
- string strOut = "";
- DataSet ds;
- System.Collections.Hashtable ht = new Hashtable();
- try
- {
- strSql = "select name_ ,id_ from SELECT BUTTRESSCODE FROM KCJ_BUTTRESS_ZW WHERE BUTTRESSTYPE='0' AND ISVALID='1' where sort_code = '" + _sortCode + "'" + " and substr(id_,1,4) ='" + _sortCode + "'";
- ds = this.DBManager.ExecuteQuery(strSql, out strOut);
- if (ds != null && ds.Tables.Count == 1)
- {
- foreach (System.Data.DataRow row in ds.Tables[0].Rows)
- {
- ht.Add(row["id_"].ToString(), row["name_"].ToString());
- }
- return new ReturnObject(ht);
- }
- return new ReturnObject(strOut);
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- return new ReturnObject(ex.ToString());
- }
- }
- /// <summary>
- /// 初始化ComboBox,返回哈希表(针对所有表表)
- /// </summary>
- /// <param name="_sql ">SQL(Select语句)</param>
- /// <param name="_keyCol ">Key字段</param>
- /// <param name="_valuesCol ">Values字段</param>
- /// <returns></returns>
- public ReturnObject IniAllComboBox(string _sql, string _keyCol, string _valuesCol)
- {
- string strOut = "";
- DataSet ds;
- System.Collections.Hashtable ht = new Hashtable();
- try
- {
- ds = this.DBManager.ExecuteQuery(_sql, out strOut);
- if (ds != null && ds.Tables.Count == 1)
- {
- foreach (System.Data.DataRow row in ds.Tables[0].Rows)
- {
- ht.Add(row[_keyCol].ToString(), row[_valuesCol].ToString());
- }
- return new ReturnObject(ht);
- }
- return new ReturnObject(strOut);
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- return new ReturnObject(ex.ToString());
- }
- }
- //得到区域编码_AreaType=0原料,1成品
- public ReturnObject GetAreaCode(string _AreaType)
- {
- string strOut = "";
- ArrayList al = new ArrayList();
- string sql = "";
- try
- {
-
- sql = "select distinct(areacode) from KCJ_AREA_ZW where isvalid = '1'and areatype = '" + _AreaType + "' ";
-
- DataSet ds = this.DBManager.ExecuteQuery(sql, out strOut);
- if (strOut != "")
- {
- return new ReturnObject(strOut);
- }
- foreach (System.Data.DataRow row in ds.Tables[0].Rows)
- {
- al.Add(row["areacode"].ToString());
- }
- return new ReturnObject(al);
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- return new ReturnObject(ex.ToString());
- }
- }
- public ReturnObject GetDataSet(string _sqlstr)
- {
- string strOut = "";
- DataSet ds = this.DBManager.ExecuteQuery(_sqlstr, out strOut);
- //DataSet ds = ((STMes.DBManager)DBManagerList["ODPDB"]).ExecuteQuery(_sqlstr, out strOut);
- return new ReturnObject(ds, strOut);
- }
- }
- }
|