using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ObjectModel.Backend
{
    /// <summary>
    /// 日志
    /// </summary>
    public class BMLogModel
    {
        /// <summary>
        /// 操作员
        /// </summary>
        public string username;

        /// <summary>
        /// 操作的数值备份
        /// </summary>
        public long numBak;

        /// <summary>
        /// 操作的具体数值
        /// </summary>
        public long num;

        /// <summary>
        /// 对谁操作
        /// </summary>
        public int toObj;

        /// <summary>
        /// 说明
        /// </summary>
        public string memo;

        /// <summary>
        /// 操作类型,1修改资产 2系统日志
        /// </summary>
        public int lx;

        /// <summary>
        /// 操作时间
        /// </summary>
        public DateTime CreateTime;

        public BMLogModel() { }

        public BMLogModel(DataRow row) {
            this.username = row["username"].ToString();
            this.memo = row["memo"].ToString();
            this.numBak = (long)row["numBak"];
            this.num = (long)row["num"];
            this.toObj = (int)row["toObj"];
            this.lx = (int)row["lx"];
            this.CreateTime = (DateTime)row["CreateTime"];
        }

        /// <summary>
        /// 获取保存日志SQL
        /// </summary>
        /// <returns></returns>
        public string GetInsertSql() {
            return $"INSERT INTO [bm_log]( [username], [numBak], [num], [toObj], [memo], [lx]) VALUES ('{username}', {numBak}, {num}, {toObj}, '{memo}', {lx})";
        }
    }
}
