コード例 #1
0
ファイル: SM.cs プロジェクト: eprasart/kBit.ERP
        //public static void SetStatus(long Id, string s)
        //{
        //    DateTime? ts = SqlFacade.GetCurrentTimeStamp();
        //    SqlFacade.Connection.UpdateOnly(new User { Status = s, ChangeBy = App.session.Username, ChangeAt = ts }, p => new { p.Status, p.ChangeBy, p.ChangeAt }, p => p.Id == Id);
        //}

        //public static bool IsLocked(long Id)
        //{
        //    return SqlFacade.Connection.Exists<User>("Id = @Id and Lock_By = @LockBy", new { Id = Id, LockBy = App.session.Username });
        //}

        //public static LockInfo GetLockInfo(long Id)
        //{
        //    var m = Select(Id);
        //    var l = new LockInfo();
        //    l.Id = Id;
        //    l.LockBy = m.LockBy;
        //    l.LockAt = m.LockAt;
        //    return l;
        //}

        //public static void Lock(long Id)
        //{
        //    DateTime ts = SqlFacade.GetCurrentTimeStamp();
        //    SqlFacade.Connection.UpdateOnly(new User { LockBy = App.session.Username, LockAt = ts }, p => new { p.LockBy, p.LockAt }, p => p.Id == Id);
        //}

        //public static void ReleaseLock(long Id)
        //{
        //    if (Id == 0) return;
        //    DateTime ts = SqlFacade.GetCurrentTimeStamp();
        //    SqlFacade.Connection.UpdateOnly(new User { LockBy = null }, p => p.LockBy, p => p.Id == Id);
        //}

        //public static bool IsExist(string Username, long Id = 0)
        //{
        //    return SqlFacade.Connection.Exists<User>("Id <> @Id and Username = @Username", new { Id = Id, Username = Username });
        //}

        public static void UpdatePwd(User m)
        {
            string sqlPwd = "select crypt('" + m.Pwd + "', gen_salt('bf'))";

            m.Pwd = SqlFacade.Connection.ExecuteScalar <string>(sqlPwd);
            var sql = SqlFacade.SqlUpdate(TableName, "Pwd = @Pwd", "Id = @Id");

            SqlFacade.Connection.Execute(sql, m);
        }
コード例 #2
0
        public void Save()
        {
            if (!Changed)
            {
                return;
            }
            var sql = SqlFacade.SqlUpdate(TableName, "value", "", "id = :id");

            try
            {
                SqlFacade.Connection.Execute(sql, new { Value, Id });
            }
            catch (Exception ex)
            {
                ErrorLogFacade.LogToFile(ex, "sql='" + sql + "')");
            }
        }
コード例 #3
0
ファイル: IC.cs プロジェクト: eprasart/kBit.ERP
        public static long Save(UnitMeasure m)
        {
            string sql = "";

            if (m.Id == 0)
            {
                m.Insert_By = App.session.Username;
                sql         = SqlFacade.SqlInsert(TableName, "code, default_factor, description, insert_by", "", true);
                m.Id        = SqlFacade.Connection.ExecuteScalar <long>(sql, m);
            }
            else
            {
                m.Change_By = App.session.Username;
                sql         = SqlFacade.SqlUpdate(TableName, "code, description, default_factor, note, change_by, change_at, change_no", "change_at = now(), change_no = change_no + 1", "id = :id");
                SqlFacade.Connection.Execute(sql, m);
                ReleaseLock(m.Id);  // Unlock
            }
            return(m.Id);
        }
コード例 #4
0
        public static long Save(Account m)
        {
            string sql = "";

            m.Branch_Code = App.session.Branch_Code;
            if (m.Id == 0)
            {
                m.Insert_By = App.session.Username;
                sql         = SqlFacade.SqlInsert(TableName, "branch_code, code, description, type, address, name, phone, fax, email, note, insert_by", "", true);
                m.Id        = SqlFacade.Connection.ExecuteScalar <long>(sql, m);
            }
            else
            {
                m.Change_By = App.session.Username;
                sql         = SqlFacade.SqlUpdate(TableName, "branch_code, code, description, type, address, name, phone, fax, email, note, change_by, change_at, change_no", "change_at = now(), change_no = change_no + 1", "id = :id");
                SqlFacade.Connection.Execute(sql, m);
                ReleaseLock(m.Id);  // Unlock
            }
            return(m.Id);
        }
コード例 #5
0
        public static void SetStatus(long Id, string status)
        {
            var sql = SqlFacade.SqlUpdate(TableName, "status, change_by, change_at", "change_at = now()", "id = :id");

            SqlFacade.Connection.Execute(sql, new { status, Change_By = App.session.Username, Id });
        }