当前位置: 首页 > article >正文

mis_table.cs 与 csharp_mis_table.h

 C++ CLI 中 DataTable, DataRow 用法

mis_table.cs 

/****************************************************************************************************
 * 文件名		:mis_table.cs
 * 
 * 功能			:数据库表的基类 
 * 
 * 作者			:李锋
 * 
 * 邮箱			:ruizhilf@139.com
 * 
 * 手机			:13828778863
 * 
 * 创建时间		:2007年01月09日
                                                    -------------------最后一次修改时间:2016年11月22日

 
 *****************************************************************************************************/
using System;
using System.IO;
using System.Data;


#if _WINDOWS_PLATFORM_
    using System.Data.SqlClient;
    using System.Data.OleDb;
    #if _WINDOWS_DESKTOP_
        using System.Windows.Forms;
    #elif _WINDOWS_WEB_
        using System.Web.UI;
        using System.Web.UI.WebControls;
    #endif
#elif _ANDROID_PLATFORM_
    using Android.App;
    using Android.Content;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using Android.OS;
#elif _IOS_PLATFORM_


#endif




namespace lf
{

    /// <summary>
    /// mis_table 的摘要说明
    /// </summary>
    /// <summary>
    /// 对记录的操作,例如查找,更新,删除等等
    /// </summary>
    public enum Record_Operate
    {
        R_DELETE,         //删除一条记录
        R_UPDATE,         //更新一条记录
        R_INSERT,         //插入一条记录
        R_READ_ALL,       //读出全部记录  
        R_VIEW            //显示字段
    };

 
    public class mis_table
    {
        /// <summary>
        /// 活动,Web页面,窗体
        /// </summary>

#if _WINDOWS_DESKTOP_
        public Form context_page_form = null;
#elif _WINDOWS_WEB_
        public Page context_page_form = null;
#elif _LF_PHONE_APP_

#elif _ANDROID_PLATFORM_
             public  Activity context_page_form = null;
#elif _IOS_PLATFORM_

#endif



        /// <summary>
        /// MIS全局数据库
        /// </summary>
        public Db_ db;

        /// <summary>
        /// 要操作表的名子
        /// </summary>
        public string m_sTableName;


        //------------------------------------------------------------------------------------------------------------------------------------------数据定议
        /// <summary>
        /// 一条记录的索引
        /// </summary>
        public int fd_id;

        /// <summary>
        /// 记录创建时间
        /// </summary>
        public DateTime fd_create_time;

        /// <summary>
        /// 记录最后一次修改时间
        /// </summary>
        public DateTime fd_modify_time;
        /// <summary>
        /// 记录创建人
        /// </summary>
        public int fd_create_author_id;
        /// <summary>
        /// 最后一次记录修改人		
        /// </summary>
        public int fd_modify_author_id;
        /// <summary>
        /// 扩展字段 nchar 1
        /// </summary>
        public string fd_nchar_ext1;
        /// <summary>
        /// 扩展字段 nchar 2
        /// </summary>
        public string fd_nchar_ext2;
        /// <summary>
        /// 扩展字段ntext 1
        /// </summary>
        public string fd_ntext_ext1;
        /// <summary>
        /// 扩展字段ntext 2
        /// </summary>
        public string fd_ntext_ext2;
        /// <summary>
        /// 扩展字段,INTEGER1
        /// </summary>
        public int fd_integer_ext1;
        /// <summary>
        /// 扩展字段,INTEGER2
        /// </summary>
        public int fd_integer_ext2;
        /// <summary>
        /// 扩展字段, float1
        /// </summary>
        public float fd_float_ext1;
        /// <summary>
        /// 扩展字段 ,float2
        /// </summary>
        public float fd_float_ext2;

        /// <summary>
        /// 说明字段
        /// </summary>  
        public string fd_desc;


        /// <summary>
        /// Key的字符串形式索引
        /// </summary>
        public string SID { get { return fd_id.ToString(); } }


        /// <summary>
        /// Key的整数形式索引
        /// </summary>
        public int ID { get { return fd_id; } }



        /// <summary>
        /// 登陆人ID
        /// </summary>
        public int LoginUserID { get { return MIS_Global.LoginUser.ID; } }



        //-------------------------------------------------------------------------------------------------------------------------------重写
        /// <summary>
        /// 删除一条索引为sID的记录。
        /// </summary>
        /// <param name="sID"></param>
        /// <returns></returns>
        public bool deleteDataFromID(string sID, mis_natural_person em)
        {
            if (em != null)
            {
                
                if (!MIS_Global.LoginUser.CanModuleDelete(get_module_id()))
                {
                    throw new Exception("你没有权限删除这条录!");
                }
            }
            return (db.ExecNonSQL("DELETE FROM " + m_sTableName + " WHERE fd_id = " + sID) != 0);
        }


        //-------------------------------------------------------------------------------------------------------------------------------重写
        /// <summary>
        /// 返回模块ID
        /// </summary>
        /// <returns></returns>
        public virtual int get_module_id()
        {
            return -1;
        }













        /// <summary>
        /// 删除一条记录
        /// </summary>
        /// <param name="em"></param>
        /// 创建时间:????-??-??          最后一次修改时间:2020-05-04
        /// <returns></returns>
        public virtual int DeleteSQL()
        {
            crm_login_member clmLogin = MIS_Global.LoginUser;

            string ssql = this.get_Record_Operate_SQL(Record_Operate.R_DELETE);

            if (clmLogin != null)
            {
                if (clmLogin.CanModuleDelete(get_module_id()))
                {
                    return db.ExecNonSQL(ssql);
                }
                else
                {
                    //throw new Exception("你没有权限删除这条记录,请用其它用户登陆再试!");
                    lg.ShowError("你没有权限删除这条记录, 请用其它用户登陆再试!");
                    return -1;
                }
            }
            else
            {
                return db.ExecNonSQL(ssql);
            }
        }

        /// <summary>
        /// 添加一条记录。
        /// </summary>
        /// <param name="em"></param>
        /// 创建时间:????-??-??          最后一次修改时间:2020-05-04
        /// <returns></returns>
        public virtual int InsertSQL()
        {
            crm_login_member clmLogin = MIS_Global.LoginUser;

            string ssql = this.get_Record_Operate_SQL(Record_Operate.R_INSERT);

            if (clmLogin != null)
            {
                if (clmLogin.CanModuleWrite(get_module_id()))
                {
                    return db.ExecNonSQL(ssql);
                }
                else
                {
                    //throw new Exception("你没有权限写入这条记录,请用其它用户登陆再试!");
                    lg.ShowError("你没有权限修改这条记录, 请用其它用户登陆再试!");
                    return -1;
                }
            }
            else
            {
                return db.ExecNonSQL(ssql);
            }
        }



        /// <summary>
        /// 更新一条记录
        /// </summary>
        /// <param name="em"></param>
        /// 创建时间:????-??-??          最后一次修改时间:2020-05-13
        /// <returns></returns>
        public virtual int UpdateSQL()
        {
            crm_login_member clmLogin = MIS_Global.LoginUser;

            string ssql = this.get_Record_Operate_SQL(Record_Operate.R_UPDATE);

            if (clmLogin != null)
            {
                if (clmLogin.CanModuleWrite(get_module_id()))
                {
                    return db.ExecNonSQL(ssql);
                }
                else
                {
                    //throw new Exception("你没有权限写入这条记录,请用其它用户登陆再试!");
                    lg.ShowError("你没有权限写入这条记录, 请用其它用户登陆再试!");
                    return -1;
                }
            }
            else
            {
                return db.ExecNonSQL(ssql);
            }
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="sRecordID"></param>
        /// <param name="sFieldName"></param>
        /// <param name="sFieldValue"></param>
        /// <param name="sTableName"></param>
        /// <param name="db"></param>
        /// 创建时间: ????-??-??      最后一次修改时间:2021-10-03
        /// <returns></returns>
        public static bool UpdateFieldValue(string sRecordID, string sFieldName, string sFieldValue, string sTableName, Db_ db)
        {
            string ssql = "UPDATE [" + sTableName + "] SET [" + sFieldName + "]=" + ConvertToSQLString(sFieldName, sFieldValue, sTableName, db);
            ssql += " WHERE [fd_id] = " + sRecordID;

            return db.ExecNonSQL(ssql) != 0;
         
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="sFieldName"></param>
        /// <param name="sFieldValue"></param>
        /// <param name="sTableName"></param>
        /// <param name="db"></param>
        /// 创建时间: ????-??-??      最后一次修改时间:2021-10-03
        /// <returns></returns>
        public static string ConvertToSQLString(string sFieldName, string sFieldValue, string sTableName, Db_ db)
        {
            Field_ f = db.GetFieldInfo(sFieldName, sTableName);
        
            switch(f.DataType)
            {
                case DataType_.dtString:
                    return "'" + lg.CheckSQLString(sFieldValue) +"'";
                case DataType_.dtDateTime:
                    return "\'" + sFieldValue + "\'";
            }
   
            return sFieldValue;
        }


        //-----------------------------------------------------------------------------------------------------方法
        public string[] getModuleListForTypeCalling(int calling_id)
        {
            return null;
        }

        public string[] getModuleListForTypeCalling(string calling_name)
        {

            return null;
        }


        /// <summary>
        /// 新的索引号
        /// </summary>
        /// <returns></returns>
        public int GetNewID()
        {
            return db.GetMaxID(m_sTableName, "") + 1;
        }


        /// <summary>
        /// 获取登陆人ID
        /// </summary>
        /// <returns></returns>
        public int GetLoginID()
        {
           return (MIS_Global.LoginUser != null ? MIS_Global.LoginUser.fd_id : -1);
        }


        /// <summary>
        /// 返回记录条数
        /// </summary>
        /// <returns></returns>
        public int getRecordCount()
        {
            DataTable dt = db.ExecSQLQuery("SELECT Count(*) AS fd_sum FROM " + m_sTableName);
            return (int)dt.Rows[0]["fd_sum"];
        }

#if _CS_
            /// <summary>
            /// 得到某字段的所有值的列表,如果sqql不为空,则执行sql语句
            /// </summary>
            /// <param name="li"></param>
            public void getFieldValueList(string sFieldName, System.Windows.Forms.ComboBox cb, string ssql)
            {
                db.GetTrimFieldValueList(sFieldName, m_sTableName, "", cb);
            }

#elif _WINDOWS_WEB_
            /// <summary>
            /// 得到某字段的所有值的列表,如果sqql不为空,则执行sql语句
            /// </summary>
            /// <param name="li"></param>
            public void getFieldValueList(string sFieldName, System.Web.UI.WebControls.ListItemCollection li,
                string ssql)
            {
                db.GetTrimFieldValueList(sFieldName, m_sTableName, "", li);
            }
#endif
        //-----------------------------------------------------------------------------方法 


        /// <summary>
        /// 从某个字段的值得到索引号,这个值必须是唯一的,字段的值必须是字符串
        /// </summary>
        /// <param name="sFieldName">字段名</param>
        /// <param name="sValue">字段值</param>
        /// <returns>如找到,返回索引号,否则返回-1</returns>
        public int GetIndex(string sFieldName, string sValue)
        {
            return db.GetIDFromValue(sFieldName, sValue, m_sTableName);
        }
        //----------------------------------------------------------------------------属性

        /// <summary>
        /// 返回记录条数
        /// </summary>
        public int recordCount
        {
            get
            {
                return db.getRecordCount(m_sTableName);
            }
        }




        /// <summary>
        /// 返回最后一条记录的某个字段值
        /// </summary>
        /// <param name="sFileName"></param>
        /// <returns></returns>
        public object getFieldValueForLastRecord(string sFieldName)
        {
            return db.getFieldValueForLastRecord(sFieldName, m_sTableName, "");
        }


        /// <summary>
        /// 删除当前记录
        /// </summary>
        /// <param name="em"></param>
        /// <returns></returns>




        /// <summary>
        /// 根据索引号从数据库读出一条记录
        /// </summary>
        /// <param name="sID"></param>
        /// <returns></returns>
        public bool readDataFromID(string sID)
        {
            DataTable dt = db.ExecSQLQuery("SELECT * FROM " + m_sTableName + " WHERE fd_id =" + sID);
            return readAll(dt);

        }



        /// <summary>
        /// 查字段值为oFieldValue的第一条记录,如果找到,则返回第一条记录的ID,否则返回-1,字符串字段;
        /// </summary>
        /// <param name="sFieldName">字段名</param>
        /// <param name="sFileValue">字段值</param>
        /// <param name="s_condition">条件,可以为空</param>
        /// <returns></returns>
        public int find_s(string sFieldName, string sFileValue, string s_condition = "")
        {
            string ssql = "SELECT fd_id," + sFieldName + " FROM " + m_sTableName + " WHERE "
                + sFieldName + "=\'" + lg.CheckSQLString(sFileValue) + "\'";

            if (s_condition.Trim() != "")
                ssql += " AND " + s_condition;

            DataTable dt = db.ExecSQLQuery(ssql);
            if (dt.Rows.Count > 0)
            {
                return (int)dt.Rows[0]["fd_id"];

            }
            return -1;
        }



        /// <summary>
        /// 查字段值为oFieldValue的第一条记录,如果找到,则返回第一条记录的ID,否则返回-1,数字字段;
        /// </summary>
        /// <param name="sFieldName"></param>
        /// <param name="oFieldValue"></param>
        /// <param name="sCondition"></param>
        /// <returns></returns>
        public int find_d(string sFieldName, object oFieldValue, string sCondition)
        {
            string ssql = "SELECT fd_id," + sFieldName + " FROM " + m_sTableName + " WHERE "
                + sFieldName + "=" + oFieldValue.ToString();

            if (sCondition.Trim().Length != 0)
            {
                ssql += " WHERE " + sCondition;
            }

            DataTable dt = db.ExecSQLQuery(ssql);
            if (dt.Rows.Count > 0)
            {
                return (int)dt.Rows[0]["fd_id"];

            }
            return -1;
        }



        /// <summary>
        /// 查时间值为dt1和dt2之前的记录,如有查到,则返回第一条记录,否则返回-1.
        /// </summary>
        /// <param name="sFieldName"></param>
        /// <param name="dt1"></param>
        /// <param name="dt2"></param>
        /// <param name="sCondition"></param>
        /// <returns></returns>
        public int find_t(string sFieldName, DateTime dt1, DateTime dt2, string sCondition)
        {
            string ssql = "SELECT fd_id FROM " + m_sTableName + " WHERE "
              + sFieldName + " between \'" + dt1.ToString() + "\' AND \'" + dt2.ToString() + "\'";

            if (sCondition.Trim().Length != 0)
            {
                ssql += " AND " + sCondition;
            }

            DataTable dt = db.ExecSQLQuery(ssql);
            if (dt.Rows.Count > 0)
            {
                return (int)dt.Rows[0]["fd_id"];
            }
            return -1;
        }



        /// <summary>
        /// 给出字段名和字段值,读取字段值第一次出现的记录,成功返回真,否则返加假。
        /// </summary>
        /// <param name="sFieldName">字段名</param>
        /// <param name="oFieldValue">字段值</param>
        /// <returns></returns>
        public bool readFromFieldValue(string sFieldName, object oFieldValue)
        {
            string ssql = "SELECT * FROM " + m_sTableName + " WHERE " + sFieldName + "=";
            if (oFieldValue.GetType().ToString() == "System.String")
            {
                ssql += "\'" + oFieldValue.ToString() + "\'";
            }
            else
            {
                throw new Exception("不能识别的数据类型");
            }
            return readAll(db.ExecSQLQuery(ssql));
        }


        /// <summary>
        /// 根据索引号从数据库读出一条记录
        /// </summary>
        /// <param name="sID"></param>
        /// <returns></returns>
        public bool readDataFromID(int iID)
        {
            return readAll(db.ExecSQLQuery("SELECT * FROM " + m_sTableName + " WHERE fd_id =" + iID.ToString()));
        }



        /// <summary>
        /// 显示读取记录时的错误信息
        /// </summary>
        /// <param name="iID"></param>
        public void errorRread(int iID)
        {
            throw new Exception("错误:在表“" + m_sTableName + "”中,无法读取ID号为:“" + iID.ToString() + "”的数据库记录!");
        }


        /// <summary>
        /// 显示读取记录时的错误信息
        /// </summary>
        /// <param name="iID"></param>
        public void errorRread(string sID)
        {
            throw new Exception("错误:在表“" + m_sTableName + "”中,无法读取ID号为:“" + sID + "”的数据库记录!");
        }

        /// <summary>
        /// 显示删除记录时的错误信息
        /// </summary>
        /// <param name="iID"></param>
        public void errorDelete(int iID)
        {
            throw new Exception("错误:在表“" + m_sTableName + "”中,无法删除ID号为:“" + iID.ToString() + "”的数据库记录!");
        }

        /// <summary>
        /// 修改一个ID号
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public virtual int updateID(int nNewID)
        {
            return db.ExecNonSQL("UPDATE " + m_sTableName + "  SET fd_id = " + nNewID.ToString() + " WHERE fd_id=" +
                fd_id.ToString());
        }


        /// <summary>
        /// 初始化数据,在类的构造函数中,会调用这个函数
        /// </summary>
        protected virtual void InitData()
        {
            fd_id = -1;
            fd_create_time = DateTime.Now;
            fd_modify_time = DateTime.Now;
            fd_create_author_id = -1;
            fd_modify_author_id = -1;


            fd_nchar_ext1 = "";
            fd_nchar_ext2 = "";
            fd_ntext_ext1 = "";
            fd_ntext_ext2 = "";
            fd_integer_ext1 = 0;
            fd_integer_ext2 = 0;
            fd_float_ext1 = 0;
            fd_float_ext2 = 0;

            fd_desc = "";
        }



        /// <summary>
        /// 根据字段的值,读取一条记录
        /// </summary>
        /// <param name="sNameCN"></param>
        /// <returns></returns>
        public virtual bool readDataFromName_CN(string sValue)
        {
            return readAll(db.ExecSQLQuery("SELECT * FROM " + m_sTableName + " WHERE fd_name_cn =\'" + lg.CheckSQLString(sValue) + "\'"));
        }

        /// <summary>
        /// 根据字段的值,读取一条记录
        /// </summary>
        /// <param name="sNameCN"></param>
        /// <returns></returns>
        public virtual bool readDataFromName(string sValue)
        {
            string fd_field_name = "fd_name_cn";

            if (lg.languageID == 1)
            {
                fd_field_name = "fd_name_en";
            }

            return readAll(db.ExecSQLQuery("SELECT * FROM " + m_sTableName + " WHERE " + fd_field_name + "=\'" + lg.CheckSQLString(sValue) + "\'"));
        }


        /// <summary>
        /// 读取所有字段值
        /// </summary>
        /// <param name="dt"></param>
        public virtual bool readAll(DataTable dt)
        {
            if (dt.Rows.Count > 0)
            {
                fd_id = (int)dt.Rows[0]["fd_id"];
                fd_create_time = Convert.ToDateTime(dt.Rows[0]["fd_create_time"]);
                fd_modify_time = Convert.ToDateTime(dt.Rows[0]["fd_modify_time"]);
                fd_desc = dt.Rows[0]["fd_desc"].ToString();
                return true;
            }
            return false;
        }


        public virtual void readRowAll(DataRow dr)
        {
            fd_id = (int)dr["fd_id"];
            fd_create_time = Convert.ToDateTime(dr["fd_create_time"]);
            fd_modify_time = Convert.ToDateTime(dr["fd_modify_time"]);
            fd_desc = dr["fd_desc"].ToString();
        }


        /// <summary>
        /// 更新照片,文件等二进制字段
        /// </summary>
        /// <param name="sFieldName"></param>
        /// <param name="msFieldValue"></param>
        /// <param name="em"></param>
        /// <returns></returns>
        public int updateMemoryField(string sFieldName, MemoryStream msFieldValue)
        {
#if _WINDOWS_PLATFORM_
            if (msFieldValue == null)   return 0;
            string ssql = "UPDATE " + m_sTableName + " SET " + sFieldName + "=@"
                    + sFieldName + " WHERE fd_id=" + fd_id.ToString();

            string ssqlName = "@" + sFieldName;


            if (db.dataFormat == DataFormat_.dfAccdb || db.dataFormat == DataFormat_.dfMDB)
            {
                OleDbConnection onn = new OleDbConnection(db.GetConnection().ConnectionString);
                OleDbCommand cmd = new OleDbCommand(ssql,onn);
                OleDbParameter par_filed = new OleDbParameter(ssqlName, OleDbType.LongVarBinary);       
                par_filed.Value = msFieldValue.ToArray();
                cmd.Parameters.Add(par_filed);
                onn.Open();
                int n = cmd.ExecuteNonQuery();
                onn.Close();
                return n;
            }
            else if (db.dataFormat == DataFormat_.dfSQLServer)
            {
                SqlConnection onn = new SqlConnection(db.GetConnection().ConnectionString);
                SqlCommand cmd = new SqlCommand(ssql, onn);
                SqlParameter par_filed = new SqlParameter(ssqlName, OleDbType.LongVarBinary);

                par_filed.Value = msFieldValue.ToArray();
                cmd.Parameters.Add(par_filed);

                onn.Open();
                int n = cmd.ExecuteNonQuery();
                onn.Close();
                return n;
            }
            else
            {
                //lg.ShowInfo("InsertSQL(crm_natural_person em)函数还未完成,请重新完成!",this);
                return 0;
            }        
#else

            throw new Exception("代码未完成!");
#endif
        }

        /*
        /// <summary>
        /// 查看这个员工是否能够修改这个模块
        /// </summary>
        /// <param name="sModule"></param>
        /// <returns></returns>
        public virtual bool CanModuleWrite(int i_module_id)
        {
            return true;
        }

        /// <summary>
        /// 查看这个员工是否能够读取这个模块
        /// </summary>
        /// <param name="sModule"></param>
        /// <returns></returns>
        public virtual bool CanModuleRead(int i_module_id)
        {
            return true;
        }

        /// <summary>
        /// 查看这个员工是否能够删除记录
        /// </summary>
        /// <param name="sModule"></param>
        /// <returns></returns>
        public virtual bool CanModuleDelete(int i_module_id)
        {
            return true;
        }
        */

        /// <summary>
        /// 创建时间: ????-??-??      最后一次修改时间:2020-06-16
        /// 根据参数,得到SQL语句
        /// </summary>
        /// <param name="ro"></param>
        /// <returns></returns>
        public virtual string get_Record_Operate_SQL(Record_Operate ro)
        {
            string ssql;

           
            switch (ro)
            {
                case Record_Operate.R_DELETE:
                    {
                        ssql = "DELETE FROM " + m_sTableName + " WHERE fd_id = " + fd_id.ToString();
                        break;
                    }

                case Record_Operate.R_INSERT:
                    {
                        fd_id = GetNewID();
                        ssql = "INSERT INTO " + m_sTableName +
                             "(fd_id,fd_create_time,fd_modify_time,fd_create_author_id,fd_modify_author_id,fd_desc) VALUES(" +
                             "" + fd_id.ToString() + "," +           
                             "\'" + DateTime.Now.ToShortDateString() + "\'," +
                             "\'" + DateTime.Now.ToShortDateString() + "\'," +
                             "" + GetLoginID().ToString() + "," +
                             "" + GetLoginID().ToString() + "," +
                             "\'" + lg.CheckSQLString(fd_desc) + "\'" + ")";                         
                        break;
                    }

                case Record_Operate.R_UPDATE:
                    {

                        ssql = "UPDATE [" + m_sTableName + "] SET " +
                            //"fd_create_time=\'" + fd_create_time.ToString() + "\'," +
                            "[fd_create_author_id] =" + GetLoginID().ToString() + "," +
                            "[fd_modify_time]=\'" + DateTime.Now.ToShortDateString() + "\'," +
                            "[fd_desc]=\'" + lg.CheckSQLString(fd_desc) + "\' WHERE fd_id =" + fd_id.ToString();

                        break;
                    }
                case Record_Operate.R_VIEW:
                    {
                        if (lg.languageID == 2)
                        {
                            ssql = "SELECT fd_id AS 索引,fd_create_time AS 创建时间,fd_modify_time AS 修改时间,fd_desc AS  描述 FROM " + m_sTableName;
                        }
                        else
                        {
                            ssql = "SELECT fd_id AS [Index], fd_create_time AS [Create time],fd_modify_time AS [Modify time]fd_desc AS [Description] FROM " + m_sTableName;

                        }
                        break;
                    }
                default:
                    ssql = "";
                    break;
            }
            return ssql;
        }




        public mis_table(string sTableName, Db_ fromDB)
        {
            InitData();
            db = fromDB;
            m_sTableName = sTableName;
        }


        /// <summary>
        /// 如果没有指定数据库,则默认为:MIS_Global.db_data
        /// </summary>
        /// <param name="sTableName">表名</param>
        public mis_table(string sTableName)
        {
            InitData();
            db = MIS_Global.db_data;
            m_sTableName = sTableName;
        }


        /// <summary>
        /// 读取id号为最大的记录,一般是最后一条记录
        /// </summary>
        /// <returns></returns>
        public bool readRecorderForMaxID()
        {
            return readAll(db.ExecSQLQuery("SELECT TOP 1 * FROM " + m_sTableName + " ORDER BY fd_id DESC"));
        }
    }


    public class mis_image : mis_table
    {

        /// <summary>
        /// 图片类型(合同,个人简历,个人相片、、)
        /// </summary>
        protected string fd_type;

        /// <summary>
        /// 关键字,标识
        /// </summary>
        protected string fd_key;


        /// <summary>
        /// 页面次序
        /// </summary>
        protected int fd_page_order;

        /// <summary>
        /// 图片
        /// </summary>
        private MemoryStream fd_image;

        /// <summary>
        /// 图片扩展名
        /// </summary>
        protected string fd_image_ext;

        /// <summary>
        /// 图片类型(合同,个人简历,个人相片、、)
        /// </summary>
        public string type { get { return fd_type; } set { fd_type = value; } }

        /// <summary>
        /// 关键字,标识
        /// </summary>
        public string key { get { return fd_key; } set { fd_key = value; } }

        /// <summary>
        /// 页面次序
        /// </summary>
        public int page_order { get { return fd_page_order; } set { fd_page_order = value; } }


        /// <summary>
        /// 图片
        /// </summary>
        public MemoryStream image
        {
            get
            {
                return fd_image;
            }
            set
            {
                fd_image = value;
            }
        }

        /// <summary>
        /// 图片扩展名
        /// </summary>
        public string image_ext { get { return fd_image_ext; } set { fd_image_ext = value; } }



        public mis_image() : base("mis_image", LDB_Global.db_data)
        {
            fd_image = null;
        }

        /*
        public mis_image(string sTableName) : base(sTableName, MIS_Global.LoginUser.db)
        {

            fd_image = null;
        }

        */

        /// <summary>
        /// 更新照片
        /// </summary>
        /// <param name="sFullPath"></param>
        public int updatePicture(string sFullPath)
        {
            /*
            FileStream fs = new FileStream(sFullPath, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);
            byte[] _imgBytesIn = br.ReadBytes((int)fs.Length);
            br.Close();
            fs.Close(); 
            image = new System.IO.MemoryStream(_imgBytesIn);
            return updateMemoryField("fd_image", image, null);
            */
            return 0;
        }

        /// <summary>
        /// 读取照片
        /// </summary>
        /// <returns></returns>
        public bool readPicture()
        {
            DataTable dt = db.ExecSQLQuery("SELECT fd_image FROM " + m_sTableName + " WHERE fd_id=" +
                fd_id.ToString());

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["fd_image"] != DBNull.Value)
                {
                    fd_image = new MemoryStream((byte[])dt.Rows[0]["fd_image"]);
                    return true;
                }
            }
            return false;
        }


        /// <summary>
        /// 返回一个新的页面序号
        /// </summary>
        /// <param name="sTableName"></param>
        /// <param name="sType"></param>
        /// <param name="sKey"></param>
        /// <returns></returns>
        public static int get_new_order(string sTableName, string sType, string sKey)
        {
            string ssql = "SELECT TOP 1 fd_page_order FROM  " + sTableName + " WHERE fd_type=\'" +
                sType + "\' AND fd_key=\'" + sKey + "\' ORDER BY fd_page_order DESC";

            DataTable dt = LDB_Global.db_data.ExecSQLQuery(ssql);
            if (dt.Rows.Count > 0)
                return System.Convert.ToInt32(dt.Rows[0]["fd_page_order"]) + 1;
            else
                return 1;
        }

        public override string get_Record_Operate_SQL(Record_Operate ro)
        {
            string ssql = "";

            switch (ro)
            {
                case Record_Operate.R_INSERT:
                    {
                        fd_id = GetNewID();
                        ssql = "INSERT INTO " + m_sTableName +
                        "(fd_id,fd_create_time,fd_modify_time,fd_create_author_id,fd_modify_author_id," +
                        "fd_type,fd_key,fd_page_order,fd_image_ext," +
                        "fd_nchar_ext1,fd_nchar_ext2,fd_ntext_ext1,fd_ntext_ext2,fd_integer_ext1," +
                        "fd_integer_ext2,fd_float_ext1,fd_float_ext2,fd_desc) VALUES(" +
                        "" + fd_id.ToString() + "," +
                        "\'" + System.DateTime.Now.ToString() + "\'," +
                        "\'" + System.DateTime.Now.ToString() + "\'," +
                        "" + MIS_Global.LoginUser.fd_id.ToString() + "," +
                        "" + MIS_Global.LoginUser.fd_id.ToString() + "," +
                        "\'" + lg.CheckSQLString(fd_type) + "\'," +
                        "\'" + lg.CheckSQLString(fd_key) + "\'," +
                        "" + fd_page_order.ToString() + "," +
                        "\'" + lg.CheckSQLString(fd_image_ext) + "\'," +
                        "\'" + lg.CheckSQLString(fd_nchar_ext1) + "\'," +
                        "\'" + lg.CheckSQLString(fd_nchar_ext2) + "\'," +
                        "\'" + lg.CheckSQLString(fd_ntext_ext1) + "\'," +
                        "\'" + lg.CheckSQLString(fd_ntext_ext2) + "\'," +
                        "" + fd_integer_ext1.ToString() + "," +
                        "" + fd_integer_ext2.ToString() + "," +
                        "" + fd_float_ext1.ToString() + "," +
                        "" + fd_float_ext2.ToString() + "," +
                        "\'" + lg.CheckSQLString(fd_desc) + "\')";
                        break;
                    }

                case Record_Operate.R_UPDATE:
                    {
                        ssql = "UPDATE " + m_sTableName + " SET ";
                        ssql += "fd_id=" + fd_id.ToString() + ",";
                        ssql += "fd_modify_time=\'" + System.DateTime.Now.ToString() + "\',";
                        ssql += "fd_modify_author_id=" + MIS_Global.LoginUser.fd_id.ToString() + ",";
                        ssql += "fd_type=\'" + lg.CheckSQLString(fd_type) + "\',";
                        ssql += "fd_key=\'" + lg.CheckSQLString(fd_key) + "\',";
                        ssql += "fd_page_order=" + fd_page_order.ToString() + ",";
                        ssql += "fd_image_ext=\'" + lg.CheckSQLString(fd_image_ext) + "\',";
                        ssql += "fd_nchar_ext1=\'" + lg.CheckSQLString(fd_nchar_ext1) + "\',";
                        ssql += "fd_nchar_ext2=\'" + lg.CheckSQLString(fd_nchar_ext2) + "\',";
                        ssql += "fd_ntext_ext1=\'" + lg.CheckSQLString(fd_ntext_ext1) + "\',";
                        ssql += "fd_ntext_ext2=\'" + lg.CheckSQLString(fd_ntext_ext2) + "\',";
                        ssql += "fd_integer_ext1=" + fd_integer_ext1.ToString() + ",";
                        ssql += "fd_integer_ext2=" + fd_integer_ext2.ToString() + ",";
                        ssql += "fd_float_ext1=" + fd_float_ext1.ToString() + ",";
                        ssql += "fd_float_ext2=" + fd_float_ext2.ToString() + ",";
                        ssql += "fd_desc=\'" + lg.CheckSQLString(fd_desc) + "\'";
                        ssql += "  WHERE fd_id=" + fd_id.ToString();
                        break;
                    }
                default:
                    return base.get_Record_Operate_SQL(ro);
            }
            return ssql;
        }

        public override bool readAll(DataTable dt)
        {
            if (dt.Rows.Count > 0)
            {
                fd_id = (int)dt.Rows[0]["fd_id"];
                fd_create_time = Convert.ToDateTime(dt.Rows[0]["fd_create_time"]);
                fd_modify_time = Convert.ToDateTime(dt.Rows[0]["fd_modify_time"]);
                fd_create_author_id = (int)dt.Rows[0]["fd_create_author_id"];
                fd_modify_author_id = (int)dt.Rows[0]["fd_modify_author_id"];
                fd_type = dt.Rows[0]["fd_type"].ToString();
                fd_key = dt.Rows[0]["fd_key"].ToString();
                fd_page_order = (int)dt.Rows[0]["fd_page_order"];
                fd_image_ext = dt.Rows[0]["fd_image_ext"].ToString();
                fd_nchar_ext1 = dt.Rows[0]["fd_nchar_ext1"].ToString();
                fd_nchar_ext2 = dt.Rows[0]["fd_nchar_ext2"].ToString();
                fd_ntext_ext1 = dt.Rows[0]["fd_ntext_ext1"].ToString();
                fd_ntext_ext2 = dt.Rows[0]["fd_ntext_ext2"].ToString();
                fd_integer_ext1 = (int)dt.Rows[0]["fd_integer_ext1"];
                fd_integer_ext2 = (int)dt.Rows[0]["fd_integer_ext2"];
                fd_float_ext1 = Convert.ToSingle(dt.Rows[0]["fd_float_ext1"]);
                fd_float_ext2 = Convert.ToSingle(dt.Rows[0]["fd_float_ext2"]);
                fd_desc = dt.Rows[0]["fd_desc"].ToString();
                return true;
            }
            return false;
        }

        public override void readRowAll(DataRow dr)
        {
            fd_id = (int)dr["fd_id"];
            fd_create_time = Convert.ToDateTime(dr["fd_create_time"]);
            fd_modify_time = Convert.ToDateTime(dr["fd_modify_time"]);
            fd_create_author_id = (int)dr["fd_create_author_id"];
            fd_modify_author_id = (int)dr["fd_modify_author_id"];
            fd_type = dr["fd_type"].ToString();
            fd_key = dr["fd_key"].ToString();
            fd_page_order = (int)dr["fd_page_order"];
            fd_image_ext = dr["fd_image_ext"].ToString();
            fd_nchar_ext1 = dr["fd_nchar_ext1"].ToString();
            fd_nchar_ext2 = dr["fd_nchar_ext2"].ToString();
            fd_ntext_ext1 = dr["fd_ntext_ext1"].ToString();
            fd_ntext_ext2 = dr["fd_ntext_ext2"].ToString();
            fd_integer_ext1 = (int)dr["fd_integer_ext1"];
            fd_integer_ext2 = (int)dr["fd_integer_ext2"];
            fd_float_ext1 = Convert.ToSingle(dr["fd_float_ext1"]);
            fd_float_ext2 = Convert.ToSingle(dr["fd_float_ext2"]);
            fd_desc = dr["fd_desc"].ToString();
        }
    }

}

csharp_mis_table.h

/****************************************************************************
 * 文件名		:csharp_mis_table.h
 *
 * 功能			:数据库表的基类
 *
 * 作者			:李锋
 *
 * 邮箱			:ruizhilf@139.com
 *
 * 手机			:13828778863
 *
 * 创建时间		:2007年01月09日
                                        -------最后一次修改时间:2016年11月22日


 ***************************************************************************/
#pragma once




#include"csharp_db.h"
#include "csharp_MIS_Global.h"
/


_LF_BEGIN_


using namespace System;
using namespace System::IO;
using namespace System::Data;


#if _WINDOWS_PLATFORM_
using System.Data.SqlClient;
using System.Data.OleDb;
#if _WINDOWS_DESKTOP_
using System.Windows.Forms;
#elif _WINDOWS_WEB_
using System.Web.UI;
using System.Web.UI.WebControls;
#endif
#elif _ANDROID_PLATFORM_
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
#elif _IOS_PLATFORM_


#endif




ref class csharp_mis_natural_person;


///

 
/// <summary>
/// csharp_mis_table 的摘要说明
/// </summary>
/// <summary>
/// 对记录的操作,例如查找,更新,删除等等
/// </summary>
enum class  csharp_Record_Operate
{
    R_DELETE,         //删除一条记录
    R_UPDATE,         //更新一条记录
    R_INSERT,         //插入一条记录
    R_READ_ALL,       //读出全部记录  
    R_VIEW            //显示字段
};


ref class csharp_mis_table
{
protected:

    /// <summary>
    /// 初始化数据,在类的构造函数中,会调用这个函数
    /// </summary>
    virtual void InitData();


public:
    /// <summary>
    /// 活动,Web页面,窗体
    /// </summary>

#if _WINDOWS_DESKTOP_
    Form context_page_form = null;
#elif _WINDOWS_WEB_
    Page context_page_form = null;
#elif _LF_PHONE_APP_

#elif _ANDROID_PLATFORM_
     Activity context_page_form = null;
#elif _IOS_PLATFORM_

#endif



    /// <summary>
    /// MIS全局数据库
    /// </summary>
    csharp_db^ db;

    /// <summary>
    /// 要操作表的名子
    /// </summary>
    String^ m_sTableName;


    //------------------------------------------------------------------------------------------------------------------------------------------数据定议
    /// <summary>
    /// 一条记录的索引
    /// </summary>
    int fd_id;

    /// <summary>
    /// 记录创建时间
    /// </summary>
    DateTime fd_create_time;

    /// <summary>
    /// 记录最后一次修改时间
    /// </summary>
    DateTime fd_modify_time;
    /// <summary>
    /// 记录创建人
    /// </summary>
    int fd_create_author_id;
    /// <summary>
    /// 最后一次记录修改人		
    /// </summary>
    int fd_modify_author_id;
    /// <summary>
    /// 扩展字段 nchar 1
    /// </summary>
    String^ fd_nchar_ext1;
    /// <summary>
    /// 扩展字段 nchar 2
    /// </summary>
    String^ fd_nchar_ext2;
    /// <summary>
    /// 扩展字段ntext 1
    /// </summary>
    String^ fd_ntext_ext1;
    /// <summary>
    /// 扩展字段ntext 2
    /// </summary>
    String^ fd_ntext_ext2;
    /// <summary>
    /// 扩展字段,INTEGER1
    /// </summary>
    int fd_integer_ext1;
    /// <summary>
    /// 扩展字段,INTEGER2
    /// </summary>
    int fd_integer_ext2;
    /// <summary>
    /// 扩展字段, float1
    /// </summary>
    float fd_float_ext1;
    /// <summary>
    /// 扩展字段 ,float2
    /// </summary>
    float fd_float_ext2;

    /// <summary>
    /// 说明字段
    /// </summary>  
    String^ fd_desc;


    /// <summary>
    /// Key的字符串形式索引
    /// </summary>
    property String^ SID{ String^  get() { return fd_id.ToString(); } }


    /// <summary>
    /// Key的整数形式索引
    /// </summary>
    property int ID{ int get() { return fd_id; } }



    /// <summary>
    /// 登陆人ID
    /// </summary>
    int GetLoginUserID();



    //-------------------------------------------------------------------------------------------------------------------------------重写
    /// <summary>
    /// 删除一条索引为sID的记录。
    /// </summary>
    /// <param name="sID"></param>
    /// <returns></returns>
    bool deleteDataFromID(String^ sID, csharp_mis_natural_person^ em);


    //-------------------------------------------------------------------------------------------------------------------------------重写
    /// <summary>
    /// 返回模块ID
    /// </summary>
    /// <returns></returns>
    virtual int get_module_id();


      
    /// <summary>
    /// 删除一条记录
    /// </summary>
    /// <param name="em"></param>
    /// 创建时间:????-??-??          最后一次修改时间:2020-05-04
    /// <returns></returns>
    virtual int DeleteSQL();

    /// <summary>
    /// 添加一条记录。
    /// </summary>
    /// <param name="em"></param>
    /// 创建时间:????-??-??          最后一次修改时间:2020-05-04
    /// <returns></returns>
    virtual int InsertSQL();



    /// <summary>
    /// 更新一条记录
    /// </summary>
    /// <param name="em"></param>
    /// 创建时间:????-??-??          最后一次修改时间:2020-05-13
    /// <returns></returns>
    virtual int UpdateSQL();



    /// <summary>
    /// 
    /// </summary>
    /// <param name="sRecordID"></param>
    /// <param name="sFieldName"></param>
    /// <param name="sFieldValue"></param>
    /// <param name="sTableName"></param>
    /// <param name="db"></param>
    /// 创建时间: ????-??-??      最后一次修改时间:2021-10-03
    /// <returns></returns>
    static bool UpdateFieldValue(String^ sRecordID, String^ sFieldName,
        String^ sFieldValue, String^ sTableName, csharp_db^ db);

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sFieldName"></param>
    /// <param name="sFieldValue"></param>
    /// <param name="sTableName"></param>
    /// <param name="db"></param>
    /// 创建时间: ????-??-??      最后一次修改时间:2021-10-03
    /// <returns></returns>
    static String^ ConvertToSQLString(String^ sFieldName, String^ sFieldValue,
        String^ sTableName, csharp_db^ db);


    //-----------------------------------------------------------------------------------------------------方法
    csharp_StringList^ getModuleListForTypeCalling(int calling_id);

    csharp_StringList^ getModuleListForTypeCalling(String^ calling_name);


    /// <summary>
    /// 新的索引号
    /// </summary>
    /// <returns></returns>
    int GetNewID();


    /// <summary>
    /// 获取登陆人ID
    /// </summary>
    /// <returns></returns>
    int GetLoginID();


    /// <summary>
    /// 返回记录条数
    /// </summary>
    /// <returns></returns>
    int getRecordCount();

#if _CS_
    /// <summary>
    /// 得到某字段的所有值的列表,如果sqql不为空,则执行sql语句
    /// </summary>
    /// <param name="li"></param>
    void getFieldValueList(String^ sFieldName, System.Windows.Forms.ComboBox cb, String^ ssql)
    {
        db.GetTrimFieldValueList(sFieldName, m_sTableName, "", cb);
    }

#elif _WINDOWS_WEB_
    /// <summary>
    /// 得到某字段的所有值的列表,如果sqql不为空,则执行sql语句
    /// </summary>
    /// <param name="li"></param>
    void getFieldValueList(String^ sFieldName, System.Web.UI.WebControls.ListItemCollection li,
        String^ ssql)
    {
        db.GetTrimFieldValueList(sFieldName, m_sTableName, "", li);
    }
#endif
    //-----------------------------------------------------------------------------方法 


    /// <summary>
    /// 从某个字段的值得到索引号,这个值必须是唯一的,字段的值必须是字符串
    /// </summary>
    /// <param name="sFieldName">字段名</param>
    /// <param name="sValue">字段值</param>
    /// <returns>如找到,返回索引号,否则返回-1</returns>
    int GetIndex(String^ sFieldName, String^ sValue);


    //----------------------------------------------------------------------------属性

    /// <summary>
    /// 返回记录条数
    /// </summary>
    property int recordCount
    {
        int get()
        {
            return db->getRecordCount(m_sTableName);
        }
    }




    /// <summary>
    /// 返回最后一条记录的某个字段值
    /// </summary>
    /// <param name="sFileName"></param>
    /// <returns></returns>
    Object^ getFieldValueForLastRecord(String^ sFieldName);


    /// <summary>
    /// 删除当前记录
    /// </summary>
    /// <param name="em"></param>
    /// <returns></returns>




    /// <summary>
    /// 根据索引号从数据库读出一条记录
    /// </summary>
    /// <param name="sID"></param>
    /// <returns></returns>
    bool readDataFromID(String^ sID);



    /// <summary>
    /// 查字段值为oFieldValue的第一条记录,如果找到,则返回第一条记录的ID,否则返回-1,字符串字段;
    /// </summary>
    /// <param name="sFieldName">字段名</param>
    /// <param name="sFileValue">字段值</param>
    /// <param name="s_condition">条件,可以为空</param>
    /// <returns></returns>
    int find_s(String^ sFieldName, String^ sFileValue, String^ s_condition);
    int find_s(String^ sFieldName, String^ sFileValue);


    /// <summary>
    /// 查字段值为oFieldValue的第一条记录,如果找到,则返回第一条记录的ID,否则返回-1,数字字段;
    /// </summary>
    /// <param name="sFieldName"></param>
    /// <param name="oFieldValue"></param>
    /// <param name="sCondition"></param>
    /// <returns></returns>
    int find_d(String^ sFieldName, Object^ oFieldValue, String^ sCondition);


    /// <summary>
    /// 查时间值为dt1和dt2之前的记录,如有查到,则返回第一条记录,否则返回-1.
    /// </summary>
    /// <param name="sFieldName"></param>
    /// <param name="dt1"></param>
    /// <param name="dt2"></param>
    /// <param name="sCondition"></param>
    /// <returns></returns>
    int find_t(String^ sFieldName, DateTime dt1, DateTime dt2, String^ sCondition);



    /// <summary>
    /// 给出字段名和字段值,读取字段值第一次出现的记录,成功返回真,否则返加假。
    /// </summary>
    /// <param name="sFieldName">字段名</param>
    /// <param name="oFieldValue">字段值</param>
    /// <returns></returns>
    bool readFromFieldValue(String^ sFieldName, Object^ oFieldValue);


    /// <summary>
    /// 根据索引号从数据库读出一条记录
    /// </summary>
    /// <param name="sID"></param>
    /// <returns></returns>
    bool readDataFromID(int iID);



    /// <summary>
    /// 显示读取记录时的错误信息
    /// </summary>
    /// <param name="iID"></param>
    void errorRread(int iID);


    /// <summary>
    /// 显示读取记录时的错误信息
    /// </summary>
    /// <param name="iID"></param>
    void errorRread(String^ sID);

    /// <summary>
    /// 显示删除记录时的错误信息
    /// </summary>
    /// <param name="iID"></param>
    void errorDelete(int iID);

    /// <summary>
    /// 修改一个ID号
    /// </summary>
    /// <param name="iid"></param>
    /// <returns></returns>
    virtual int updateID(int nNewID);


    /// <summary>
    /// 根据字段的值,读取一条记录
    /// </summary>
    /// <param name="sNameCN"></param>
    /// <returns></returns>
    virtual bool readDataFromName_CN(String^ sValue);

    /// <summary>
    /// 根据字段的值,读取一条记录
    /// </summary>
    /// <param name="sNameCN"></param>
    /// <returns></returns>
    virtual bool readDataFromName(String^ sValue);


    /// <summary>
    /// 读取所有字段值
    /// </summary>
    /// <param name="dt"></param>
    virtual bool readAll(DataTable^ dt);


    virtual bool readRowAll(DataRow^ dr);


    /// <summary>
    /// 更新照片,文件等二进制字段
    /// </summary>
    /// <param name="sFieldName"></param>
    /// <param name="msFieldValue"></param>
    /// <param name="em"></param>
    /// <returns></returns>
    int updateMemoryField(String^ sFieldName, MemoryStream^ msFieldValue);



    /*
    /// <summary>
    /// 查看这个员工是否能够修改这个模块
    /// </summary>
    /// <param name="sModule"></param>
    /// <returns></returns>
    virtual bool CanModuleWrite(int i_module_id)
    {
        return true;
    }

    /// <summary>
    /// 查看这个员工是否能够读取这个模块
    /// </summary>
    /// <param name="sModule"></param>
    /// <returns></returns>
    virtual bool CanModuleRead(int i_module_id)
    {
        return true;
    }

    /// <summary>
    /// 查看这个员工是否能够删除记录
    /// </summary>
    /// <param name="sModule"></param>
    /// <returns></returns>
    virtual bool CanModuleDelete(int i_module_id)
    {
        return true;
    }
    */

    /// <summary>
    /// 创建时间: ????-??-??      最后一次修改时间:2020-06-16
    /// 根据参数,得到SQL语句
    /// </summary>
    /// <param name="ro"></param>
    /// <returns></returns>
    virtual String^ get_Record_Operate_SQL(csharp_Record_Operate ro);




    csharp_mis_table(String^ sTableName, csharp_db^ fromDB);


    /// <summary>
    /// 如果没有指定数据库,则默认为:csharp_MIS_Global::db_data
    /// </summary>
    /// <param name="sTableName">表名</param>
    csharp_mis_table(String^ sTableName);


    /// <summary>
    /// 读取id号为最大的记录,一般是最后一条记录
    /// </summary>
    /// <returns></returns>
    bool readRecorderForMaxID();
};


/// <summary>
/// 有名字fd_name_cn, fd_name_en的表
/// </summary>
ref class csharp_mis_identity : public csharp_mis_table
{
public:
    String^ fd_name_cn;
    String^ fd_name_en;

    csharp_mis_identity(String^ sTableName, csharp_db^ db) :
        csharp_mis_table(sTableName, db) {}

    virtual String^ ToString() override { return fd_name_cn; }


    String^ get_Record_Operate_SQL(csharp_Record_Operate ro) override;

    bool readRowAll(DataRow^ dr) override;
};


ref class csharp_mis_image : public csharp_mis_table
{

private:
    /// <summary>
    /// 图片
    /// </summary>
    MemoryStream^ fd_image;

protected:
    /// <summary>
    /// 图片类型(合同,个人简历,个人相片、、)
    /// </summary>
    String^ fd_type;

    /// <summary>
    /// 关键字,标识
    /// </summary>
    String^ fd_key;


    /// <summary>
    /// 页面次序
    /// </summary>
    int fd_page_order;



    /// <summary>
    /// 图片扩展名
    /// </summary>
    String^ fd_image_ext;

public:
    /// <summary>
    /// 图片类型(合同,个人简历,个人相片、、)
    /// </summary>
    property String^ type
    { 
        String^ get()
        { 
            return fd_type; 
        } 
        void set(String^ value)
        { 
            fd_type = value; 
        }
    }

    /// <summary>
    /// 关键字,标识
    /// </summary>
    property String^ key
    { 
        String^ get()
        {
            return fd_key; 
        } 
        void set(String^ value)
        { 
            fd_key = value;
        } 
    }


    /// <summary>
    /// 页面次序
    /// </summary>
    property int page_order
    { 
        int get()
        { 
            return fd_page_order; 
        } 
        void set(int value)
        { 
            fd_page_order = value;
        } 
    }


        /// <summary>
        /// 图片
        /// </summary>
    property  MemoryStream^ image
    {
        MemoryStream^ get()
        {
            return fd_image;
        }
        void set(MemoryStream^ value)
        {
            fd_image = value;
        }
    }

    /// <summary>
    /// 图片扩展名
    /// </summary>
    property String^ image_ext
    { 
        String^ get()
        { 
            return fd_image_ext;
        } 
        void set(String^ value)
        { 
            fd_image_ext = value; 
        } 
    }



    csharp_mis_image() : csharp_mis_table("mis_image", csharp_DB_Global::db_data)
    {
        fd_image = null;
    }

    /*
    mis_image(String^ sTableName) : base(sTableName, csharp_MIS_Global::LoginUser.db)
    {

        fd_image = null;
    }

    */

    /// <summary>
    /// 更新照片
    /// </summary>
    /// <param name="sFullPath"></param>
    int updatePicture(String^ sFullPath);

    /// <summary>
    /// 读取照片
    /// </summary>
    /// <returns></returns>
    bool readPicture();


    /// <summary>
    /// 返回一个新的页面序号
    /// </summary>
    /// <param name="sTableName"></param>
    /// <param name="sType"></param>
    /// <param name="sKey"></param>
    /// <returns></returns>
    static int get_new_order(String^ sTableName, String^ sType, String^ sKey);


    String^ get_Record_Operate_SQL(csharp_Record_Operate ro)override;
  
    bool readAll(DataTable^ dt) override;
   
    void readRowAll(DataRow dr)override;

   
};



//
_LF_END_

csharp_mis_table.cpp

#include "csharp_mis_table.h"
#include "csharp_mis_natural_person.h"
#include "csharp_crm_login_member.h"

_LF_BEGIN_

int csharp_mis_table::GetLoginUserID()
{
    return csharp_MIS_Global::LoginUser->ID;  
}

bool csharp_mis_table::deleteDataFromID(String^ sID, csharp_mis_natural_person^ em)
{
    if (em != null)
    {

        if (!csharp_MIS_Global::LoginUser->CanModuleDelete(get_module_id()))
        {
            throw gcnew Exception("你没有权限删除这条录!");
        }
    }
    return (db->ExecNonSQL("DELETE FROM " + m_sTableName + " WHERE fd_id = " + sID) != 0);
}

 
void csharp_mis_table::InitData()
{
    fd_id = -1;
    fd_create_time = DateTime::Now;
    fd_modify_time = DateTime::Now;
    fd_create_author_id = -1;
    fd_modify_author_id = -1;


    fd_nchar_ext1 = "";
    fd_nchar_ext2 = "";
    fd_ntext_ext1 = "";
    fd_ntext_ext2 = "";
    fd_integer_ext1 = 0;
    fd_integer_ext2 = 0;
    fd_float_ext1 = 0;
    fd_float_ext2 = 0;

    fd_desc = "";
}

int csharp_mis_table::get_module_id()
{
    return -1;
}


int csharp_mis_table::DeleteSQL()
{
    csharp_crm_login_member^ clmLogin = csharp_MIS_Global::LoginUser;

    String^ ssql = this->get_Record_Operate_SQL(csharp_Record_Operate::R_DELETE);

    if (clmLogin != null)
    {
        if (clmLogin->CanModuleDelete(get_module_id()))
        {
            return db->ExecNonSQL(ssql);
        }
        else
        {
            //throw gcnew Exception("你没有权限删除这条记录,请用其它用户登陆再试!");
            gce::ShowError("你没有权限删除这条记录, 请用其它用户登陆再试!");
            return -1;
        }
    }
    else
    {
        return db->ExecNonSQL(ssql);
    }
}

int csharp_mis_table::InsertSQL()
{
    csharp_crm_login_member^ clmLogin = csharp_MIS_Global::LoginUser;

    String^ ssql = this->get_Record_Operate_SQL(csharp_Record_Operate::R_INSERT);

    if (clmLogin != null)
    {
        if (clmLogin->CanModuleWrite(get_module_id()))
        {
            return db->ExecNonSQL(ssql);
        }
        else
        {
            
            //throw gcnew Exception("你没有权限写入这条记录,请用其它用户登陆再试!");
            gce::ShowError("你没有权限修改这条记录, 请用其它用户登陆再试!");
            return -1;
        }
    }
    else
    {
        return db->ExecNonSQL(ssql);
    }
}

int csharp_mis_table::UpdateSQL()
{
    csharp_crm_login_member^ clmLogin = csharp_MIS_Global::LoginUser;

    String^ ssql = get_Record_Operate_SQL(csharp_Record_Operate::R_UPDATE);

    if (clmLogin != null)
    {
        if (clmLogin->CanModuleWrite(get_module_id()))
        {
            return db->ExecNonSQL(ssql);
        }
        else
        {
            //throw gcnew Exception("你没有权限写入这条记录,请用其它用户登陆再试!");
            gce::ShowError("你没有权限写入这条记录, 请用其它用户登陆再试!");
            return -1;
        }
    }
    else
    {
        return db->ExecNonSQL(ssql);
    }
}

bool csharp_mis_table::UpdateFieldValue(String^ sRecordID, String^ sFieldName,
    String^ sFieldValue, String^ sTableName, csharp_db^ db)
{
    String^ ssql = "UPDATE [" + sTableName + "] SET [" + sFieldName + "]=" + ConvertToSQLString(sFieldName, sFieldValue, sTableName, db);
    ssql += " WHERE [fd_id] = " + sRecordID;

    return db->ExecNonSQL(ssql) != 0;

}

String^ csharp_mis_table::ConvertToSQLString(String^ sFieldName, 
    String^ sFieldValue, String^ sTableName, csharp_db^ db)
{
    csharp_Field^  f = db->GetFieldInfo(sFieldName, sTableName);

    switch (f->DataType)
    {
    case csharp_DataType::dtString:
        return "'" + gce::CheckSQLString(sFieldValue) + "'";
    case csharp_DataType::dtDateTime:
        return "\'" + sFieldValue + "\'";
    }

    return sFieldValue;
}

csharp_StringList^ csharp_mis_table::getModuleListForTypeCalling(int calling_id)
{
    return null;
}

csharp_StringList^ csharp_mis_table::getModuleListForTypeCalling(String^ calling_name)
{

    return null;
}

int csharp_mis_table::GetNewID()
{
    return db->GetMaxID(m_sTableName, "") + 1;
}

int csharp_mis_table::GetLoginID()
{
    return (csharp_MIS_Global::LoginUser != null ? csharp_MIS_Global::LoginUser->fd_id : -1);
}

int csharp_mis_table::getRecordCount()
{
    DataTable^ dt = db->ExecSQLQuery("SELECT Count(*) AS fd_sum FROM " + m_sTableName);
    return (int)dt->Rows[0]["fd_sum"];
}

int csharp_mis_table::GetIndex(String^ sFieldName, String^ sValue)
{
    return db->GetIDFromValue(sFieldName, sValue, m_sTableName);
}

Object^ csharp_mis_table::getFieldValueForLastRecord(String^ sFieldName)
{
    return db->getFieldValueForLastRecord(sFieldName, m_sTableName, "");
}

bool csharp_mis_table::readDataFromID(String^ sID)
{
    DataTable^ dt = db->ExecSQLQuery("SELECT * FROM " + m_sTableName + " WHERE fd_id =" + sID);
    return readAll(dt);

}

int csharp_mis_table::find_s(String^ sFieldName, String^ sFileValue, String^ s_condition)
{
    String^ ssql = "SELECT fd_id," + sFieldName + " FROM " + m_sTableName + " WHERE "
        + sFieldName + "=\'" + gce::CheckSQLString(sFileValue) + "\'";

    if (s_condition->Trim() != "")
        ssql += " AND " + s_condition;

    DataTable^ dt = db->ExecSQLQuery(ssql);
    if (dt->Rows->Count > 0)
    {
        return (int)dt->Rows[0]["fd_id"];

    }
    return -1;
}

int csharp_mis_table::find_s(String^ sFieldName, String^ sFileValue)
{
    return find_s(sFieldName, sFileValue, "");
}


int csharp_mis_table::find_d(String^ sFieldName, Object^ oFieldValue, String^ sCondition)
{
    String^ ssql = "SELECT fd_id," + sFieldName + " FROM " + m_sTableName + " WHERE "
        + sFieldName + "=" + oFieldValue->ToString();

    if (sCondition->Trim()->Length != 0)
    {
        ssql += " WHERE " + sCondition;
    }

    DataTable^ dt = db->ExecSQLQuery(ssql);
    if (dt->Rows->Count > 0)
    {
        return (int)dt->Rows[0]["fd_id"];

    }
    return -1;
}

int csharp_mis_table::find_t(String^ sFieldName, DateTime dt1, DateTime dt2, String^ sCondition)
{
    String^ ssql = "SELECT fd_id FROM " + m_sTableName + " WHERE "
        + sFieldName + " between \'" + dt1.ToString() + "\' AND \'" + dt2.ToString() + "\'";

    if (sCondition->Trim()->Length != 0)
    {
        ssql += " AND " + sCondition;
    }

    DataTable^ dt = db->ExecSQLQuery(ssql);
    if (dt->Rows->Count > 0)
    {
        return (int)dt->Rows[0]["fd_id"];
    }
    return -1;
}

bool csharp_mis_table::readFromFieldValue(String^ sFieldName, Object^ oFieldValue)
{
    String^ ssql = "SELECT * FROM " + m_sTableName + " WHERE " + sFieldName + "=";
    if (oFieldValue->GetType()->ToString() == "System.String")
    {
        ssql += "\'" + oFieldValue->ToString() + "\'";
    }
    else
    {
        throw gcnew Exception("不能识别的数据类型");
    }
    return readAll(db->ExecSQLQuery(ssql));
}

bool csharp_mis_table::readDataFromID(int iID)
{
    return readAll(db->ExecSQLQuery("SELECT * FROM " + m_sTableName + " WHERE fd_id =" + iID.ToString()));
}

void csharp_mis_table::errorRread(int iID)
{
    throw gcnew Exception("错误:在表“" + m_sTableName + "”中,无法读取ID号为:“" + iID.ToString() + "”的数据库记录!");
}

void csharp_mis_table::errorRread(String^ sID)
{
    throw gcnew Exception("错误:在表“" + m_sTableName + "”中,无法读取ID号为:“" + sID + "”的数据库记录!");
}

void csharp_mis_table::errorDelete(int iID)
{
    throw gcnew Exception("错误:在表“" + m_sTableName + "”中,无法删除ID号为:“" + iID.ToString() + "”的数据库记录!");
}

int csharp_mis_table::updateID(int nNewID)
{
    return db->ExecNonSQL("UPDATE " + m_sTableName + "  SET fd_id = " + nNewID.ToString() + " WHERE fd_id=" +
        fd_id.ToString());
}

bool csharp_mis_table::readDataFromName_CN(String^ sValue)
{
    return readAll(db->ExecSQLQuery("SELECT * FROM " + m_sTableName + " WHERE fd_name_cn =\'" + gce::CheckSQLString(sValue) + "\'"));
}

bool csharp_mis_table::readDataFromName(String^ sValue)
{
    String^ fd_field_name = "fd_name_cn";

    if (gce::languageID == 1)
    {
        fd_field_name = "fd_name_en";
    }

    return readAll(db->ExecSQLQuery("SELECT * FROM " + m_sTableName + " WHERE " + fd_field_name + "=\'" + gce::CheckSQLString(sValue) + "\'"));
}

bool csharp_mis_table::readAll(DataTable^ dt)
{
    if (dt->Rows->Count > 0)
    {
        /*
        fd_id = (int)dt->Rows[0]["fd_id"];
        fd_create_time = Convert::ToDateTime(dt->Rows[0]["fd_create_time"]);
        fd_modify_time = Convert::ToDateTime(dt->Rows[0]["fd_modify_time"]);
        fd_desc = dt->Rows[0]["fd_desc"]->ToString();
        return true;
        */
        return readRowAll(dt->Rows[0]);
    }
    return false;
}

bool csharp_mis_table::readRowAll(DataRow^ dr)
{
    fd_id = (int)dr["fd_id"];
    fd_create_time = Convert::ToDateTime(dr["fd_create_time"]);
    fd_modify_time = Convert::ToDateTime(dr["fd_modify_time"]);
    fd_desc = dr["fd_desc"]->ToString();


    return true;
}

int csharp_mis_table::updateMemoryField(String^ sFieldName, MemoryStream^ msFieldValue)
{
#if _WINDOWS_PLATFORM_
    if (msFieldValue == null)   return 0;
    String^ ssql = "UPDATE " + m_sTableName + " SET " + sFieldName + "=@"
        + sFieldName + " WHERE fd_id=" + fd_id.ToString();

    String^ ssqlName = "@" + sFieldName;


    if (db->dataFormat == csharp_DataFormat::dfAccdb || db->dataFormat == csharp_DataFormat::dfMDB)
    {
        OleDbConnection onn = gcnew OleDbConnection(db->GetConnection().ConnectionString);
        OleDbCommand cmd = gcnew OleDbCommand(ssql, onn);
        OleDbParameter par_filed = gcnew OleDbParameter(ssqlName, OleDbType.LongVarBinary);
        par_filed.Value = msFieldValue.ToArray();
        cmd.Parameters.Add(par_filed);
        onn.Open();
        int n = cmd.ExecuteNonQuery();
        onn.Close();
        return n;
    }
    else if (db->dataFormat == csharp_DataFormat::dfSQLServer)
    {
        SqlConnection onn = gcnew SqlConnection(db->GetConnection().ConnectionString);
        SqlCommand cmd = gcnew SqlCommand(ssql, onn);
        SqlParameter par_filed = gcnew SqlParameter(ssqlName, OleDbType.LongVarBinary);

        par_filed.Value = msFieldValue.ToArray();
        cmd.Parameters.Add(par_filed);

        onn.Open();
        int n = cmd.ExecuteNonQuery();
        onn.Close();
        return n;
    }
    else
    {
        //gce::ShowInfo("InsertSQL(crm_natural_person em)函数还未完成,请重新完成!",this);
        return 0;
    }
#else

    throw gcnew Exception("代码未完成!");
#endif
}

String^ csharp_mis_table::get_Record_Operate_SQL(csharp_Record_Operate ro)
{
    String^ ssql;


    switch (ro)
    {
    case csharp_Record_Operate::R_DELETE:
    {
        ssql = "DELETE FROM " + m_sTableName + " WHERE fd_id = " + fd_id.ToString();
        break;
    }

    case csharp_Record_Operate::R_INSERT:
    {
        fd_id = GetNewID();
        ssql = "INSERT INTO " + m_sTableName +
            "(fd_id,fd_create_time,fd_modify_time,fd_create_author_id,fd_modify_author_id,fd_desc) VALUES(" +
            "" + fd_id.ToString() + "," +
            "\'" + DateTime::Now.ToShortDateString() + "\'," +
            "\'" + DateTime::Now.ToShortDateString() + "\'," +
            "" + GetLoginID().ToString() + "," +
            "" + GetLoginID().ToString() + "," +
            "\'" + gce::CheckSQLString(fd_desc) + "\'" + ")";
        break;
    }

    case csharp_Record_Operate::R_UPDATE:
    {

        ssql = "UPDATE [" + m_sTableName + "] SET " +
            //"fd_create_time=\'" + fd_create_time.ToString() + "\'," +
            "[fd_create_author_id] =" + GetLoginID().ToString() + "," +
            "[fd_modify_time]=\'" + DateTime::Now.ToShortDateString() + "\'," +
            "[fd_desc]=\'" + gce::CheckSQLString(fd_desc) + "\' WHERE fd_id =" + fd_id.ToString();

        break;
    }
    case csharp_Record_Operate::R_VIEW:
    {
        if (gce::languageID == 2)
        {
            ssql = "SELECT fd_id AS 索引,fd_create_time AS 创建时间,fd_modify_time AS 修改时间,fd_desc AS  描述 FROM " + m_sTableName;
        }
        else
        {
            ssql = "SELECT fd_id AS [Index], fd_create_time AS [Create time],fd_modify_time AS [Modify time]fd_desc AS [Description] FROM " + m_sTableName;

        }
        break;
    }
    default:
        ssql = "";
        break;
    }
    return ssql;
}

csharp_mis_table::csharp_mis_table(String^ sTableName, csharp_db^ fromDB)
{
    InitData();
    db = fromDB;
    m_sTableName = sTableName;
}

csharp_mis_table::csharp_mis_table(String^ sTableName)
{
    InitData();
    db = csharp_MIS_Global::db_data;
    m_sTableName = sTableName;
}

bool csharp_mis_table::readRecorderForMaxID()
{
    return readAll(db->ExecSQLQuery("SELECT TOP 1 * FROM " + m_sTableName + " ORDER BY fd_id DESC"));
}



int csharp_mis_image::updatePicture(String^ sFullPath)

{
    /*
    FileStream fs = gcnew FileStream(sFullPath, FileMode.Open, FileAccess.Read);
    BinaryReader br = gcnew BinaryReader(fs);
    byte[] _imgBytesIn = br.ReadBytes((int)fs.Length);
    br.Close();
    fs.Close();
    image = gcnew System.IO.MemoryStream(_imgBytesIn);
    return updateMemoryField("fd_image", image, null);
    */
    return 0;
}

bool csharp_mis_image::readPicture()
{
    DataTable^ dt = db->ExecSQLQuery("SELECT fd_image FROM " + m_sTableName + " WHERE fd_id=" +
        fd_id.ToString());

    if (dt->Rows->Count > 0)
    {
        if (dt->Rows[0]["fd_image"] != DBNull::Value)
        {
            fd_image = gcnew MemoryStream( (array<byte>^)dt->Rows[0]["fd_image"]);
            return true;
        }
    }
    return false;
}

int csharp_mis_image::get_new_order(String^ sTableName, String^ sType, String^ sKey)
{
    String^ ssql = "SELECT TOP 1 fd_page_order FROM  " + sTableName + " WHERE fd_type=\'" +
        sType + "\' AND fd_key=\'" + sKey + "\' ORDER BY fd_page_order DESC";

    DataTable^ dt = csharp_DB_Global::db_data->ExecSQLQuery(ssql);
    if (dt->Rows->Count > 0)
        return System::Convert::ToInt32(dt->Rows[0]["fd_page_order"]) + 1;
    else
        return 1;
}


String^ csharp_mis_image::get_Record_Operate_SQL(csharp_Record_Operate ro)
{
    String^ ssql = "";

    switch (ro)
    {
    case csharp_Record_Operate::R_INSERT:
    {
        fd_id = GetNewID();
        ssql = "INSERT INTO " + m_sTableName +
            "(fd_id,fd_create_time,fd_modify_time,fd_create_author_id,fd_modify_author_id," +
            "fd_type,fd_key,fd_page_order,fd_image_ext," +
            "fd_nchar_ext1,fd_nchar_ext2,fd_ntext_ext1,fd_ntext_ext2,fd_integer_ext1," +
            "fd_integer_ext2,fd_float_ext1,fd_float_ext2,fd_desc) VALUES(" +
            "" + fd_id.ToString() + "," +
            "\'" + System::DateTime::Now.ToString() + "\'," +
            "\'" + System::DateTime::Now.ToString() + "\'," +
            "" + csharp_MIS_Global::LoginUser->fd_id.ToString() + "," +
            "" + csharp_MIS_Global::LoginUser->fd_id.ToString() + "," +
            "\'" + gce::CheckSQLString(fd_type) + "\'," +
            "\'" + gce::CheckSQLString(fd_key) + "\'," +
            "" + fd_page_order.ToString() + "," +
            "\'" + gce::CheckSQLString(fd_image_ext) + "\'," +
            "\'" + gce::CheckSQLString(fd_nchar_ext1) + "\'," +
            "\'" + gce::CheckSQLString(fd_nchar_ext2) + "\'," +
            "\'" + gce::CheckSQLString(fd_ntext_ext1) + "\'," +
            "\'" + gce::CheckSQLString(fd_ntext_ext2) + "\'," +
            "" + fd_integer_ext1.ToString() + "," +
            "" + fd_integer_ext2.ToString() + "," +
            "" + fd_float_ext1.ToString() + "," +
            "" + fd_float_ext2.ToString() + "," +
            "\'" + gce::CheckSQLString(fd_desc) + "\')";
        break;
    }

    case csharp_Record_Operate::R_UPDATE:
    {
        ssql = "UPDATE " + m_sTableName + " SET ";
        ssql += "fd_id=" + fd_id.ToString() + ",";
        ssql += "fd_modify_time=\'" + System::DateTime::Now.ToString() + "\',";
        ssql += "fd_modify_author_id=" + csharp_MIS_Global::LoginUser->fd_id.ToString() + ",";
        ssql += "fd_type=\'" + gce::CheckSQLString(fd_type) + "\',";
        ssql += "fd_key=\'" + gce::CheckSQLString(fd_key) + "\',";
        ssql += "fd_page_order=" + fd_page_order.ToString() + ",";
        ssql += "fd_image_ext=\'" + gce::CheckSQLString(fd_image_ext) + "\',";
        ssql += "fd_nchar_ext1=\'" + gce::CheckSQLString(fd_nchar_ext1) + "\',";
        ssql += "fd_nchar_ext2=\'" + gce::CheckSQLString(fd_nchar_ext2) + "\',";
        ssql += "fd_ntext_ext1=\'" + gce::CheckSQLString(fd_ntext_ext1) + "\',";
        ssql += "fd_ntext_ext2=\'" + gce::CheckSQLString(fd_ntext_ext2) + "\',";
        ssql += "fd_integer_ext1=" + fd_integer_ext1.ToString() + ",";
        ssql += "fd_integer_ext2=" + fd_integer_ext2.ToString() + ",";
        ssql += "fd_float_ext1=" + fd_float_ext1.ToString() + ",";
        ssql += "fd_float_ext2=" + fd_float_ext2.ToString() + ",";
        ssql += "fd_desc=\'" + gce::CheckSQLString(fd_desc) + "\'";
        ssql += "  WHERE fd_id=" + fd_id.ToString();
        break;
    }
    default:
        return csharp_mis_table::get_Record_Operate_SQL(ro);
    }
    return ssql;
}

bool csharp_mis_image::readAll(DataTable^ dt)
{
    if (dt->Rows->Count > 0)
    {
        fd_id = (int)dt->Rows[0]["fd_id"];
        fd_create_time = Convert::ToDateTime(dt->Rows[0]["fd_create_time"]);
        fd_modify_time = Convert::ToDateTime(dt->Rows[0]["fd_modify_time"]);
        fd_create_author_id = (int)dt->Rows[0]["fd_create_author_id"];
        fd_modify_author_id = (int)dt->Rows[0]["fd_modify_author_id"];
        fd_type = dt->Rows[0]["fd_type"]->ToString();
        fd_key = dt->Rows[0]["fd_key"]->ToString();
        fd_page_order = (int)dt->Rows[0]["fd_page_order"];
        fd_image_ext = dt->Rows[0]["fd_image_ext"]->ToString();
        fd_nchar_ext1 = dt->Rows[0]["fd_nchar_ext1"]->ToString();
        fd_nchar_ext2 = dt->Rows[0]["fd_nchar_ext2"]->ToString();
        fd_ntext_ext1 = dt->Rows[0]["fd_ntext_ext1"]->ToString();
        fd_ntext_ext2 = dt->Rows[0]["fd_ntext_ext2"]->ToString();
        fd_integer_ext1 = (int)dt->Rows[0]["fd_integer_ext1"];
        fd_integer_ext2 = (int)dt->Rows[0]["fd_integer_ext2"];
        fd_float_ext1 = Convert::ToSingle(dt->Rows[0]["fd_float_ext1"]);
        fd_float_ext2 = Convert::ToSingle(dt->Rows[0]["fd_float_ext2"]);
        fd_desc = dt->Rows[0]["fd_desc"]->ToString();
        return true;
    }
    return false;
}



void csharp_mis_image::readRowAll(DataRow dr)
{
    fd_id = (int)dr["fd_id"];
    fd_create_time = Convert::ToDateTime(dr["fd_create_time"]);
    fd_modify_time = Convert::ToDateTime(dr["fd_modify_time"]);
    fd_create_author_id = (int)dr["fd_create_author_id"];
    fd_modify_author_id = (int)dr["fd_modify_author_id"];
    fd_type = dr["fd_type"]->ToString();
    fd_key = dr["fd_key"]->ToString();
    fd_page_order = (int)dr["fd_page_order"];
    fd_image_ext = dr["fd_image_ext"]->ToString();
    fd_nchar_ext1 = dr["fd_nchar_ext1"]->ToString();
    fd_nchar_ext2 = dr["fd_nchar_ext2"]->ToString();
    fd_ntext_ext1 = dr["fd_ntext_ext1"]->ToString();
    fd_ntext_ext2 = dr["fd_ntext_ext2"]->ToString();
    fd_integer_ext1 = (int)dr["fd_integer_ext1"];
    fd_integer_ext2 = (int)dr["fd_integer_ext2"];
    fd_float_ext1 = Convert::ToSingle(dr["fd_float_ext1"]);
    fd_float_ext2 = Convert::ToSingle(dr["fd_float_ext2"]);
    fd_desc = dr["fd_desc"]->ToString();
}



/// <summary>
/// 
/// </summary>
/// <param name="ro"></param>
/// <returns></returns>
/// 创建时间: 2024-08-27  最后一次修改时间:2024-08-27   
String^ csharp_mis_identity::get_Record_Operate_SQL(csharp_Record_Operate ro)
{
    String^ ssql;
     
    switch (ro)
    {
    case csharp_Record_Operate::R_DELETE:
    {
        ssql = "DELETE FROM " + m_sTableName + " WHERE fd_id = " + fd_id.ToString();
        break;
    }

    case csharp_Record_Operate::R_INSERT:
    {
        fd_id = GetNewID();
        ssql = "INSERT INTO " + m_sTableName +
            "(fd_id,fd_create_time,fd_modify_time,fd_create_author_id,fd_modify_author_id," +
            "fd_name_cn,fd_name_en,fd_desc) VALUES(" +
            "" + fd_id.ToString() + "," +
            "\'" + DateTime::Now.ToShortDateString() + "\'," +
            "\'" + DateTime::Now.ToShortDateString() + "\'," +
            "" + GetLoginID().ToString() + "," +
            "" + GetLoginID().ToString() + "," +
            "\'" + gce::CheckSQLString(fd_name_cn) + "\'," +
            "\'" + gce::CheckSQLString(fd_name_en) + "\'," +
            "\'" + gce::CheckSQLString(fd_desc) + "\'" + ")";
        break;
    }

    case csharp_Record_Operate::R_UPDATE:
    {

        ssql = "UPDATE [" + m_sTableName + "] SET " +
            //"fd_create_time=\'" + fd_create_time.ToString() + "\'," +
            "[fd_create_author_id] =" + GetLoginID().ToString() + "," +
            "[fd_modify_time]=\'" + DateTime::Now.ToShortDateString() + "\'," +

            "[fd_name_cn]=\'" + gce::CheckSQLString(fd_name_cn) + "\'," +
            "[fd_name_en]=\'" + gce::CheckSQLString(fd_name_en) + "\'," +

            "[fd_desc]=\'" + gce::CheckSQLString(fd_desc) + "\' WHERE fd_id =" + fd_id.ToString();

        break;
    }
    case csharp_Record_Operate::R_VIEW:
    {
        if (gce::languageID == 2)
        {
            ssql = "SELECT fd_id AS 索引,fd_create_time AS 创建时间,fd_modify_time AS 修改时间," +
                "fd_name_cn AS 文件名, fd_name_en AS 英文名, fd_desc AS  描述 FROM " + m_sTableName;
        }
        else
        {
            ssql = "SELECT fd_id AS [Index], fd_create_time AS [Create time],fd_modify_time AS [Modify time]," +
                "fd_name_cn AS [China], fd_name_en AS [English], fd_desc AS [Description] FROM " + m_sTableName;

        }
        break;
    }
    default:
        ssql = "";
        break;
    }
    return ssql;
}

bool csharp_mis_identity::readRowAll(DataRow^ dr)
{
  
    fd_id = (int)dr["fd_id"];
    fd_create_time = Convert::ToDateTime(dr["fd_create_time"]);
    fd_modify_time = Convert::ToDateTime(dr["fd_modify_time"]);
    fd_create_author_id = (int)dr["fd_create_author_id"]; 
    fd_modify_author_id = (int)dr["fd_modify_author_id"];
    fd_name_cn = dr["fd_name_cn"]->ToString();
    fd_name_cn = dr["fd_name_cn"]->ToString();
    fd_desc = dr["fd_desc"]->ToString();

    return true;    
}









_LF_END_


http://www.kler.cn/a/307140.html

相关文章:

  • 项目集章程program charter
  • vue3+element-plus==> el-form输入响应式失效踩坑!!!!!!!!!!
  • 在 Ubuntu 上安装 `.deb` 软件包有几种方法
  • 深入理解接口测试:实用指南与最佳实践5.0(一)
  • Hadoop(环境搭建篇)
  • 深入理解 Vue v-model 原理与应用
  • Oracle(121)如何进行数据文件的恢复?
  • Linux中使用Docker构建Nginx容器完整教程
  • k8s使用本地docker私服启动自制的flink集群
  • OKHttp实现原理分享
  • vue3 指定元素全屏 screenfull(可直接粘贴使用)
  • 《凡人歌》:网络安全组电话响3声必须接,安全组长被压迫患得惊恐症、抑郁症
  • HTTP跨域请求时为什么要发送options请求
  • 【LLMs对抗性提示:提示泄漏、非法行为、DAN、Waluigi效应、 游戏模拟器、防御策略————】
  • JSON教程
  • 聪明办法学 Python 第二版.1.学习安排
  • vue3项目实现全局国际化
  • 深入理解C++中的std::string::substr成员函数:子串操作的艺术
  • 增强LinkedList实现瑞士轮赛制编排
  • C++课程笔记 类和对象
  • Android JobScheduler介绍
  • 介绍一些免费 的 html 5模版网站 和配色 网站
  • Spring的核心思想
  • Linux常用命令以及操作技巧
  • 数据库之索引<保姆级文章>
  • 纯血鸿蒙NEXT常用的几个官方网站